File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,10 +120,27 @@ fn check_call_args(
120120 . map ( |param| param. name . clone ( ) )
121121 . collect ( ) ;
122122
123+ let mut seen_names = HashSet :: new ( ) ;
123124 for arg in args {
124125 let Some ( name) = & arg. name else {
125126 continue ;
126127 } ;
128+ if !seen_names. insert ( name. as_str ( ) ) {
129+ analyzer. diagnostics . push (
130+ Diagnostic :: error (
131+ code:: DUPLICATE_ARGUMENT ,
132+ format ! ( "call to `{call_name}` repeats argument `{name}`." ) ,
133+ arg. span . clone ( ) ,
134+ "duplicate argument" ,
135+ )
136+ . with_cause ( "Each named parameter can be provided at most once." )
137+ . with_fix (
138+ "remove_duplicate_argument" ,
139+ format ! ( "Remove the extra `{name}: ...` argument." ) ,
140+ "manual" ,
141+ ) ,
142+ ) ;
143+ }
127144 if !param_names. contains ( name) {
128145 analyzer. diagnostics . push (
129146 Diagnostic :: error (
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ pub mod code {
1010 pub const MISSING_DATA_EFFECT : & str = "RS0202" ;
1111 pub const UNKNOWN_ARGUMENT : & str = "RS0203" ;
1212 pub const MISSING_ARGUMENT : & str = "RS0204" ;
13+ pub const DUPLICATE_ARGUMENT : & str = "RS0205" ;
1314 pub const MANAGED_TO_LOCAL : & str = "RS0301" ;
1415 pub const USE_AFTER_MANAGE : & str = "RS0401" ;
1516 pub const LOCAL_VALUE_RETAINED : & str = "RS0501" ;
@@ -231,6 +232,11 @@ static DIAGNOSTIC_EXPLANATIONS: &[DiagnosticExplanation] = &[
231232 title : "missing required argument" ,
232233 explanation : "Every parameter in the resolved callee signature must be supplied by name at the call site." ,
233234 } ,
235+ DiagnosticExplanation {
236+ code : code:: DUPLICATE_ARGUMENT ,
237+ title : "duplicate named argument" ,
238+ explanation : "A call may bind each named parameter only once. Duplicate names make effect and ownership review ambiguous." ,
239+ } ,
234240 DiagnosticExplanation {
235241 code : code:: MANAGED_TO_LOCAL ,
236242 title : "managed-to-local conversion" ,
Original file line number Diff line number Diff line change 1+ // expect: RS0205
2+ mode: uses-local
3+
4+ struct Image {
5+ pixels: Buffer
6+ }
7+
8+ fn bad_resize_duplicate_argument(path: read Path) -> Unit {
9+ local image = Image.load(path: read path)
10+ Image.resize(image: mut image, image: mut image, width: 800, height: 600)
11+ }
You can’t perform that action at this time.
0 commit comments