@@ -41,6 +41,7 @@ enum DisallowTildeConstContext<'a> {
41
41
TraitObject ,
42
42
Fn ( FnKind < ' a > ) ,
43
43
Trait ( Span ) ,
44
+ TraitImpl ( Span ) ,
44
45
Impl ( Span ) ,
45
46
Item ,
46
47
}
@@ -837,7 +838,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
837
838
this. visit_vis ( & item. vis ) ;
838
839
this. visit_ident ( item. ident ) ;
839
840
let disallowed = matches ! ( constness, Const :: No )
840
- . then ( || DisallowTildeConstContext :: Impl ( item. span ) ) ;
841
+ . then ( || DisallowTildeConstContext :: TraitImpl ( item. span ) ) ;
841
842
this. with_tilde_const ( disallowed, |this| this. visit_generics ( generics) ) ;
842
843
this. visit_trait_ref ( t) ;
843
844
this. visit_ty ( self_ty) ;
@@ -890,7 +891,9 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
890
891
891
892
self . visit_vis ( & item. vis ) ;
892
893
self . visit_ident ( item. ident ) ;
893
- self . with_tilde_const ( None , |this| this. visit_generics ( generics) ) ;
894
+ self . with_tilde_const ( Some ( DisallowTildeConstContext :: Impl ( item. span ) ) , |this| {
895
+ this. visit_generics ( generics)
896
+ } ) ;
894
897
self . visit_ty ( self_ty) ;
895
898
walk_list ! ( self , visit_assoc_item, items, AssocCtxt :: Impl ) ;
896
899
walk_list ! ( self , visit_attribute, & item. attrs) ;
@@ -1216,7 +1219,12 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1216
1219
& DisallowTildeConstContext :: Trait ( span) => {
1217
1220
errors:: TildeConstReason :: Trait { span }
1218
1221
}
1222
+ & DisallowTildeConstContext :: TraitImpl ( span) => {
1223
+ errors:: TildeConstReason :: TraitImpl { span }
1224
+ }
1219
1225
& DisallowTildeConstContext :: Impl ( span) => {
1226
+ // FIXME(effects): Consider providing a help message or even a structured
1227
+ // suggestion for moving such bounds to the assoc const fns if available.
1220
1228
errors:: TildeConstReason :: Impl { span }
1221
1229
}
1222
1230
DisallowTildeConstContext :: TraitObject => {
0 commit comments