@@ -81,7 +81,7 @@ fn parse_args<'a>(
8181 } // accept trailing commas
8282
8383 // Parse options
84- if p. eat ( & token :: Ident ( sym:: options, false ) ) {
84+ if p. eat_keyword ( sym:: options) {
8585 parse_options ( & mut p, & mut args) ?;
8686 allow_templates = false ;
8787 continue ;
@@ -101,19 +101,19 @@ fn parse_args<'a>(
101101 } ;
102102
103103 let mut explicit_reg = false ;
104- let op = if p. eat ( & token :: Ident ( kw:: In , false ) ) {
104+ let op = if p. eat_keyword ( kw:: In ) {
105105 let reg = parse_reg ( & mut p, & mut explicit_reg) ?;
106106 let expr = p. parse_expr ( ) ?;
107107 ast:: InlineAsmOperand :: In { reg, expr }
108- } else if p. eat ( & token :: Ident ( sym:: out, false ) ) {
108+ } else if p. eat_keyword ( sym:: out) {
109109 let reg = parse_reg ( & mut p, & mut explicit_reg) ?;
110110 let expr = if p. eat_keyword ( kw:: Underscore ) { None } else { Some ( p. parse_expr ( ) ?) } ;
111111 ast:: InlineAsmOperand :: Out { reg, expr, late : false }
112- } else if p. eat ( & token :: Ident ( sym:: lateout, false ) ) {
112+ } else if p. eat_keyword ( sym:: lateout) {
113113 let reg = parse_reg ( & mut p, & mut explicit_reg) ?;
114114 let expr = if p. eat_keyword ( kw:: Underscore ) { None } else { Some ( p. parse_expr ( ) ?) } ;
115115 ast:: InlineAsmOperand :: Out { reg, expr, late : true }
116- } else if p. eat ( & token :: Ident ( sym:: inout, false ) ) {
116+ } else if p. eat_keyword ( sym:: inout) {
117117 let reg = parse_reg ( & mut p, & mut explicit_reg) ?;
118118 let expr = p. parse_expr ( ) ?;
119119 if p. eat ( & token:: FatArrow ) {
@@ -123,7 +123,7 @@ fn parse_args<'a>(
123123 } else {
124124 ast:: InlineAsmOperand :: InOut { reg, expr, late : false }
125125 }
126- } else if p. eat ( & token :: Ident ( sym:: inlateout, false ) ) {
126+ } else if p. eat_keyword ( sym:: inlateout) {
127127 let reg = parse_reg ( & mut p, & mut explicit_reg) ?;
128128 let expr = p. parse_expr ( ) ?;
129129 if p. eat ( & token:: FatArrow ) {
@@ -133,10 +133,10 @@ fn parse_args<'a>(
133133 } else {
134134 ast:: InlineAsmOperand :: InOut { reg, expr, late : true }
135135 }
136- } else if p. eat ( & token :: Ident ( kw:: Const , false ) ) {
136+ } else if p. eat_keyword ( kw:: Const ) {
137137 let expr = p. parse_expr ( ) ?;
138138 ast:: InlineAsmOperand :: Const { expr }
139- } else if p. eat ( & token :: Ident ( sym:: sym, false ) ) {
139+ } else if p. eat_keyword ( sym:: sym) {
140140 let expr = p. parse_expr ( ) ?;
141141 match expr. kind {
142142 ast:: ExprKind :: Path ( ..) => { }
@@ -333,21 +333,22 @@ fn parse_options<'a>(p: &mut Parser<'a>, args: &mut AsmArgs) -> Result<(), Diagn
333333 p. expect ( & token:: OpenDelim ( token:: DelimToken :: Paren ) ) ?;
334334
335335 while !p. eat ( & token:: CloseDelim ( token:: DelimToken :: Paren ) ) {
336- if p. eat ( & token :: Ident ( sym:: pure, false ) ) {
336+ if p. eat_keyword ( sym:: pure) {
337337 try_set_option ( p, args, sym:: pure, ast:: InlineAsmOptions :: PURE ) ;
338- } else if p. eat ( & token :: Ident ( sym:: nomem, false ) ) {
338+ } else if p. eat_keyword ( sym:: nomem) {
339339 try_set_option ( p, args, sym:: nomem, ast:: InlineAsmOptions :: NOMEM ) ;
340- } else if p. eat ( & token :: Ident ( sym:: readonly, false ) ) {
340+ } else if p. eat_keyword ( sym:: readonly) {
341341 try_set_option ( p, args, sym:: readonly, ast:: InlineAsmOptions :: READONLY ) ;
342- } else if p. eat ( & token :: Ident ( sym:: preserves_flags, false ) ) {
342+ } else if p. eat_keyword ( sym:: preserves_flags) {
343343 try_set_option ( p, args, sym:: preserves_flags, ast:: InlineAsmOptions :: PRESERVES_FLAGS ) ;
344- } else if p. eat ( & token :: Ident ( sym:: noreturn, false ) ) {
344+ } else if p. eat_keyword ( sym:: noreturn) {
345345 try_set_option ( p, args, sym:: noreturn, ast:: InlineAsmOptions :: NORETURN ) ;
346- } else if p. eat ( & token :: Ident ( sym:: nostack, false ) ) {
346+ } else if p. eat_keyword ( sym:: nostack) {
347347 try_set_option ( p, args, sym:: nostack, ast:: InlineAsmOptions :: NOSTACK ) ;
348- } else {
349- p. expect ( & token:: Ident ( sym:: att_syntax, false ) ) ?;
348+ } else if p. eat_keyword ( sym:: att_syntax) {
350349 try_set_option ( p, args, sym:: att_syntax, ast:: InlineAsmOptions :: ATT_SYNTAX ) ;
350+ } else {
351+ return Err ( p. expect_one_of ( & [ ] , & [ ] ) . unwrap_err ( ) ) ;
351352 }
352353
353354 // Allow trailing commas
0 commit comments