Skip to content
Permalink
Browse files

syntax: extract `error_on_invalid_abi`.

  • Loading branch information...
Centril committed Sep 30, 2019
1 parent 66bf323 commit 573a8d8d30723592030c4eb22ebea637a58ac411
Showing with 17 additions and 14 deletions.
  1. +17 −14 src/libsyntax/parse/parser.rs
@@ -1501,32 +1501,35 @@ impl<'a> Parser<'a> {
match self.token.kind {
token::Literal(token::Lit { kind: token::Str, symbol, suffix }) |
token::Literal(token::Lit { kind: token::StrRaw(..), symbol, suffix }) => {
let sp = self.token.span;
self.expect_no_suffix(sp, "an ABI spec", suffix);
self.expect_no_suffix(self.token.span, "an ABI spec", suffix);
self.bump();
match abi::lookup(&symbol.as_str()) {
Some(abi) => Ok(Some(abi)),
None => {
let prev_span = self.prev_span;
struct_span_err!(
self.sess.span_diagnostic,
prev_span,
E0703,
"invalid ABI: found `{}`",
symbol
)
.span_label(prev_span, "invalid ABI")
.help(&format!("valid ABIs: {}", abi::all_names().join(", ")))
.emit();
self.error_on_invalid_abi(symbol);
Ok(None)
}
}
}

_ => Ok(None),
}
}

/// Emit an error where `symbol` is an invalid ABI.
fn error_on_invalid_abi(&self, symbol: Symbol) {
let prev_span = self.prev_span;
struct_span_err!(
self.sess.span_diagnostic,
prev_span,
E0703,
"invalid ABI: found `{}`",
symbol
)
.span_label(prev_span, "invalid ABI")
.help(&format!("valid ABIs: {}", abi::all_names().join(", ")))
.emit();
}

/// We are parsing `async fn`. If we are on Rust 2015, emit an error.
fn ban_async_in_2015(&self, async_span: Span) {
if async_span.rust_2015() {

0 comments on commit 573a8d8

Please sign in to comment.
You can’t perform that action at this time.