From 1b3a03009215b518572b03dd4bf02dbcba129527 Mon Sep 17 00:00:00 2001 From: lucy Date: Thu, 29 May 2014 14:40:41 +0200 Subject: [PATCH] syntax: Fix span on illegal ABI errors Fixes #8537 Fixes #14499 --- src/libsyntax/parse/parser.rs | 2 +- src/test/compile-fail/issue-8537.rs | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/test/compile-fail/issue-8537.rs diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 65ad83d4b4fb1..2884bb68261d4 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4537,7 +4537,7 @@ impl<'a> Parser<'a> { Some(abi) => Some(abi), None => { self.span_err( - self.span, + self.last_span, format!("illegal ABI: expected one of [{}], \ found `{}`", abi::all_names().connect(", "), diff --git a/src/test/compile-fail/issue-8537.rs b/src/test/compile-fail/issue-8537.rs new file mode 100644 index 0000000000000..dba9e751f71f5 --- /dev/null +++ b/src/test/compile-fail/issue-8537.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub extern + "invalid-abi" //~ ERROR illegal ABI +fn foo() {} + +fn main() {}