@@ -856,8 +856,15 @@ pub struct UnknownLangItem {
856856
857857pub struct InvalidAttrAtCrateLevel {
858858 pub span : Span ,
859- pub snippet : Option < String > ,
859+ pub sugg_span : Option < Span > ,
860860 pub name : Symbol ,
861+ pub item : Option < ItemFollowingInnerAttr > ,
862+ }
863+
864+ #[ derive( Clone , Copy ) ]
865+ pub struct ItemFollowingInnerAttr {
866+ pub span : Span ,
867+ pub kind : & ' static str ,
861868}
862869
863870impl IntoDiagnostic < ' _ > for InvalidAttrAtCrateLevel {
@@ -871,15 +878,18 @@ impl IntoDiagnostic<'_> for InvalidAttrAtCrateLevel {
871878 diag. set_arg ( "name" , self . name ) ;
872879 // Only emit an error with a suggestion if we can create a string out
873880 // of the attribute span
874- if let Some ( src) = self . snippet {
875- let replacement = src. replace ( "#!" , "#" ) ;
881+ if let Some ( span) = self . sugg_span {
876882 diag. span_suggestion_verbose (
877- self . span ,
883+ span,
878884 fluent:: passes_suggestion,
879- replacement ,
885+ String :: new ( ) ,
880886 rustc_errors:: Applicability :: MachineApplicable ,
881887 ) ;
882888 }
889+ if let Some ( item) = self . item {
890+ diag. set_arg ( "kind" , item. kind ) ;
891+ diag. span_label ( item. span , fluent:: passes_invalid_attr_at_crate_level_item) ;
892+ }
883893 diag
884894 }
885895}
0 commit comments