@@ -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 => {
@@ -3351,10 +3334,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
33513334 generics. span ,
33523335 |this| {
33533336 this. with_lifetime_rib (
3354- LifetimeRibKind :: StaticIfNoLifetimeInScope {
3355- lint_id : item. id ,
3356- emit_lint : false ,
3357- } ,
3337+ LifetimeRibKind :: StaticIfNoLifetimeInScope { emit_lint : false } ,
33583338 |this| {
33593339 this. visit_generics ( generics) ;
33603340 if rhs_kind. is_type_const ( )
@@ -3571,66 +3551,46 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
35713551 generics. span ,
35723552 |this| {
35733553 this. with_lifetime_rib (
3574- // Until these are a hard error, we need to create them within the
3575- // correct binder, Otherwise the lifetimes of this assoc const think
3576- // they are lifetimes of the trait.
3577- LifetimeRibKind :: AnonymousCreateParameter {
3578- binder : item. id ,
3579- report_in_path : true ,
3554+ LifetimeRibKind :: StaticIfNoLifetimeInScope {
3555+ // In impls, it's not a hard error yet due to backcompat.
3556+ emit_lint : true ,
35803557 } ,
35813558 |this| {
3582- this. with_lifetime_rib (
3583- LifetimeRibKind :: StaticIfNoLifetimeInScope {
3584- lint_id : item. id ,
3585- // In impls, it's not a hard error yet due to backcompat.
3586- emit_lint : true ,
3587- } ,
3588- |this| {
3589- // If this is a trait impl, ensure the const
3590- // exists in trait
3591- this. check_trait_item (
3592- item. id ,
3593- * ident,
3594- & item. kind ,
3595- ValueNS ,
3596- item. span ,
3597- seen_trait_items,
3598- |i, s, c| ConstNotMemberOfTrait ( i, s, c) ,
3599- ) ;
3559+ // If this is a trait impl, ensure the const
3560+ // exists in trait
3561+ this. check_trait_item (
3562+ item. id ,
3563+ * ident,
3564+ & item. kind ,
3565+ ValueNS ,
3566+ item. span ,
3567+ seen_trait_items,
3568+ |i, s, c| ConstNotMemberOfTrait ( i, s, c) ,
3569+ ) ;
36003570
3601- this. visit_generics ( generics) ;
3602- if rhs_kind. is_type_const ( )
3603- && !this
3604- . r
3605- . tcx
3606- . features ( )
3607- . generic_const_parameter_types ( )
3608- {
3609- this. with_rib ( TypeNS , RibKind :: ConstParamTy , |this| {
3610- this. with_rib (
3611- ValueNS ,
3612- RibKind :: ConstParamTy ,
3613- |this| {
3614- this. with_lifetime_rib (
3615- LifetimeRibKind :: ConstParamTy ,
3616- |this| this. visit_ty ( ty) ,
3617- )
3618- } ,
3619- )
3620- } ) ;
3621- } else {
3622- this. visit_ty ( ty) ;
3623- }
3624- // We allow arbitrary const expressions inside of associated consts,
3625- // even if they are potentially not const evaluatable.
3626- //
3627- // Type parameters can already be used and as associated consts are
3628- // not used as part of the type system, this is far less surprising.
3629- this. resolve_const_item_rhs ( rhs_kind, None ) ;
3630- } ,
3631- )
3571+ this. visit_generics ( generics) ;
3572+ if rhs_kind. is_type_const ( )
3573+ && !this. r . tcx . features ( ) . generic_const_parameter_types ( )
3574+ {
3575+ this. with_rib ( TypeNS , RibKind :: ConstParamTy , |this| {
3576+ this. with_rib ( ValueNS , RibKind :: ConstParamTy , |this| {
3577+ this. with_lifetime_rib (
3578+ LifetimeRibKind :: ConstParamTy ,
3579+ |this| this. visit_ty ( ty) ,
3580+ )
3581+ } )
3582+ } ) ;
3583+ } else {
3584+ this. visit_ty ( ty) ;
3585+ }
3586+ // We allow arbitrary const expressions inside of associated consts,
3587+ // even if they are potentially not const evaluatable.
3588+ //
3589+ // Type parameters can already be used and as associated consts are
3590+ // not used as part of the type system, this is far less surprising.
3591+ this. resolve_const_item_rhs ( rhs_kind, None ) ;
36323592 } ,
3633- ) ;
3593+ )
36343594 } ,
36353595 ) ;
36363596 self . resolve_define_opaques ( define_opaque) ;
0 commit comments