From 5bf1b03e5c8753680c231ebcb7735a9855de31a3 Mon Sep 17 00:00:00 2001 From: Jonas Hietala Date: Fri, 29 Aug 2014 09:18:05 +0200 Subject: [PATCH] Tweak error message for use of a keyword in ident position. Closes #15358 --- src/doc/guide.md | 2 +- src/libsyntax/parse/parser.rs | 2 +- src/test/compile-fail/bad-value-ident-false.rs | 2 +- src/test/compile-fail/bad-value-ident-true.rs | 2 +- src/test/compile-fail/keyword-super.rs | 2 +- src/test/compile-fail/keyword.rs | 2 +- src/test/compile-fail/removed-syntax-field-let.rs | 2 +- src/test/compile-fail/removed-syntax-mut-vec-expr.rs | 2 +- src/test/compile-fail/removed-syntax-mut-vec-ty.rs | 2 +- src/test/compile-fail/removed-syntax-uniq-mut-expr.rs | 2 +- src/test/compile-fail/removed-syntax-uniq-mut-ty.rs | 2 +- src/test/compile-fail/unsized2.rs | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/doc/guide.md b/src/doc/guide.md index 8a634a083e8ad..5bd88288caf43 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -630,7 +630,7 @@ In Rust, however, using `let` to introduce a binding is _not_ an expression. The following will produce a compile-time error: ```{ignore} -let x = (let y = 5i); // found `let` in ident position +let x = (let y = 5i); // expected identifier, found keyword `let` ``` The compiler is telling us here that it was expecting to see the beginning of diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 37bda15ac2c41..e53ad42cb8e38 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -599,7 +599,7 @@ impl<'a> Parser<'a> { let token_str = self.this_token_to_string(); let span = self.span; self.span_err(span, - format!("found `{}` in ident position", + format!("expected identifier, found keyword `{}`", token_str).as_slice()); } } diff --git a/src/test/compile-fail/bad-value-ident-false.rs b/src/test/compile-fail/bad-value-ident-false.rs index 17157623863ad..ca10bdd9848ec 100644 --- a/src/test/compile-fail/bad-value-ident-false.rs +++ b/src/test/compile-fail/bad-value-ident-false.rs @@ -8,5 +8,5 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn false() { } //~ ERROR found `false` in ident position +fn false() { } //~ ERROR expected identifier, found keyword `false` fn main() { } diff --git a/src/test/compile-fail/bad-value-ident-true.rs b/src/test/compile-fail/bad-value-ident-true.rs index 5160471e95c80..4508d5219a217 100644 --- a/src/test/compile-fail/bad-value-ident-true.rs +++ b/src/test/compile-fail/bad-value-ident-true.rs @@ -8,5 +8,5 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn true() { } //~ ERROR found `true` in ident position +fn true() { } //~ ERROR expected identifier, found keyword `true` fn main() { } diff --git a/src/test/compile-fail/keyword-super.rs b/src/test/compile-fail/keyword-super.rs index 0a4ec841bd3ce..6cbc8aa1ea642 100644 --- a/src/test/compile-fail/keyword-super.rs +++ b/src/test/compile-fail/keyword-super.rs @@ -9,5 +9,5 @@ // except according to those terms. fn main() { - let super: int; //~ ERROR found `super` in ident position + let super: int; //~ ERROR expected identifier, found keyword `super` } diff --git a/src/test/compile-fail/keyword.rs b/src/test/compile-fail/keyword.rs index 2df56a0ab7c22..64eac47e69b32 100644 --- a/src/test/compile-fail/keyword.rs +++ b/src/test/compile-fail/keyword.rs @@ -9,5 +9,5 @@ // except according to those terms. pub mod break { - //~^ ERROR found `break` in ident position + //~^ ERROR expected identifier, found keyword `break` } diff --git a/src/test/compile-fail/removed-syntax-field-let.rs b/src/test/compile-fail/removed-syntax-field-let.rs index 2b76db4f160a4..c8711598163a0 100644 --- a/src/test/compile-fail/removed-syntax-field-let.rs +++ b/src/test/compile-fail/removed-syntax-field-let.rs @@ -10,6 +10,6 @@ struct s { let foo: (), - //~^ ERROR found `let` in ident position + //~^ ERROR expected identifier, found keyword `let` //~^^ ERROR expected `:`, found `foo` } diff --git a/src/test/compile-fail/removed-syntax-mut-vec-expr.rs b/src/test/compile-fail/removed-syntax-mut-vec-expr.rs index 9f0cc0107c1f8..b20da6346f775 100644 --- a/src/test/compile-fail/removed-syntax-mut-vec-expr.rs +++ b/src/test/compile-fail/removed-syntax-mut-vec-expr.rs @@ -10,6 +10,6 @@ fn f() { let v = [mut 1, 2, 3, 4]; - //~^ ERROR found `mut` in ident position + //~^ ERROR expected identifier, found keyword `mut` //~^^ ERROR expected `]`, found `1` } diff --git a/src/test/compile-fail/removed-syntax-mut-vec-ty.rs b/src/test/compile-fail/removed-syntax-mut-vec-ty.rs index 912952892e4f7..c5eec2ef6e199 100644 --- a/src/test/compile-fail/removed-syntax-mut-vec-ty.rs +++ b/src/test/compile-fail/removed-syntax-mut-vec-ty.rs @@ -9,5 +9,5 @@ // except according to those terms. type v = [mut int]; - //~^ ERROR found `mut` in ident position + //~^ ERROR expected identifier, found keyword `mut` //~^^ ERROR expected `]`, found `int` diff --git a/src/test/compile-fail/removed-syntax-uniq-mut-expr.rs b/src/test/compile-fail/removed-syntax-uniq-mut-expr.rs index f4fc5b696fa4b..124b3738fab5f 100644 --- a/src/test/compile-fail/removed-syntax-uniq-mut-expr.rs +++ b/src/test/compile-fail/removed-syntax-uniq-mut-expr.rs @@ -10,6 +10,6 @@ fn f() { let a_box = box mut 42; - //~^ ERROR found `mut` in ident position + //~^ ERROR expected identifier, found keyword `mut` //~^^ ERROR expected `;`, found `42` } diff --git a/src/test/compile-fail/removed-syntax-uniq-mut-ty.rs b/src/test/compile-fail/removed-syntax-uniq-mut-ty.rs index a3fc27d8cf2e0..579bfed1331ed 100644 --- a/src/test/compile-fail/removed-syntax-uniq-mut-ty.rs +++ b/src/test/compile-fail/removed-syntax-uniq-mut-ty.rs @@ -9,5 +9,5 @@ // except according to those terms. type mut_box = Box; - //~^ ERROR found `mut` in ident position + //~^ ERROR expected identifier, found keyword `mut` //~^^ ERROR expected `,`, found `int` diff --git a/src/test/compile-fail/unsized2.rs b/src/test/compile-fail/unsized2.rs index 0c9d05e298832..c5f9e8d599193 100644 --- a/src/test/compile-fail/unsized2.rs +++ b/src/test/compile-fail/unsized2.rs @@ -13,5 +13,5 @@ fn f() {} pub fn main() { - f(); //~ ERROR found `type` in ident position + f(); //~ ERROR expected identifier, found keyword `type` }