@@ -336,33 +336,30 @@ impl<'a, 'b> Context<'a, 'b> {
336
336
Placeholder ( _) => {
337
337
// record every (position, type) combination only once
338
338
let ref mut seen_ty = self . arg_unique_types [ arg] ;
339
- let i = match seen_ty. iter ( ) . position ( |x| * x == ty) {
340
- Some ( i) => i,
341
- None => {
342
- let i = seen_ty. len ( ) ;
343
- seen_ty. push ( ty) ;
344
- i
345
- }
346
- } ;
339
+ let i = seen_ty. iter ( ) . position ( |x| * x == ty) . unwrap_or_else ( || {
340
+ let i = seen_ty. len ( ) ;
341
+ seen_ty. push ( ty) ;
342
+ i
343
+ } ) ;
347
344
self . arg_types [ arg] . push ( i) ;
348
345
}
349
346
Count => {
350
- match self . count_positions . entry ( arg) {
351
- Entry :: Vacant ( e) => {
352
- let i = self . count_positions_count ;
353
- e. insert ( i) ;
354
- self . count_args . push ( Exact ( arg) ) ;
355
- self . count_positions_count += 1 ;
356
- }
357
- Entry :: Occupied ( _) => { }
347
+ if let Entry :: Vacant ( e) = self . count_positions . entry ( arg) {
348
+ let i = self . count_positions_count ;
349
+ e. insert ( i) ;
350
+ self . count_args . push ( Exact ( arg) ) ;
351
+ self . count_positions_count += 1 ;
358
352
}
359
353
}
360
354
}
361
355
}
362
356
363
357
Named ( name) => {
364
- let idx = match self . names . get ( & name) {
365
- Some ( e) => * e,
358
+ match self . names . get ( & name) {
359
+ Some ( idx) => {
360
+ // Treat as positional arg.
361
+ self . verify_arg_type ( Exact ( * idx) , ty)
362
+ }
366
363
None => {
367
364
let msg = format ! ( "there is no argument named `{}`" , name) ;
368
365
let sp = if self . is_literal {
@@ -372,11 +369,8 @@ impl<'a, 'b> Context<'a, 'b> {
372
369
} ;
373
370
let mut err = self . ecx . struct_span_err ( sp, & msg[ ..] ) ;
374
371
err. emit ( ) ;
375
- return ;
376
372
}
377
- } ;
378
- // Treat as positional arg.
379
- self . verify_arg_type ( Exact ( idx) , ty)
373
+ }
380
374
}
381
375
}
382
376
}
0 commit comments