@@ -5,7 +5,7 @@ use rustc_ast::ast::{self, ItemKind, MetaItemKind, NestedMetaItem};
55use rustc_ast:: token;
66use rustc_ast:: tokenstream:: { self , TokenStream } ;
77use rustc_data_structures:: sync:: Lrc ;
8- use rustc_errors:: { Applicability , ErrorReported , FatalError } ;
8+ use rustc_errors:: { Applicability , ErrorReported } ;
99use rustc_span:: symbol:: sym;
1010use rustc_span:: { Span , DUMMY_SP } ;
1111
@@ -86,8 +86,7 @@ impl MultiItemModifier for ProcMacroDerive {
8686 | Annotatable :: Expr ( _) => {
8787 ecx. span_err (
8888 span,
89- "proc-macro derives may only be \
90- applied to a struct, enum, or union",
89+ "proc-macro derives may only be applied to a struct, enum, or union" ,
9190 ) ;
9291 return ExpandResult :: Ready ( Vec :: new ( ) ) ;
9392 }
@@ -97,8 +96,7 @@ impl MultiItemModifier for ProcMacroDerive {
9796 _ => {
9897 ecx. span_err (
9998 span,
100- "proc-macro derives may only be \
101- applied to a struct, enum, or union",
99+ "proc-macro derives may only be applied to a struct, enum, or union" ,
102100 ) ;
103101 return ExpandResult :: Ready ( Vec :: new ( ) ) ;
104102 }
@@ -111,20 +109,16 @@ impl MultiItemModifier for ProcMacroDerive {
111109 let stream = match self . client . run ( & EXEC_STRATEGY , server, input) {
112110 Ok ( stream) => stream,
113111 Err ( e) => {
114- let msg = "proc-macro derive panicked" ;
115- let mut err = ecx. struct_span_fatal ( span, msg) ;
112+ let mut err = ecx. struct_span_err ( span, "proc-macro derive panicked" ) ;
116113 if let Some ( s) = e. as_str ( ) {
117114 err. help ( & format ! ( "message: {}" , s) ) ;
118115 }
119-
120116 err. emit ( ) ;
121- FatalError . raise ( ) ;
117+ return ExpandResult :: Ready ( vec ! [ ] ) ;
122118 }
123119 } ;
124120
125121 let error_count_before = ecx. parse_sess . span_diagnostic . err_count ( ) ;
126- let msg = "proc-macro derive produced unparseable tokens" ;
127-
128122 let mut parser =
129123 rustc_parse:: stream_to_parser ( ecx. parse_sess , stream, Some ( "proc-macro derive" ) ) ;
130124 let mut items = vec ! [ ] ;
@@ -134,18 +128,15 @@ impl MultiItemModifier for ProcMacroDerive {
134128 Ok ( None ) => break ,
135129 Ok ( Some ( item) ) => items. push ( Annotatable :: Item ( item) ) ,
136130 Err ( mut err) => {
137- // FIXME: handle this better
138- err. cancel ( ) ;
139- ecx. struct_span_fatal ( span, msg) . emit ( ) ;
140- FatalError . raise ( ) ;
131+ err. emit ( ) ;
132+ break ;
141133 }
142134 }
143135 }
144136
145137 // fail if there have been errors emitted
146138 if ecx. parse_sess . span_diagnostic . err_count ( ) > error_count_before {
147- ecx. struct_span_fatal ( span, msg) . emit ( ) ;
148- FatalError . raise ( ) ;
139+ ecx. struct_span_err ( span, "proc-macro derive produced unparseable tokens" ) . emit ( ) ;
149140 }
150141
151142 ExpandResult :: Ready ( items)
0 commit comments