@@ -196,8 +196,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
196196 /// corresponding to a set of generic parameters.
197197 pub fn create_substs_for_generic_args < ' a , ' b , A , P , I > (
198198 tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
199- span : Span ,
200- err_if_invalid : bool ,
201199 def_id : DefId ,
202200 parent_substs : & [ Kind < ' tcx > ] ,
203201 has_self : bool ,
@@ -279,48 +277,36 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
279277 let mut progress_arg = true ;
280278 match ( next_arg, next_param) {
281279 ( Some ( arg) , Some ( param) ) => {
282- match ( & param. kind , arg ) {
283- ( GenericParamDefKind :: Lifetime , GenericArg :: Lifetime ( _ ) ) => {
280+ match ( arg , & param. kind ) {
281+ ( GenericArg :: Lifetime ( _ ) , GenericParamDefKind :: Lifetime ) => {
284282 push_kind ( & mut substs, provided_kind ( param, arg) ) ;
285283 next_param = params. next ( ) ;
286284 }
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 { .. } ) => {
299286 // We expected a type argument, but got a lifetime
300287 // argument. This is an error, but we need to handle it
301288 // gracefully so we can report sensible errors. In this
302289 // case, we're simply going to infer the remaining
303290 // 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 ;
313303 }
314304 }
315305 }
316306 ( Some ( _) , None ) => {
317307 // We should never be able to reach this point with well-formed input.
318308 // Getting to this point means the user supplied more arguments than
319309 // there are parameters.
320- if err_if_invalid {
321- tcx. sess . delay_span_bug ( span,
322- "GenericArg did not have matching GenericParamDef" ) ;
323- }
324310 }
325311 ( None , Some ( param) ) => {
326312 // If there are fewer arguments than parameters, it means
@@ -428,8 +414,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
428414
429415 let substs = Self :: create_substs_for_generic_args (
430416 self . tcx ( ) ,
431- span,
432- false ,
433417 def_id,
434418 & [ ] [ ..] ,
435419 self_ty. is_some ( ) ,
0 commit comments