use std::cell::RefCell;
use std::collections::BTreeMap;
+use std::env;
use ast;
use ast::{Ident, Name, TokenTree};
use ptr::P;
use util::small_vector::SmallVector;
+use diagnostics::metadata::output_metadata;
+
// Maximum width of any line in an extended error description (inclusive).
const MAX_DESCRIPTION_WIDTH: usize = 80;
token_tree: &[TokenTree])
-> Box<MacResult+'cx> {
assert_eq!(token_tree.len(), 3);
- let (_crate_name, name) = match (&token_tree[0], &token_tree[2]) {
+ let (crate_name, name) = match (&token_tree[0], &token_tree[2]) {
(
// Crate name.
&ast::TtToken(_, token::Ident(ref crate_name, _)),
_ => unreachable!()
};
- // FIXME (#25705): we used to ensure error code uniqueness and
- // output error description JSON metadata here, but the approach
- // employed was too brittle.
+ // 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, &diagnostics) {
+ ecx.span_bug(span, &format!(
+ "error writing metadata for triple `{}` and crate `{}`, error: {}, cause: {:?}",
+ target_triple, crate_name, e.description(), e.cause()
+ ));
+ }
+ });
// Construct the output expression.
let (count, expr) =