about summary refs log tree commit diff
path: root/src/libsyntax_ext
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-12-01 06:06:06 +0000
committerbors <bors@rust-lang.org>2017-12-01 06:06:06 +0000
commitd1364a65c0e064ee12aea8d58aceb403b8200682 (patch)
tree4610cdc2a8f401adb2cca09a6594d52fd1c74299 /src/libsyntax_ext
parent804b15be82ea668d943fab70195eb57a2f942d4b (diff)
parentcf9283ea9376525c59015a52c729e7a79f576426 (diff)
downloadrust-d1364a65c0e064ee12aea8d58aceb403b8200682.tar.gz
rust-d1364a65c0e064ee12aea8d58aceb403b8200682.zip
Auto merge of #45997 - estebank:pub-ident, r=nikomatsakis
Account for missing keyword in fn/struct definition

Fix #38911.
Diffstat (limited to 'src/libsyntax_ext')
-rw-r--r--src/libsyntax_ext/deriving/custom.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libsyntax_ext/deriving/custom.rs b/src/libsyntax_ext/deriving/custom.rs
index fa5537b5d8f..f375847e705 100644
--- a/src/libsyntax_ext/deriving/custom.rs
+++ b/src/libsyntax_ext/deriving/custom.rs
@@ -96,12 +96,18 @@ impl MultiItemModifier for ProcMacroDerive {
             }
         };
 
+        let error_count_before = ecx.parse_sess.span_diagnostic.err_count();
         __internal::set_sess(ecx, || {
+            let msg = "proc-macro derive produced unparseable tokens";
             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(),
                 Err(_) => {
                     // FIXME: handle this better
-                    let msg = "proc-macro derive produced unparseable tokens";
                     ecx.struct_span_fatal(span, msg).emit();
                     panic!(FatalError);
                 }