Skip to content

Commit 0f196bc

Browse files
committed
Auto merge of rust-lang#31248 - ruud-v-a:fix-triple-ice, r=nrc
This fixes rust-lang#31238. r? @michaelsproul
2 parents 61441cb + a7f1d12 commit 0f196bc

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/libsyntax/diagnostics/plugin.rs

+18-14
Original file line numberDiff line numberDiff line change
@@ -168,20 +168,24 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
168168
};
169169

170170
// Output error metadata to `tmp/extended-errors/<target arch>/<crate name>.json`
171-
let target_triple = env::var("CFG_COMPILER_HOST_TRIPLE")
172-
.ok().expect("unable to determine target arch from $CFG_COMPILER_HOST_TRIPLE");
173-
174-
with_registered_diagnostics(|diagnostics| {
175-
if let Err(e) = output_metadata(ecx,
176-
&target_triple,
177-
&crate_name.name.as_str(),
178-
&diagnostics) {
179-
ecx.span_bug(span, &format!(
180-
"error writing metadata for triple `{}` and crate `{}`, error: {}, cause: {:?}",
181-
target_triple, crate_name, e.description(), e.cause()
182-
));
183-
}
184-
});
171+
if let Ok(target_triple) = env::var("CFG_COMPILER_HOST_TRIPLE") {
172+
with_registered_diagnostics(|diagnostics| {
173+
if let Err(e) = output_metadata(ecx,
174+
&target_triple,
175+
&crate_name.name.as_str(),
176+
&diagnostics) {
177+
ecx.span_bug(span, &format!(
178+
"error writing metadata for triple `{}` and crate `{}`, error: {}, \
179+
cause: {:?}",
180+
target_triple, crate_name, e.description(), e.cause()
181+
));
182+
}
183+
});
184+
} else {
185+
ecx.span_err(span, &format!(
186+
"failed to write metadata for crate `{}` because $CFG_COMPILER_HOST_TRIPLE is not set",
187+
crate_name));
188+
}
185189

186190
// Construct the output expression.
187191
let (count, expr) =

0 commit comments

Comments
 (0)