diff options
| author | P1start <rewi-github@whanau.org> | 2014-09-13 14:09:22 +1200 |
|---|---|---|
| committer | P1start <rewi-github@whanau.org> | 2014-10-03 20:39:56 +1300 |
| commit | 042cdeefc7708291057770ddd5becf14288dad71 (patch) | |
| tree | 8d93978d162a2ac1b0f2234b19f0ce9b04f10608 | |
| parent | 45044124e46bbfd1ab9869ffce71259ae93866ff (diff) | |
Correct error message for invalid `ref`/`mut` bindings
Closes #15914.
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 7 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-15914.rs | 14 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7cce9c2dc3a..d2735a425f5 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3402,9 +3402,10 @@ impl<'a> Parser<'a> { binding_mode: ast::BindingMode) -> ast::Pat_ { if !is_plain_ident(&self.token) { - let last_span = self.last_span; - self.span_fatal(last_span, - "expected identifier, found path"); + let span = self.span; + let tok_str = self.this_token_to_string(); + self.span_fatal(span, + format!("expected identifier, found `{}`", tok_str).as_slice()); } let ident = self.parse_ident(); let last_span = self.last_span; diff --git a/src/test/compile-fail/issue-15914.rs b/src/test/compile-fail/issue-15914.rs new file mode 100644 index 00000000000..45b3abfddfb --- /dev/null +++ b/src/test/compile-fail/issue-15914.rs @@ -0,0 +1,14 @@ +// 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 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let ref + (); //~ ERROR expected identifier, found `(` +} |
