Skip to content

Commit 5bf1b03

Browse files
committed
Tweak error message for use of a keyword in ident position.
Closes #15358
1 parent dee8423 commit 5bf1b03

12 files changed

+12
-12
lines changed

src/doc/guide.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ In Rust, however, using `let` to introduce a binding is _not_ an expression. The
630630
following will produce a compile-time error:
631631

632632
```{ignore}
633-
let x = (let y = 5i); // found `let` in ident position
633+
let x = (let y = 5i); // expected identifier, found keyword `let`
634634
```
635635

636636
The compiler is telling us here that it was expecting to see the beginning of

src/libsyntax/parse/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ impl<'a> Parser<'a> {
599599
let token_str = self.this_token_to_string();
600600
let span = self.span;
601601
self.span_err(span,
602-
format!("found `{}` in ident position",
602+
format!("expected identifier, found keyword `{}`",
603603
token_str).as_slice());
604604
}
605605
}

src/test/compile-fail/bad-value-ident-false.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
fn false() { } //~ ERROR found `false` in ident position
11+
fn false() { } //~ ERROR expected identifier, found keyword `false`
1212
fn main() { }

src/test/compile-fail/bad-value-ident-true.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
fn true() { } //~ ERROR found `true` in ident position
11+
fn true() { } //~ ERROR expected identifier, found keyword `true`
1212
fn main() { }

src/test/compile-fail/keyword-super.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
// except according to those terms.
1010

1111
fn main() {
12-
let super: int; //~ ERROR found `super` in ident position
12+
let super: int; //~ ERROR expected identifier, found keyword `super`
1313
}

src/test/compile-fail/keyword.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
// except according to those terms.
1010

1111
pub mod break {
12-
//~^ ERROR found `break` in ident position
12+
//~^ ERROR expected identifier, found keyword `break`
1313
}

src/test/compile-fail/removed-syntax-field-let.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010

1111
struct s {
1212
let foo: (),
13-
//~^ ERROR found `let` in ident position
13+
//~^ ERROR expected identifier, found keyword `let`
1414
//~^^ ERROR expected `:`, found `foo`
1515
}

src/test/compile-fail/removed-syntax-mut-vec-expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010

1111
fn f() {
1212
let v = [mut 1, 2, 3, 4];
13-
//~^ ERROR found `mut` in ident position
13+
//~^ ERROR expected identifier, found keyword `mut`
1414
//~^^ ERROR expected `]`, found `1`
1515
}

src/test/compile-fail/removed-syntax-mut-vec-ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
// except according to those terms.
1010

1111
type v = [mut int];
12-
//~^ ERROR found `mut` in ident position
12+
//~^ ERROR expected identifier, found keyword `mut`
1313
//~^^ ERROR expected `]`, found `int`

src/test/compile-fail/removed-syntax-uniq-mut-expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010

1111
fn f() {
1212
let a_box = box mut 42;
13-
//~^ ERROR found `mut` in ident position
13+
//~^ ERROR expected identifier, found keyword `mut`
1414
//~^^ ERROR expected `;`, found `42`
1515
}

src/test/compile-fail/removed-syntax-uniq-mut-ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
// except according to those terms.
1010

1111
type mut_box = Box<mut int>;
12-
//~^ ERROR found `mut` in ident position
12+
//~^ ERROR expected identifier, found keyword `mut`
1313
//~^^ ERROR expected `,`, found `int`

src/test/compile-fail/unsized2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
fn f<X>() {}
1414

1515
pub fn main() {
16-
f<type>(); //~ ERROR found `type` in ident position
16+
f<type>(); //~ ERROR expected identifier, found keyword `type`
1717
}

0 commit comments

Comments
 (0)