Skip to content

Commit 723d1df

Browse files
committed
Provide more info when encountering error during error code metadata output.
1 parent 8189864 commit 723d1df

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/libsyntax/diagnostics/plugin.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use std::cell::RefCell;
1212
use std::collections::BTreeMap;
13+
use std::error::Error;
1314

1415
use ast;
1516
use ast::{Ident, Name, TokenTree};
@@ -163,7 +164,17 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
163164
// FIXME (25364, 25592): used to ensure error code uniqueness
164165
// here, but the approach employed was too brittle. Need to
165166
// put such a check back in (e.g. in `make tidy`).
166-
output_metadata(&*ecx, crate_name, &*diagnostics).ok().expect("metadata output error");
167+
match output_metadata(&*ecx, crate_name, &*diagnostics) {
168+
Ok(()) => {}
169+
Err(error) => {
170+
ecx.span_err(span, &format!("metadata output error {}", error.description()));
171+
let mut error: &Error = &*error;
172+
while let Some(cause) = error.cause() {
173+
error = cause;
174+
ecx.span_err(span, &format!("caused by error {}", error.description()));
175+
}
176+
}
177+
}
167178
});
168179

169180
// Construct the output expression.

0 commit comments

Comments
 (0)