@@ -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 ,
@@ -1876,7 +1876,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
18761876 self . record_lifetime_res ( lifetime. id , res, elision_candidate) ;
18771877 return ;
18781878 }
1879- LifetimeRibKind :: StaticIfNoLifetimeInScope { lint_id : node_id , emit_lint } => {
1879+ LifetimeRibKind :: StaticIfNoLifetimeInScope { emit_lint } => {
18801880 let mut lifetimes_in_scope = vec ! [ ] ;
18811881 for rib in self . lifetime_ribs [ ..i] . iter ( ) . rev ( ) {
18821882 lifetimes_in_scope. extend ( rib. bindings . iter ( ) . map ( |( ident, _) | ident. span ) ) ;
@@ -1898,24 +1898,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
18981898 ) ;
18991899 return ;
19001900 } else if emit_lint {
1901- let lt_span = if elided {
1902- lifetime. ident . span . shrink_to_hi ( )
1903- } else {
1904- lifetime. ident . span
1905- } ;
1906- let code = if elided { "'static " } else { "'static" } ;
1907-
1908- self . r . lint_buffer . buffer_lint (
1909- lint:: builtin:: ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT ,
1910- node_id,
1911- lifetime. ident . span ,
1912- crate :: errors:: AssociatedConstElidedLifetime {
1913- elided,
1914- code,
1915- span : lt_span,
1916- lifetimes_in_scope : lifetimes_in_scope. into ( ) ,
1917- } ,
1918- ) ;
1901+ break ;
19191902 }
19201903 }
19211904 LifetimeRibKind :: AnonymousReportError => {
@@ -3356,10 +3339,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
33563339 generics. span ,
33573340 |this| {
33583341 this. with_lifetime_rib (
3359- LifetimeRibKind :: StaticIfNoLifetimeInScope {
3360- lint_id : item. id ,
3361- emit_lint : false ,
3362- } ,
3342+ LifetimeRibKind :: StaticIfNoLifetimeInScope { emit_lint : false } ,
33633343 |this| {
33643344 this. visit_generics ( generics) ;
33653345 if rhs_kind. is_type_const ( )
@@ -3576,66 +3556,46 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
35763556 generics. span ,
35773557 |this| {
35783558 this. with_lifetime_rib (
3579- // Until these are a hard error, we need to create them within the
3580- // correct binder, Otherwise the lifetimes of this assoc const think
3581- // they are lifetimes of the trait.
3582- LifetimeRibKind :: AnonymousCreateParameter {
3583- binder : item. id ,
3584- report_in_path : true ,
3559+ LifetimeRibKind :: StaticIfNoLifetimeInScope {
3560+ // In impls, it's not a hard error yet due to backcompat.
3561+ emit_lint : true ,
35853562 } ,
35863563 |this| {
3587- this. with_lifetime_rib (
3588- LifetimeRibKind :: StaticIfNoLifetimeInScope {
3589- lint_id : item. id ,
3590- // In impls, it's not a hard error yet due to backcompat.
3591- emit_lint : true ,
3592- } ,
3593- |this| {
3594- // If this is a trait impl, ensure the const
3595- // exists in trait
3596- this. check_trait_item (
3597- item. id ,
3598- * ident,
3599- & item. kind ,
3600- ValueNS ,
3601- item. span ,
3602- seen_trait_items,
3603- |i, s, c| ConstNotMemberOfTrait ( i, s, c) ,
3604- ) ;
3564+ // If this is a trait impl, ensure the const
3565+ // exists in trait
3566+ this. check_trait_item (
3567+ item. id ,
3568+ * ident,
3569+ & item. kind ,
3570+ ValueNS ,
3571+ item. span ,
3572+ seen_trait_items,
3573+ |i, s, c| ConstNotMemberOfTrait ( i, s, c) ,
3574+ ) ;
36053575
3606- this. visit_generics ( generics) ;
3607- if rhs_kind. is_type_const ( )
3608- && !this
3609- . r
3610- . tcx
3611- . features ( )
3612- . generic_const_parameter_types ( )
3613- {
3614- this. with_rib ( TypeNS , RibKind :: ConstParamTy , |this| {
3615- this. with_rib (
3616- ValueNS ,
3617- RibKind :: ConstParamTy ,
3618- |this| {
3619- this. with_lifetime_rib (
3620- LifetimeRibKind :: ConstParamTy ,
3621- |this| this. visit_ty ( ty) ,
3622- )
3623- } ,
3624- )
3625- } ) ;
3626- } else {
3627- this. visit_ty ( ty) ;
3628- }
3629- // We allow arbitrary const expressions inside of associated consts,
3630- // even if they are potentially not const evaluatable.
3631- //
3632- // Type parameters can already be used and as associated consts are
3633- // not used as part of the type system, this is far less surprising.
3634- this. resolve_const_item_rhs ( rhs_kind, None ) ;
3635- } ,
3636- )
3576+ this. visit_generics ( generics) ;
3577+ if rhs_kind. is_type_const ( )
3578+ && !this. r . tcx . features ( ) . generic_const_parameter_types ( )
3579+ {
3580+ this. with_rib ( TypeNS , RibKind :: ConstParamTy , |this| {
3581+ this. with_rib ( ValueNS , RibKind :: ConstParamTy , |this| {
3582+ this. with_lifetime_rib (
3583+ LifetimeRibKind :: ConstParamTy ,
3584+ |this| this. visit_ty ( ty) ,
3585+ )
3586+ } )
3587+ } ) ;
3588+ } else {
3589+ this. visit_ty ( ty) ;
3590+ }
3591+ // We allow arbitrary const expressions inside of associated consts,
3592+ // even if they are potentially not const evaluatable.
3593+ //
3594+ // Type parameters can already be used and as associated consts are
3595+ // not used as part of the type system, this is far less surprising.
3596+ this. resolve_const_item_rhs ( rhs_kind, None ) ;
36373597 } ,
3638- ) ;
3598+ )
36393599 } ,
36403600 ) ;
36413601 self . resolve_define_opaques ( define_opaque) ;
0 commit comments