@@ -48,7 +48,7 @@ enum SelfSemantic {
4848}
4949
5050enum TraitOrTraitImpl {
51- Trait { span : Span , constness : Const } ,
51+ Trait { vis : Span , constness : Const } ,
5252 TraitImpl { constness : Const , polarity : ImplPolarity , trait_ref_span : Span } ,
5353}
5454
@@ -109,10 +109,10 @@ impl<'a> AstValidator<'a> {
109109 self . outer_trait_or_trait_impl = old;
110110 }
111111
112- fn with_in_trait ( & mut self , span : Span , constness : Const , f : impl FnOnce ( & mut Self ) ) {
112+ fn with_in_trait ( & mut self , vis : Span , constness : Const , f : impl FnOnce ( & mut Self ) ) {
113113 let old = mem:: replace (
114114 & mut self . outer_trait_or_trait_impl ,
115- Some ( TraitOrTraitImpl :: Trait { span , constness } ) ,
115+ Some ( TraitOrTraitImpl :: Trait { vis , constness } ) ,
116116 ) ;
117117 f ( self ) ;
118118 self . outer_trait_or_trait_impl = old;
@@ -265,10 +265,12 @@ impl<'a> AstValidator<'a> {
265265 None
266266 } ;
267267
268+ let map = self . sess . source_map ( ) ;
269+
268270 let make_trait_const_sugg = if const_trait_impl
269- && let TraitOrTraitImpl :: Trait { span , constness : ast:: Const :: No } = parent
271+ && let & TraitOrTraitImpl :: Trait { vis , constness : ast:: Const :: No } = parent
270272 {
271- Some ( span . shrink_to_lo ( ) )
273+ Some ( map . span_extend_while_whitespace ( vis ) . shrink_to_hi ( ) )
272274 } else {
273275 None
274276 } ;
@@ -279,7 +281,7 @@ impl<'a> AstValidator<'a> {
279281 in_impl : matches ! ( parent, TraitOrTraitImpl :: TraitImpl { .. } ) ,
280282 const_context_label : parent_constness,
281283 remove_const_sugg : (
282- self . sess . source_map ( ) . span_extend_while_whitespace ( span) ,
284+ map . span_extend_while_whitespace ( span) ,
283285 match parent_constness {
284286 Some ( _) => rustc_errors:: Applicability :: MachineApplicable ,
285287 None => rustc_errors:: Applicability :: MaybeIncorrect ,
@@ -1165,13 +1167,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
11651167 ..
11661168 } ) => {
11671169 self . visit_attrs_vis_ident ( & item. attrs , & item. vis , ident) ;
1168- // FIXME(const_trait_impl) remove this
1169- let alt_const_trait_span =
1170- attr:: find_by_name ( & item. attrs , sym:: const_trait) . map ( |attr| attr. span ) ;
1171- let constness = match ( * constness, alt_const_trait_span) {
1172- ( Const :: Yes ( span) , _) | ( Const :: No , Some ( span) ) => Const :: Yes ( span) ,
1173- ( Const :: No , None ) => Const :: No ,
1174- } ;
11751170 if * is_auto == IsAuto :: Yes {
11761171 // Auto traits cannot have generics, super traits nor contain items.
11771172 self . deny_generic_params ( generics, ident. span ) ;
@@ -1188,7 +1183,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
11881183 this. visit_generics ( generics) ;
11891184 walk_list ! ( this, visit_param_bound, bounds, BoundKind :: SuperTraits )
11901185 } ) ;
1191- self . with_in_trait ( item. span , constness, |this| {
1186+ self . with_in_trait ( item. vis . span , * constness, |this| {
11921187 walk_list ! ( this, visit_assoc_item, items, AssocCtxt :: Trait ) ;
11931188 } ) ;
11941189 }
0 commit comments