Skip to content

Commit 61a9db7

Browse files
committed
cleanup parse_clobber_abi
1 parent fbc7181 commit 61a9db7

File tree

1 file changed

+5
-45
lines changed
  • compiler/rustc_builtin_macros/src

1 file changed

+5
-45
lines changed

compiler/rustc_builtin_macros/src/asm.rs

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -196,36 +196,10 @@ pub fn parse_raw_asm_args<'a>(
196196
if p.eat_keyword(exp!(ClobberAbi)) {
197197
allow_templates = false;
198198

199-
p.expect(exp!(OpenParen))?;
200-
201-
// FIXME: why not allow this?
202-
if p.eat(exp!(CloseParen)) {
203-
return Err(p.dcx().create_err(errors::NonABI { span: p.token.span }));
204-
}
205-
206-
let mut new_abis = Vec::new();
207-
while !p.eat(exp!(CloseParen)) {
208-
match p.parse_str_lit() {
209-
Ok(str_lit) => {
210-
new_abis.push((str_lit.symbol_unescaped, str_lit.span));
211-
}
212-
Err(opt_lit) => {
213-
let span = opt_lit.map_or(p.token.span, |lit| lit.span);
214-
return Err(p.dcx().create_err(errors::AsmExpectedStringLiteral { span }));
215-
}
216-
};
217-
218-
// Allow trailing commas
219-
if p.eat(exp!(CloseParen)) {
220-
break;
221-
}
222-
p.expect(exp!(Comma))?;
223-
}
224-
225199
args.push(RawAsmArg {
226-
span: span_start.to(p.prev_token.span),
227200
attributes: ast::AttrVec::new(),
228-
kind: RawAsmArgKind::ClobberAbi(new_abis),
201+
kind: RawAsmArgKind::ClobberAbi(parse_clobber_abi(p)?),
202+
span: span_start.to(p.prev_token.span),
229203
});
230204

231205
continue;
@@ -655,11 +629,10 @@ fn parse_options<'a>(
655629
Ok(())
656630
}
657631

658-
fn parse_clobber_abi<'a>(p: &mut Parser<'a>, args: &mut AsmArgs) -> PResult<'a, ()> {
659-
let span_start = p.prev_token.span;
660-
632+
fn parse_clobber_abi<'a>(p: &mut Parser<'a>) -> PResult<'a, Vec<(Symbol, Span)>> {
661633
p.expect(exp!(OpenParen))?;
662634

635+
// FIXME: why not allow this?
663636
if p.eat(exp!(CloseParen)) {
664637
return Err(p.dcx().create_err(errors::NonABI { span: p.token.span }));
665638
}
@@ -683,20 +656,7 @@ fn parse_clobber_abi<'a>(p: &mut Parser<'a>, args: &mut AsmArgs) -> PResult<'a,
683656
p.expect(exp!(Comma))?;
684657
}
685658

686-
let full_span = span_start.to(p.prev_token.span);
687-
688-
match &new_abis[..] {
689-
// should have errored above during parsing
690-
[] => unreachable!(),
691-
[(abi, _span)] => args.clobber_abis.push((*abi, full_span)),
692-
abis => {
693-
for (abi, span) in abis {
694-
args.clobber_abis.push((*abi, *span));
695-
}
696-
}
697-
}
698-
699-
Ok(())
659+
Ok(new_abis)
700660
}
701661

702662
fn parse_reg<'a>(p: &mut Parser<'a>) -> PResult<'a, ast::InlineAsmRegOrRegClass> {

0 commit comments

Comments
 (0)