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