Skip to content

Commit 5b91fe5

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

File tree

1 file changed

+4
-2
lines changed
  • compiler/rustc_errors/src

1 file changed

+4
-2
lines changed

compiler/rustc_errors/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub use rustc_span::fatal_error::{FatalError, FatalErrorMarker};
7575
use rustc_span::source_map::SourceMap;
7676
use rustc_span::{BytePos, DUMMY_SP, Loc, Span};
7777
pub use snippet::Style;
78-
use tracing::{debug, instrument};
78+
use tracing::debug;
7979

8080
use crate::emitter::TimingEvent;
8181
use crate::registry::Registry;
@@ -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)