@@ -196,8 +196,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
196
196
/// corresponding to a set of generic parameters.
197
197
pub fn create_substs_for_generic_args < ' a , ' b , A , P , I > (
198
198
tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
199
- span : Span ,
200
- err_if_invalid : bool ,
201
199
def_id : DefId ,
202
200
parent_substs : & [ Kind < ' tcx > ] ,
203
201
has_self : bool ,
@@ -279,48 +277,36 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
279
277
let mut progress_arg = true ;
280
278
match ( next_arg, next_param) {
281
279
( Some ( arg) , Some ( param) ) => {
282
- match ( & param. kind , arg ) {
283
- ( GenericParamDefKind :: Lifetime , GenericArg :: Lifetime ( _ ) ) => {
280
+ match ( arg , & param. kind ) {
281
+ ( GenericArg :: Lifetime ( _ ) , GenericParamDefKind :: Lifetime ) => {
284
282
push_kind ( & mut substs, provided_kind ( param, arg) ) ;
285
283
next_param = params. next ( ) ;
286
284
}
287
- ( GenericParamDefKind :: Lifetime , GenericArg :: Type ( _) ) => {
288
- // We expected a lifetime argument, but got a type
289
- // argument. That means we're inferring the lifetimes.
290
- push_kind ( & mut substs, inferred_kind ( None , param, infer_types) ) ;
291
- next_param = params. next ( ) ;
292
- progress_arg = false ;
293
- }
294
- ( GenericParamDefKind :: Type { .. } , GenericArg :: Type ( _) ) => {
295
- push_kind ( & mut substs, provided_kind ( param, arg) ) ;
296
- next_param = params. next ( ) ;
297
- }
298
- ( GenericParamDefKind :: Type { .. } , GenericArg :: Lifetime ( _) ) => {
285
+ ( GenericArg :: Lifetime ( _) , GenericParamDefKind :: Type { .. } ) => {
299
286
// We expected a type argument, but got a lifetime
300
287
// argument. This is an error, but we need to handle it
301
288
// gracefully so we can report sensible errors. In this
302
289
// case, we're simply going to infer the remaining
303
290
// arguments.
304
- if err_if_invalid {
305
- tcx. sess . delay_span_bug ( span,
306
- "found a GenericArg::Lifetime where a \
307
- GenericArg::Type was expected") ;
308
- }
309
- // Exhaust the iterator.
310
- while next_arg. is_some ( ) {
311
- next_arg = args. next ( ) ;
312
- }
291
+ args. by_ref ( ) . for_each ( drop) ; // Exhaust the iterator.
292
+ }
293
+ ( GenericArg :: Type ( _) , GenericParamDefKind :: Type { .. } ) => {
294
+ push_kind ( & mut substs, provided_kind ( param, arg) ) ;
295
+ next_param = params. next ( ) ;
296
+ }
297
+ ( GenericArg :: Type ( _) , GenericParamDefKind :: Lifetime ) => {
298
+ // We expected a lifetime argument, but got a type
299
+ // argument. That means we're inferring the lifetimes.
300
+ push_kind ( & mut substs, inferred_kind ( None , param, infer_types) ) ;
301
+ next_param = params. next ( ) ;
302
+ progress_arg = false ;
313
303
}
314
304
}
315
305
}
316
306
( Some ( _) , None ) => {
317
307
// We should never be able to reach this point with well-formed input.
318
308
// Getting to this point means the user supplied more arguments than
319
309
// there are parameters.
320
- if err_if_invalid {
321
- tcx. sess . delay_span_bug ( span,
322
- "GenericArg did not have matching GenericParamDef" ) ;
323
- }
324
310
}
325
311
( None , Some ( param) ) => {
326
312
// If there are fewer arguments than parameters, it means
@@ -428,8 +414,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
428
414
429
415
let substs = Self :: create_substs_for_generic_args (
430
416
self . tcx ( ) ,
431
- span,
432
- false ,
433
417
def_id,
434
418
& [ ] [ ..] ,
435
419
self_ty. is_some ( ) ,
0 commit comments