Skip to content

Commit d863547

Browse files
committed
Remove debug instrument and added comment explaning the special case
1 parent 052b702 commit d863547

File tree

1 file changed

+3
-1
lines changed
  • compiler/rustc_errors/src

1 file changed

+3
-1
lines changed

compiler/rustc_errors/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ pub(crate) struct SubstitutionHighlight {
245245
impl 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.
309308
fn 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

Comments
 (0)