@@ -3329,34 +3329,44 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
3329
3329
} ,
3330
3330
|this| {
3331
3331
this. with_lifetime_rib (
3332
- LifetimeRibKind :: StaticIfNoLifetimeInScope {
3333
- lint_id : item. id ,
3334
- // In impls, it's not a hard error yet due to backcompat.
3335
- emit_lint : true ,
3332
+ // Until these are a hard error, we need to create them within the correct binder,
3333
+ // Otherwise the lifetimes of this assoc const think they are lifetimes of the trait.
3334
+ LifetimeRibKind :: AnonymousCreateParameter {
3335
+ binder : item. id ,
3336
+ report_in_path : true ,
3336
3337
} ,
3337
3338
|this| {
3338
- // If this is a trait impl, ensure the const
3339
- // exists in trait
3340
- this. check_trait_item (
3341
- item. id ,
3342
- item. ident ,
3343
- & item. kind ,
3344
- ValueNS ,
3345
- item. span ,
3346
- seen_trait_items,
3347
- |i, s, c| ConstNotMemberOfTrait ( i, s, c) ,
3348
- ) ;
3339
+ this. with_lifetime_rib (
3340
+ LifetimeRibKind :: StaticIfNoLifetimeInScope {
3341
+ lint_id : item. id ,
3342
+ // In impls, it's not a hard error yet due to backcompat.
3343
+ emit_lint : true ,
3344
+ } ,
3345
+ |this| {
3346
+ // If this is a trait impl, ensure the const
3347
+ // exists in trait
3348
+ this. check_trait_item (
3349
+ item. id ,
3350
+ item. ident ,
3351
+ & item. kind ,
3352
+ ValueNS ,
3353
+ item. span ,
3354
+ seen_trait_items,
3355
+ |i, s, c| ConstNotMemberOfTrait ( i, s, c) ,
3356
+ ) ;
3349
3357
3350
- this. visit_generics ( generics) ;
3351
- this. visit_ty ( ty) ;
3352
- if let Some ( expr) = expr {
3353
- // We allow arbitrary const expressions inside of associated consts,
3354
- // even if they are potentially not const evaluatable.
3355
- //
3356
- // Type parameters can already be used and as associated consts are
3357
- // not used as part of the type system, this is far less surprising.
3358
- this. resolve_const_body ( expr, None ) ;
3359
- }
3358
+ this. visit_generics ( generics) ;
3359
+ this. visit_ty ( ty) ;
3360
+ if let Some ( expr) = expr {
3361
+ // We allow arbitrary const expressions inside of associated consts,
3362
+ // even if they are potentially not const evaluatable.
3363
+ //
3364
+ // Type parameters can already be used and as associated consts are
3365
+ // not used as part of the type system, this is far less surprising.
3366
+ this. resolve_const_body ( expr, None ) ;
3367
+ }
3368
+ } ,
3369
+ )
3360
3370
} ,
3361
3371
) ;
3362
3372
} ,
0 commit comments