Skip to content
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1996,6 +1996,14 @@ impl HumanEmitter {
return Ok(());
};

if suggestion
.substitutions
.iter()
.any(|s| s.parts.iter().any(|p| is_external_library(sm, p.span)))
{
return Ok(());
}

// Render the replacements for each suggestion
let suggestions = suggestion.splice_lines(sm);
debug!(?suggestions);
Expand Down Expand Up @@ -3532,3 +3540,13 @@ pub(crate) fn should_show_source_code(
.map(|path| ignored_directories.iter().all(|dir| !path.starts_with(dir)))
.unwrap_or(true)
}

fn is_external_library(sm: &SourceMap, span: Span) -> bool {
let filename = sm.span_to_filename(span);
if let Some(path) = filename.into_local_path() {
path.to_string_lossy().contains(".cargo/registry/src/")
|| path.to_string_lossy().contains(".rustup/toolchains/")
} else {
false
}
}
Loading