Fix proc_macro output with struct parse error
This commit is contained in:
parent
0e241d0059
commit
cf9283ea93
@ -96,12 +96,18 @@ impl MultiItemModifier for ProcMacroDerive {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let error_count_before = ecx.parse_sess.span_diagnostic.err_count();
|
||||||
__internal::set_sess(ecx, || {
|
__internal::set_sess(ecx, || {
|
||||||
|
let msg = "proc-macro derive produced unparseable tokens";
|
||||||
match __internal::token_stream_parse_items(stream) {
|
match __internal::token_stream_parse_items(stream) {
|
||||||
|
// fail if there have been errors emitted
|
||||||
|
Ok(_) if ecx.parse_sess.span_diagnostic.err_count() > error_count_before => {
|
||||||
|
ecx.struct_span_fatal(span, msg).emit();
|
||||||
|
panic!(FatalError);
|
||||||
|
}
|
||||||
Ok(new_items) => new_items.into_iter().map(Annotatable::Item).collect(),
|
Ok(new_items) => new_items.into_iter().map(Annotatable::Item).collect(),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// FIXME: handle this better
|
// FIXME: handle this better
|
||||||
let msg = "proc-macro derive produced unparseable tokens";
|
|
||||||
ecx.struct_span_fatal(span, msg).emit();
|
ecx.struct_span_fatal(span, msg).emit();
|
||||||
panic!(FatalError);
|
panic!(FatalError);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,8 @@ extern crate derive_bad;
|
|||||||
#[derive(
|
#[derive(
|
||||||
A
|
A
|
||||||
)]
|
)]
|
||||||
//~^^ ERROR: proc-macro derive produced unparseable tokens
|
//~^^ ERROR proc-macro derive produced unparseable tokens
|
||||||
|
//~| ERROR expected `:`, found `}`
|
||||||
struct A;
|
struct A;
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user