@@ -81,7 +81,7 @@ fn parse_args<'a>(
81
81
} // accept trailing commas
82
82
83
83
// Parse options
84
- if p. eat ( & token :: Ident ( sym:: options, false ) ) {
84
+ if p. eat_keyword ( sym:: options) {
85
85
parse_options ( & mut p, & mut args) ?;
86
86
allow_templates = false ;
87
87
continue ;
@@ -101,19 +101,19 @@ fn parse_args<'a>(
101
101
} ;
102
102
103
103
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 ) {
105
105
let reg = parse_reg ( & mut p, & mut explicit_reg) ?;
106
106
let expr = p. parse_expr ( ) ?;
107
107
ast:: InlineAsmOperand :: In { reg, expr }
108
- } else if p. eat ( & token :: Ident ( sym:: out, false ) ) {
108
+ } else if p. eat_keyword ( sym:: out) {
109
109
let reg = parse_reg ( & mut p, & mut explicit_reg) ?;
110
110
let expr = if p. eat_keyword ( kw:: Underscore ) { None } else { Some ( p. parse_expr ( ) ?) } ;
111
111
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) {
113
113
let reg = parse_reg ( & mut p, & mut explicit_reg) ?;
114
114
let expr = if p. eat_keyword ( kw:: Underscore ) { None } else { Some ( p. parse_expr ( ) ?) } ;
115
115
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) {
117
117
let reg = parse_reg ( & mut p, & mut explicit_reg) ?;
118
118
let expr = p. parse_expr ( ) ?;
119
119
if p. eat ( & token:: FatArrow ) {
@@ -123,7 +123,7 @@ fn parse_args<'a>(
123
123
} else {
124
124
ast:: InlineAsmOperand :: InOut { reg, expr, late : false }
125
125
}
126
- } else if p. eat ( & token :: Ident ( sym:: inlateout, false ) ) {
126
+ } else if p. eat_keyword ( sym:: inlateout) {
127
127
let reg = parse_reg ( & mut p, & mut explicit_reg) ?;
128
128
let expr = p. parse_expr ( ) ?;
129
129
if p. eat ( & token:: FatArrow ) {
@@ -133,10 +133,10 @@ fn parse_args<'a>(
133
133
} else {
134
134
ast:: InlineAsmOperand :: InOut { reg, expr, late : true }
135
135
}
136
- } else if p. eat ( & token :: Ident ( kw:: Const , false ) ) {
136
+ } else if p. eat_keyword ( kw:: Const ) {
137
137
let expr = p. parse_expr ( ) ?;
138
138
ast:: InlineAsmOperand :: Const { expr }
139
- } else if p. eat ( & token :: Ident ( sym:: sym, false ) ) {
139
+ } else if p. eat_keyword ( sym:: sym) {
140
140
let expr = p. parse_expr ( ) ?;
141
141
match expr. kind {
142
142
ast:: ExprKind :: Path ( ..) => { }
@@ -164,7 +164,7 @@ fn parse_args<'a>(
164
164
args. templates . push ( template) ;
165
165
continue ;
166
166
} else {
167
- return Err ( p . expect_one_of ( & [ ] , & [ ] ) . unwrap_err ( ) ) ;
167
+ return p . unexpected ( ) ;
168
168
} ;
169
169
170
170
allow_templates = false ;
@@ -333,21 +333,22 @@ fn parse_options<'a>(p: &mut Parser<'a>, args: &mut AsmArgs) -> Result<(), Diagn
333
333
p. expect ( & token:: OpenDelim ( token:: DelimToken :: Paren ) ) ?;
334
334
335
335
while !p. eat ( & token:: CloseDelim ( token:: DelimToken :: Paren ) ) {
336
- if p. eat ( & token :: Ident ( sym:: pure, false ) ) {
336
+ if p. eat_keyword ( sym:: pure) {
337
337
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) {
339
339
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) {
341
341
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) {
343
343
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) {
345
345
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) {
347
347
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) {
350
349
try_set_option ( p, args, sym:: att_syntax, ast:: InlineAsmOptions :: ATT_SYNTAX ) ;
350
+ } else {
351
+ return p. unexpected ( ) ;
351
352
}
352
353
353
354
// Allow trailing commas
0 commit comments