@@ -820,40 +820,35 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
820
820
ref self_ty,
821
821
items : _,
822
822
} => {
823
- let error = |annotation_span, annotation, note , code | {
823
+ let error = |annotation_span, annotation| {
824
824
let mut err = self . err_handler ( ) . struct_span_err (
825
825
self_ty. span ,
826
826
& format ! ( "inherent impls cannot be {}" , annotation) ,
827
827
) ;
828
828
err. span_label ( annotation_span, & format ! ( "{} because of this" , annotation) ) ;
829
829
err. span_label ( self_ty. span , "inherent impl for this type" ) ;
830
- if note {
831
- err. note ( & format ! (
832
- "only trait implementations may be annotated with {}" ,
833
- annotation
834
- ) ) ;
835
- }
836
- if code {
837
- err. code ( error_code ! ( E0197 ) ) ;
838
- }
839
- err. emit ( ) ;
830
+ err
840
831
} ;
841
832
842
833
self . invalid_visibility (
843
834
& item. vis ,
844
835
Some ( "place qualifiers on individual impl items instead" ) ,
845
836
) ;
846
837
if let Unsafe :: Yes ( span) = unsafety {
847
- error ( span, "unsafe" , false , true )
838
+ error ( span, "unsafe" ) . code ( error_code ! ( E0197 ) ) . emit ( ) ;
848
839
}
849
840
if let ImplPolarity :: Negative ( span) = polarity {
850
- error ( span, "negative" , false , false ) ;
841
+ error ( span, "negative" ) . emit ( ) ;
851
842
}
852
843
if let Defaultness :: Default ( def_span) = defaultness {
853
- error ( def_span, "`default`" , true , false ) ;
844
+ error ( def_span, "`default`" )
845
+ . note ( "only trait implementations may be annotated with `default`" )
846
+ . emit ( ) ;
854
847
}
855
848
if let Const :: Yes ( span) = constness {
856
- error ( span, "`const`" , true , false ) ;
849
+ error ( span, "`const`" )
850
+ . note ( "only trait implementations may be annotated with `const`" )
851
+ . emit ( ) ;
857
852
}
858
853
}
859
854
ItemKind :: Fn ( def, ref sig, ref generics, ref body) => {
0 commit comments