@@ -23,6 +23,17 @@ use parse::token::InternedString;
2323use parse:: token;
2424use ptr:: P ;
2525
26+ macro_rules! panictry {
27+ ( $e: expr) => ( {
28+ use std:: result:: Result :: { Ok , Err } ;
29+
30+ match $e {
31+ Ok ( e) => e,
32+ Err ( e) => panic!( e) ,
33+ }
34+ } )
35+ }
36+
2637enum State {
2738 Asm ,
2839 Outputs ,
@@ -91,16 +102,16 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
91102 p. token != token:: ModSep {
92103
93104 if outputs. len ( ) != 0 {
94- p. eat ( & token:: Comma ) ;
105+ panictry ! ( p. eat( & token:: Comma ) ) ;
95106 }
96107
97- let ( constraint, _str_style) = p. parse_str ( ) ;
108+ let ( constraint, _str_style) = panictry ! ( p. parse_str( ) ) ;
98109
99110 let span = p. last_span ;
100111
101- p. expect ( & token:: OpenDelim ( token:: Paren ) ) ;
112+ panictry ! ( p. expect( & token:: OpenDelim ( token:: Paren ) ) ) ;
102113 let out = p. parse_expr ( ) ;
103- p. expect ( & token:: CloseDelim ( token:: Paren ) ) ;
114+ panictry ! ( p. expect( & token:: CloseDelim ( token:: Paren ) ) ) ;
104115
105116 // Expands a read+write operand into two operands.
106117 //
@@ -131,20 +142,20 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
131142 p. token != token:: ModSep {
132143
133144 if inputs. len ( ) != 0 {
134- p. eat ( & token:: Comma ) ;
145+ panictry ! ( p. eat( & token:: Comma ) ) ;
135146 }
136147
137- let ( constraint, _str_style) = p. parse_str ( ) ;
148+ let ( constraint, _str_style) = panictry ! ( p. parse_str( ) ) ;
138149
139150 if constraint. starts_with ( "=" ) {
140151 cx. span_err ( p. last_span , "input operand constraint contains '='" ) ;
141152 } else if constraint. starts_with ( "+" ) {
142153 cx. span_err ( p. last_span , "input operand constraint contains '+'" ) ;
143154 }
144155
145- p. expect ( & token:: OpenDelim ( token:: Paren ) ) ;
156+ panictry ! ( p. expect( & token:: OpenDelim ( token:: Paren ) ) ) ;
146157 let input = p. parse_expr ( ) ;
147- p. expect ( & token:: CloseDelim ( token:: Paren ) ) ;
158+ panictry ! ( p. expect( & token:: CloseDelim ( token:: Paren ) ) ) ;
148159
149160 inputs. push ( ( constraint, input) ) ;
150161 }
@@ -155,10 +166,10 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
155166 p. token != token:: ModSep {
156167
157168 if clobs. len ( ) != 0 {
158- p. eat ( & token:: Comma ) ;
169+ panictry ! ( p. eat( & token:: Comma ) ) ;
159170 }
160171
161- let ( s, _str_style) = p. parse_str ( ) ;
172+ let ( s, _str_style) = panictry ! ( p. parse_str( ) ) ;
162173
163174 if OPTIONS . iter ( ) . any ( |& opt| s == opt) {
164175 cx. span_warn ( p. last_span , "expected a clobber, found an option" ) ;
@@ -167,7 +178,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
167178 }
168179 }
169180 Options => {
170- let ( option, _str_style) = p. parse_str ( ) ;
181+ let ( option, _str_style) = panictry ! ( p. parse_str( ) ) ;
171182
172183 if option == "volatile" {
173184 // Indicates that the inline assembly has side effects
@@ -182,7 +193,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
182193 }
183194
184195 if p. token == token:: Comma {
185- p. eat ( & token:: Comma ) ;
196+ panictry ! ( p. eat( & token:: Comma ) ) ;
186197 }
187198 }
188199 StateNone => ( )
@@ -194,12 +205,12 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
194205 match ( & p. token , state. next ( ) , state. next ( ) . next ( ) ) {
195206 ( & token:: Colon , StateNone , _) |
196207 ( & token:: ModSep , _, StateNone ) => {
197- p. bump ( ) ;
208+ panictry ! ( p. bump( ) ) ;
198209 break ' statement;
199210 }
200211 ( & token:: Colon , st, _) |
201212 ( & token:: ModSep , _, st) => {
202- p. bump ( ) ;
213+ panictry ! ( p. bump( ) ) ;
203214 state = st;
204215 }
205216 ( & token:: Eof , _, _) => break ' statement,
0 commit comments