diff options
| author | jyn <github@jyn.dev> | 2024-12-21 10:06:07 -0500 |
|---|---|---|
| committer | jyn <github@jyn.dev> | 2025-01-20 16:46:45 -0500 |
| commit | b757663a00260e22799a1bbdc5d6ba603e4bb30d (patch) | |
| tree | 4a78b3924fb7f6bfd37ef6cf9e2b19e8082f0eb0 /compiler/rustc_session/src | |
| parent | cedd4cad21298ca8b825ab3c56a84753176dc8e8 (diff) | |
| download | rust-b757663a00260e22799a1bbdc5d6ba603e4bb30d.tar.gz rust-b757663a00260e22799a1bbdc5d6ba603e4bb30d.zip | |
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
Diffstat (limited to 'compiler/rustc_session/src')
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 60f1154dc6d..022c2aa880e 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -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, |
