diagnostics: Resurrect the Compiler Error Index.
This commit is contained in:
parent
2f5683913c
commit
634fced396
5 changed files with 54 additions and 93 deletions
|
@ -10,6 +10,7 @@
|
|||
|
||||
use std::cell::RefCell;
|
||||
use std::collections::BTreeMap;
|
||||
use std::env;
|
||||
|
||||
use ast;
|
||||
use ast::{Ident, Name, TokenTree};
|
||||
|
@ -20,6 +21,8 @@ use parse::token;
|
|||
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;
|
||||
|
||||
|
@ -154,7 +157,7 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
|
|||
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, _)),
|
||||
|
@ -164,9 +167,18 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
|
|||
_ => 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) =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue