@@ -12,7 +12,7 @@ use rustc_errors::{
1212use rustc_hir:: { self as hir, ExprKind , Target } ;
1313use rustc_macros:: { Diagnostic , LintDiagnostic , Subdiagnostic } ;
1414use rustc_middle:: ty:: { MainDefinition , Ty } ;
15- use rustc_span:: { BytePos , Span , Symbol , DUMMY_SP } ;
15+ use rustc_span:: { Span , Symbol , DUMMY_SP } ;
1616
1717use crate :: check_attr:: ProcMacroKind ;
1818use crate :: lang_items:: Duplicate ;
@@ -849,7 +849,7 @@ pub struct UnknownLangItem {
849849
850850pub struct InvalidAttrAtCrateLevel {
851851 pub span : Span ,
852- pub snippet : Option < String > ,
852+ pub sugg_span : Option < Span > ,
853853 pub name : Symbol ,
854854 pub item : Option < ItemFollowingInnerAttr > ,
855855}
@@ -871,9 +871,9 @@ impl IntoDiagnostic<'_> for InvalidAttrAtCrateLevel {
871871 diag. set_arg ( "name" , self . name ) ;
872872 // Only emit an error with a suggestion if we can create a string out
873873 // of the attribute span
874- if let Some ( src ) = self . snippet && src . starts_with ( "#![" ) {
874+ if let Some ( span ) = self . sugg_span {
875875 diag. span_suggestion_verbose (
876- self . span . with_lo ( self . span . lo ( ) + BytePos ( 1 ) ) . with_hi ( self . span . lo ( ) + BytePos ( 2 ) ) ,
876+ span,
877877 fluent:: passes_suggestion,
878878 String :: new ( ) ,
879879 rustc_errors:: Applicability :: MachineApplicable ,
0 commit comments