@@ -75,7 +75,7 @@ pub use rustc_span::fatal_error::{FatalError, FatalErrorMarker};
7575use rustc_span:: source_map:: SourceMap ;
7676use rustc_span:: { BytePos , DUMMY_SP , Loc , Span } ;
7777pub use snippet:: Style ;
78- use tracing:: { debug, instrument } ;
78+ use tracing:: debug;
7979
8080use crate :: emitter:: TimingEvent ;
8181use crate :: registry:: Registry ;
@@ -245,7 +245,6 @@ pub(crate) struct SubstitutionHighlight {
245245impl SubstitutionPart {
246246 /// Try to turn a replacement into an addition when the span that is being
247247 /// overwritten matches either the prefix or suffix of the replacement.
248- #[ instrument( level = "debug" , skip( self , sm) ) ]
249248 fn trim_trivial_replacements ( self , sm : & SourceMap ) -> TrimmedSubstitutionPart {
250249 let mut trimmed_part = TrimmedSubstitutionPart {
251250 original_span : self . span ,
@@ -307,6 +306,9 @@ impl TrimmedSubstitutionPart {
307306/// `BB` is. Return the length of the prefix, the "trimmed" suggestion, and the length
308307/// of the suffix.
309308fn as_substr < ' a > ( original : & ' a str , suggestion : & ' a str ) -> Option < ( usize , & ' a str , usize ) > {
309+ // Case for import paths where the suggestion shares a prefix with the original.
310+ // Without this, suggesting `std::sync` for `sync` would incorrectly highlight `td::s`
311+ // instead of `std::` because of the common 's' prefix. See #148070.
310312 if suggestion. contains ( "::" )
311313 && suggestion. ends_with ( original)
312314 && suggestion. len ( ) > original. len ( )
0 commit comments