@@ -12,7 +12,7 @@ use rustc_errors::{
12
12
use rustc_hir:: { self as hir, ExprKind , Target } ;
13
13
use rustc_macros:: { Diagnostic , LintDiagnostic , Subdiagnostic } ;
14
14
use rustc_middle:: ty:: { MainDefinition , Ty } ;
15
- use rustc_span:: { BytePos , Span , Symbol , DUMMY_SP } ;
15
+ use rustc_span:: { Span , Symbol , DUMMY_SP } ;
16
16
17
17
use crate :: check_attr:: ProcMacroKind ;
18
18
use crate :: lang_items:: Duplicate ;
@@ -849,7 +849,7 @@ pub struct UnknownLangItem {
849
849
850
850
pub struct InvalidAttrAtCrateLevel {
851
851
pub span : Span ,
852
- pub snippet : Option < String > ,
852
+ pub sugg_span : Option < Span > ,
853
853
pub name : Symbol ,
854
854
pub item : Option < ItemFollowingInnerAttr > ,
855
855
}
@@ -871,9 +871,9 @@ impl IntoDiagnostic<'_> for InvalidAttrAtCrateLevel {
871
871
diag. set_arg ( "name" , self . name ) ;
872
872
// Only emit an error with a suggestion if we can create a string out
873
873
// of the attribute span
874
- if let Some ( src ) = self . snippet && src . starts_with ( "#![" ) {
874
+ if let Some ( span ) = self . sugg_span {
875
875
diag. span_suggestion_verbose (
876
- self . span . with_lo ( self . span . lo ( ) + BytePos ( 1 ) ) . with_hi ( self . span . lo ( ) + BytePos ( 2 ) ) ,
876
+ span,
877
877
fluent:: passes_suggestion,
878
878
String :: new ( ) ,
879
879
rustc_errors:: Applicability :: MachineApplicable ,
0 commit comments