@@ -339,9 +339,9 @@ fn check_opaque_type_well_formed<'tcx>(
339
339
}
340
340
}
341
341
342
- fn check_opaque_type_parameter_valid (
343
- tcx : TyCtxt < ' _ > ,
344
- opaque_type_key : OpaqueTypeKey < ' _ > ,
342
+ fn check_opaque_type_parameter_valid < ' tcx > (
343
+ tcx : TyCtxt < ' tcx > ,
344
+ opaque_type_key : OpaqueTypeKey < ' tcx > ,
345
345
span : Span ,
346
346
) -> Result < ( ) , ErrorGuaranteed > {
347
347
let opaque_ty_hir = tcx. hir ( ) . expect_item ( opaque_type_key. def_id ) ;
@@ -352,25 +352,28 @@ fn check_opaque_type_parameter_valid(
352
352
353
353
let opaque_generics = tcx. generics_of ( opaque_type_key. def_id ) ;
354
354
let mut seen_params: FxIndexMap < _ , Vec < _ > > = FxIndexMap :: default ( ) ;
355
- for ( i, arg) in opaque_type_key. args . iter ( ) . enumerate ( ) {
355
+ for ( i, arg) in opaque_type_key. iter_captured_args ( tcx ) {
356
356
if let Err ( guar) = arg. error_reported ( ) {
357
357
return Err ( guar) ;
358
358
}
359
359
360
360
let arg_is_param = match arg. unpack ( ) {
361
361
GenericArgKind :: Type ( ty) => matches ! ( ty. kind( ) , ty:: Param ( _) ) ,
362
- GenericArgKind :: Lifetime ( lt) if is_ty_alias => {
363
- matches ! ( * lt, ty:: ReEarlyBound ( _) | ty:: ReFree ( _) )
364
- }
365
- // FIXME(#113916): we can't currently check for unique lifetime params,
366
- // see that issue for more. We will also have to ignore unused lifetime
367
- // params for RPIT, but that's comparatively trivial ✨
368
- GenericArgKind :: Lifetime ( _) => continue ,
362
+ GenericArgKind :: Lifetime ( lt) => match is_ty_alias {
363
+ true => matches ! ( * lt, ty:: ReEarlyBound ( _) | ty:: ReFree ( _) ) ,
364
+ // FIXME(#111935, #113916): For RPIT, we currently accept ReStatic as well.
365
+ // This is a back-compat hack, see the issue for more.
366
+ false => matches ! ( * lt, ty:: ReEarlyBound ( _) | ty:: ReFree ( _) | ty:: ReStatic ) ,
367
+ } ,
369
368
GenericArgKind :: Const ( ct) => matches ! ( ct. kind( ) , ty:: ConstKind :: Param ( _) ) ,
370
369
} ;
371
370
372
371
if arg_is_param {
373
- seen_params. entry ( arg) . or_default ( ) . push ( i) ;
372
+ // FIXME(#113916): For RPIT, we can't currently check for unique lifetime
373
+ // params, see that issue for more. We limit this to TAIT for now.
374
+ if is_ty_alias {
375
+ seen_params. entry ( arg) . or_default ( ) . push ( i) ;
376
+ }
374
377
} else {
375
378
// Prevent `fn foo() -> Foo<u32>` from being defining.
376
379
let opaque_param = opaque_generics. param_at ( i, tcx) ;
0 commit comments