@@ -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;
78+ use tracing:: { debug, instrument } ;
7979
8080use crate :: emitter:: TimingEvent ;
8181use crate :: registry:: Registry ;
@@ -245,6 +245,7 @@ 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) ) ]
248249 fn trim_trivial_replacements ( self , sm : & SourceMap ) -> TrimmedSubstitutionPart {
249250 let mut trimmed_part = TrimmedSubstitutionPart {
250251 original_span : self . span ,
@@ -306,6 +307,16 @@ impl TrimmedSubstitutionPart {
306307/// `BB` is. Return the length of the prefix, the "trimmed" suggestion, and the length
307308/// of the suffix.
308309fn as_substr < ' a > ( original : & ' a str , suggestion : & ' a str ) -> Option < ( usize , & ' a str , usize ) > {
310+ if suggestion. contains ( "::" )
311+ && suggestion. ends_with ( original)
312+ && suggestion. len ( ) > original. len ( )
313+ {
314+ let prefix = & suggestion[ ..suggestion. len ( ) - original. len ( ) ] ;
315+ if prefix. ends_with ( "::" ) && suggestion. chars ( ) . next ( ) == original. chars ( ) . next ( ) {
316+ return Some ( ( 0 , prefix, original. len ( ) ) ) ;
317+ }
318+ }
319+
309320 let common_prefix = original
310321 . chars ( )
311322 . zip ( suggestion. chars ( ) )
0 commit comments