diff options
| author | bors <bors@rust-lang.org> | 2016-01-29 17:52:26 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-01-29 17:52:26 +0000 |
| commit | 0f196bcc3b23925854e3d758c03f56c7520e9b99 (patch) | |
| tree | b7aa4a100573c012dec49dc08b1a9e285fede44e /src/libsyntax/diagnostics/plugin.rs | |
| parent | 61441cb12489faca4ee84f219b5ff9316befcb6c (diff) | |
| parent | a7f1d12ae4e0adbabc4c371d9959e4adeb4d75dd (diff) | |
| download | rust-0f196bcc3b23925854e3d758c03f56c7520e9b99.tar.gz rust-0f196bcc3b23925854e3d758c03f56c7520e9b99.zip | |
Auto merge of #31248 - ruud-v-a:fix-triple-ice, r=nrc
This fixes #31238. r? @michaelsproul
Diffstat (limited to 'src/libsyntax/diagnostics/plugin.rs')
| -rw-r--r-- | src/libsyntax/diagnostics/plugin.rs | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/libsyntax/diagnostics/plugin.rs b/src/libsyntax/diagnostics/plugin.rs index d17ca3892dc..6e389e83591 100644 --- a/src/libsyntax/diagnostics/plugin.rs +++ b/src/libsyntax/diagnostics/plugin.rs @@ -168,20 +168,24 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt, }; // Output error metadata to `tmp/extended-errors/<target arch>/<crate name>.json` - let target_triple = env::var("CFG_COMPILER_HOST_TRIPLE") - .ok().expect("unable to determine target arch from $CFG_COMPILER_HOST_TRIPLE"); - - with_registered_diagnostics(|diagnostics| { - if let Err(e) = output_metadata(ecx, - &target_triple, - &crate_name.name.as_str(), - &diagnostics) { - ecx.span_bug(span, &format!( - "error writing metadata for triple `{}` and crate `{}`, error: {}, cause: {:?}", - target_triple, crate_name, e.description(), e.cause() - )); - } - }); + if let Ok(target_triple) = env::var("CFG_COMPILER_HOST_TRIPLE") { + with_registered_diagnostics(|diagnostics| { + if let Err(e) = output_metadata(ecx, + &target_triple, + &crate_name.name.as_str(), + &diagnostics) { + ecx.span_bug(span, &format!( + "error writing metadata for triple `{}` and crate `{}`, error: {}, \ + cause: {:?}", + target_triple, crate_name, e.description(), e.cause() + )); + } + }); + } else { + ecx.span_err(span, &format!( + "failed to write metadata for crate `{}` because $CFG_COMPILER_HOST_TRIPLE is not set", + crate_name)); + } // Construct the output expression. let (count, expr) = |
