@@ -345,7 +345,7 @@ enum LifetimeRibKind {
345345 /// Resolves elided lifetimes to `'static` if there are no other lifetimes in scope,
346346 /// otherwise give a warning that the previous behavior of introducing a new early-bound
347347 /// lifetime is a bug and will be removed (if `emit_lint` is enabled).
348- StaticIfNoLifetimeInScope { lint_id : NodeId , emit_lint : bool } ,
348+ StaticIfNoLifetimeInScope { emit_lint : bool } ,
349349
350350 /// Signal we cannot find which should be the anonymous lifetime.
351351 ElisionFailure ,
@@ -1883,7 +1883,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
18831883 self . record_lifetime_use ( lifetime. id , res, elision_candidate) ;
18841884 return ;
18851885 }
1886- LifetimeRibKind :: StaticIfNoLifetimeInScope { lint_id : node_id , emit_lint } => {
1886+ LifetimeRibKind :: StaticIfNoLifetimeInScope { emit_lint } => {
18871887 let mut lifetimes_in_scope = vec ! [ ] ;
18881888 for rib in self . lifetime_ribs [ ..i] . iter ( ) . rev ( ) {
18891889 lifetimes_in_scope. extend ( rib. bindings . iter ( ) . map ( |( ident, _) | ident. span ) ) ;
@@ -1905,24 +1905,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
19051905 ) ;
19061906 return ;
19071907 } else if emit_lint {
1908- let lt_span = if elided {
1909- lifetime. ident . span . shrink_to_hi ( )
1910- } else {
1911- lifetime. ident . span
1912- } ;
1913- let code = if elided { "'static " } else { "'static" } ;
1914-
1915- self . r . lint_buffer . buffer_lint (
1916- lint:: builtin:: ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT ,
1917- node_id,
1918- lifetime. ident . span ,
1919- crate :: errors:: AssociatedConstElidedLifetime {
1920- elided,
1921- code,
1922- span : lt_span,
1923- lifetimes_in_scope : lifetimes_in_scope. into ( ) ,
1924- } ,
1925- ) ;
1908+ break ;
19261909 }
19271910 }
19281911 LifetimeRibKind :: AnonymousReportError => {
@@ -3348,10 +3331,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
33483331 generics. span ,
33493332 |this| {
33503333 this. with_lifetime_rib (
3351- LifetimeRibKind :: StaticIfNoLifetimeInScope {
3352- lint_id : item. id ,
3353- emit_lint : false ,
3354- } ,
3334+ LifetimeRibKind :: StaticIfNoLifetimeInScope { emit_lint : false } ,
33553335 |this| {
33563336 this. visit_generics ( generics) ;
33573337 if rhs_kind. is_type_const ( )
@@ -3567,67 +3547,47 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
35673547 generics. span ,
35683548 |this| {
35693549 this. with_lifetime_rib (
3570- // Until these are a hard error, we need to create them within the
3571- // correct binder, Otherwise the lifetimes of this assoc const think
3572- // they are lifetimes of the trait.
3573- LifetimeRibKind :: AnonymousCreateParameter {
3574- binder : item. id ,
3575- report_in_path : true ,
3550+ LifetimeRibKind :: StaticIfNoLifetimeInScope {
3551+ // In impls, it's not a hard error yet due to backcompat.
3552+ emit_lint : true ,
35763553 } ,
35773554 |this| {
3578- this. with_lifetime_rib (
3579- LifetimeRibKind :: StaticIfNoLifetimeInScope {
3580- lint_id : item. id ,
3581- // In impls, it's not a hard error yet due to backcompat.
3582- emit_lint : true ,
3583- } ,
3584- |this| {
3585- // If this is a trait impl, ensure the const
3586- // exists in trait
3587- this. check_trait_item (
3588- item. id ,
3589- * ident,
3590- * ident,
3591- & item. kind ,
3592- ValueNS ,
3593- item. span ,
3594- seen_trait_items,
3595- |i, s, c| ConstNotMemberOfTrait ( i, s, c) ,
3596- ) ;
3555+ // If this is a trait impl, ensure the const
3556+ // exists in trait
3557+ this. check_trait_item (
3558+ item. id ,
3559+ * ident,
3560+ * ident,
3561+ & item. kind ,
3562+ ValueNS ,
3563+ item. span ,
3564+ seen_trait_items,
3565+ |i, s, c| ConstNotMemberOfTrait ( i, s, c) ,
3566+ ) ;
35973567
3598- this. visit_generics ( generics) ;
3599- if rhs_kind. is_type_const ( )
3600- && !this
3601- . r
3602- . tcx
3603- . features ( )
3604- . generic_const_parameter_types ( )
3605- {
3606- this. with_rib ( TypeNS , RibKind :: ConstParamTy , |this| {
3607- this. with_rib (
3608- ValueNS ,
3609- RibKind :: ConstParamTy ,
3610- |this| {
3611- this. with_lifetime_rib (
3612- LifetimeRibKind :: ConstParamTy ,
3613- |this| this. visit_ty ( ty) ,
3614- )
3615- } ,
3616- )
3617- } ) ;
3618- } else {
3619- this. visit_ty ( ty) ;
3620- }
3621- // We allow arbitrary const expressions inside of associated consts,
3622- // even if they are potentially not const evaluatable.
3623- //
3624- // Type parameters can already be used and as associated consts are
3625- // not used as part of the type system, this is far less surprising.
3626- this. resolve_const_item_rhs ( rhs_kind, None ) ;
3627- } ,
3628- )
3568+ this. visit_generics ( generics) ;
3569+ if rhs_kind. is_type_const ( )
3570+ && !this. r . tcx . features ( ) . generic_const_parameter_types ( )
3571+ {
3572+ this. with_rib ( TypeNS , RibKind :: ConstParamTy , |this| {
3573+ this. with_rib ( ValueNS , RibKind :: ConstParamTy , |this| {
3574+ this. with_lifetime_rib (
3575+ LifetimeRibKind :: ConstParamTy ,
3576+ |this| this. visit_ty ( ty) ,
3577+ )
3578+ } )
3579+ } ) ;
3580+ } else {
3581+ this. visit_ty ( ty) ;
3582+ }
3583+ // We allow arbitrary const expressions inside of associated consts,
3584+ // even if they are potentially not const evaluatable.
3585+ //
3586+ // Type parameters can already be used and as associated consts are
3587+ // not used as part of the type system, this is far less surprising.
3588+ this. resolve_const_item_rhs ( rhs_kind, None ) ;
36293589 } ,
3630- ) ;
3590+ )
36313591 } ,
36323592 ) ;
36333593 self . resolve_define_opaques ( define_opaque) ;
0 commit comments