1
Fork 0

don't ICE when emitting linker errors during -Z link-only

note that this still ICEs when passed `-Z link-only --error-format json` because i can't be bothered to fix it right now
This commit is contained in:
jyn 2024-12-21 10:06:07 -05:00
parent cedd4cad21
commit b757663a00
5 changed files with 67 additions and 22 deletions

View file

@ -895,13 +895,16 @@ fn default_emitter(
}
t => t,
};
let source_map = if sopts.unstable_opts.link_only { None } else { Some(source_map) };
match sopts.error_format {
config::ErrorOutputType::HumanReadable(kind, color_config) => {
let short = kind.short();
if let HumanReadableErrorType::AnnotateSnippet = kind {
let emitter = AnnotateSnippetEmitter::new(
Some(source_map),
source_map,
bundle,
fallback_bundle,
short,
@ -911,7 +914,7 @@ fn default_emitter(
} else {
let emitter = HumanEmitter::new(stderr_destination(color_config), fallback_bundle)
.fluent_bundle(bundle)
.sm(Some(source_map))
.sm(source_map)
.short_message(short)
.teach(sopts.unstable_opts.teach)
.diagnostic_width(sopts.diagnostic_width)
@ -1442,7 +1445,7 @@ fn mk_emitter(output: ErrorOutputType) -> Box<DynEmitter> {
config::ErrorOutputType::Json { pretty, json_rendered, color_config } => {
Box::new(JsonEmitter::new(
Box::new(io::BufWriter::new(io::stderr())),
Lrc::new(SourceMap::new(FilePathMapping::empty())),
Some(Lrc::new(SourceMap::new(FilePathMapping::empty()))),
fallback_bundle,
pretty,
json_rendered,