Skip to content

Commit 1b0836d

Browse files
committed
Tweak unexpected token wording
1 parent d673d0a commit 1b0836d

32 files changed

+42
-41
lines changed

src/libsyntax/parse/parser/diagnostics.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,23 +274,23 @@ impl<'a> Parser<'a> {
274274
expected.sort_by_cached_key(|x| x.to_string());
275275
expected.dedup();
276276
let expect = tokens_to_string(&expected[..]);
277-
let actual = self.this_token_to_string();
277+
let actual = self.this_token_descr();
278278
let (msg_exp, (label_sp, label_exp)) = if expected.len() > 1 {
279279
let short_expect = if expected.len() > 6 {
280280
format!("{} possible tokens", expected.len())
281281
} else {
282282
expect.clone()
283283
};
284-
(format!("expected one of {}, found `{}`", expect, actual),
284+
(format!("expected one of {}, found {}", expect, actual),
285285
(self.sess.source_map().next_point(self.prev_span),
286286
format!("expected one of {} here", short_expect)))
287287
} else if expected.is_empty() {
288-
(format!("unexpected token: `{}`", actual),
288+
(format!("unexpected token: {}", actual),
289289
(self.prev_span, "unexpected token after this".to_string()))
290290
} else {
291-
(format!("expected {}, found `{}`", expect, actual),
291+
(format!("expected {}, found {}", expect, actual),
292292
(self.sess.source_map().next_point(self.prev_span),
293-
format!("expected {} here", expect)))
293+
format!("expected {}", expect)))
294294
};
295295
self.last_unexpected_token_span = Some(self.token.span);
296296
let mut err = self.fatal(&msg_exp);

src/test/ui/async-await/no-async-const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
// compile-flags: --crate-type lib
44

55
pub async const fn x() {}
6-
//~^ ERROR expected one of `fn` or `unsafe`, found `const`
6+
//~^ ERROR expected one of `fn` or `unsafe`, found keyword `const`

src/test/ui/async-await/no-async-const.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: expected one of `fn` or `unsafe`, found `const`
1+
error: expected one of `fn` or `unsafe`, found keyword `const`
22
--> $DIR/no-async-const.rs:5:11
33
|
44
LL | pub async const fn x() {}

src/test/ui/async-await/no-unsafe-async.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ struct S;
44

55
impl S {
66
#[cfg(FALSE)]
7-
unsafe async fn g() {} //~ ERROR expected one of `extern` or `fn`, found `async`
7+
unsafe async fn g() {} //~ ERROR expected one of `extern` or `fn`, found keyword `async`
88
}
99

1010
#[cfg(FALSE)]
11-
unsafe async fn f() {} //~ ERROR expected one of `extern`, `fn`, or `{`, found `async`
11+
unsafe async fn f() {} //~ ERROR expected one of `extern`, `fn`, or `{`, found keyword `async`

src/test/ui/async-await/no-unsafe-async.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error: expected one of `extern` or `fn`, found `async`
1+
error: expected one of `extern` or `fn`, found keyword `async`
22
--> $DIR/no-unsafe-async.rs:7:12
33
|
44
LL | unsafe async fn g() {}
55
| ^^^^^ expected one of `extern` or `fn` here
66

7-
error: expected one of `extern`, `fn`, or `{`, found `async`
7+
error: expected one of `extern`, `fn`, or `{`, found keyword `async`
88
--> $DIR/no-unsafe-async.rs:11:8
99
|
1010
LL | unsafe async fn f() {}

src/test/ui/can-begin-expr-check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ pub fn main() {
1616
return break as ();
1717
}
1818

19-
return enum; //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `enum`
19+
return enum; //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found keyword `enum`
2020
}

src/test/ui/can-begin-expr-check.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `enum`
1+
error: expected one of `.`, `;`, `?`, `}`, or an operator, found keyword `enum`
22
--> $DIR/can-begin-expr-check.rs:19:12
33
|
44
LL | return enum;

src/test/ui/issues/issue-43196.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: expected `|`, found `}`
22
--> $DIR/issue-43196.rs:3:1
33
|
44
LL | |
5-
| - expected `|` here
5+
| - expected `|`
66
LL | }
77
| ^ unexpected token
88

src/test/ui/keyword/extern/keyword-extern-as-identifier-type.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: expected `fn`, found `::`
22
--> $DIR/keyword-extern-as-identifier-type.rs:1:16
33
|
44
LL | type A = extern::foo::bar;
5-
| ^^ expected `fn` here
5+
| ^^ expected `fn`
66

77
error: aborting due to previous error
88

src/test/ui/macros/issue-54441.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: expected one of `crate`, `fn`, `pub`, `static`, or `type`, found `let`
1+
error: expected one of `crate`, `fn`, `pub`, `static`, or `type`, found keyword `let`
22
--> $DIR/issue-54441.rs:3:9
33
|
44
LL | let

src/test/ui/parser/default.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe`, found `pub`
1+
error: expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe`, found keyword `pub`
22
--> $DIR/default.rs:22:13
33
|
44
LL | default pub fn foo<T: Default>() -> T { T::default() }

src/test/ui/parser/duplicate-visibility.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: expected one of `(`, `fn`, `static`, or `type`, found `pub`
1+
error: expected one of `(`, `fn`, `static`, or `type`, found keyword `pub`
22
--> $DIR/duplicate-visibility.rs:3:9
33
|
44
LL | pub pub fn foo();
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// Verifies that the expected token errors for `extern crate` are
22
// raised
33

4-
extern "C" mod foo; //~ERROR expected one of `fn` or `{`, found `mod`
4+
extern "C" mod foo; //~ERROR expected one of `fn` or `{`, found keyword `mod`

src/test/ui/parser/extern-expected-fn-or-brace.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: expected one of `fn` or `{`, found `mod`
1+
error: expected one of `fn` or `{`, found keyword `mod`
22
--> $DIR/extern-expected-fn-or-brace.rs:4:12
33
|
44
LL | extern "C" mod foo;

src/test/ui/parser/impl-parsing.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ error: expected `impl`, found `FAIL`
2626
--> $DIR/impl-parsing.rs:11:16
2727
|
2828
LL | default unsafe FAIL
29-
| ^^^^ expected `impl` here
29+
| ^^^^ expected `impl`
3030

3131
error: aborting due to 5 previous errors
3232

src/test/ui/parser/import-from-path.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: expected `;`, found `::`
22
--> $DIR/import-from-path.rs:2:15
33
|
44
LL | use foo::{bar}::baz
5-
| ^^ expected `;` here
5+
| ^^ expected `;`
66

77
error: aborting due to previous error
88

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: expected `;`, found `as`
1+
error: expected `;`, found keyword `as`
22
--> $DIR/import-from-rename.rs:3:16
33
|
44
LL | use foo::{bar} as baz;
5-
| ^^ expected `;` here
5+
| ^^ expected `;`
66

77
error: aborting due to previous error
88

src/test/ui/parser/import-glob-path.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: expected `;`, found `::`
22
--> $DIR/import-glob-path.rs:2:11
33
|
44
LL | use foo::*::bar
5-
| ^^ expected `;` here
5+
| ^^ expected `;`
66

77
error: aborting due to previous error
88

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: expected `;`, found `as`
1+
error: expected `;`, found keyword `as`
22
--> $DIR/import-glob-rename.rs:3:12
33
|
44
LL | use foo::* as baz;
5-
| ^^ expected `;` here
5+
| ^^ expected `;`
66

77
error: aborting due to previous error
88

src/test/ui/parser/issue-15980.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn main(){
1111
}
1212
//~^ NOTE expected one of `.`, `=>`, `?`, or an operator here
1313
_ => {}
14-
//~^ ERROR expected one of `.`, `=>`, `?`, or an operator, found `_`
14+
//~^ ERROR expected one of `.`, `=>`, `?`, or an operator, found reserved identifier `_`
1515
//~| NOTE unexpected token
1616
}
1717
}

src/test/ui/parser/issue-15980.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ help: you can escape reserved keywords to use them as identifiers
1212
LL | r#return
1313
|
1414

15-
error: expected one of `.`, `=>`, `?`, or an operator, found `_`
15+
error: expected one of `.`, `=>`, `?`, or an operator, found reserved identifier `_`
1616
--> $DIR/issue-15980.rs:13:9
1717
|
1818
LL | }

src/test/ui/parser/issue-19398.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
trait T {
2-
extern "Rust" unsafe fn foo(); //~ ERROR expected `fn`, found `unsafe`
2+
extern "Rust" unsafe fn foo(); //~ ERROR expected `fn`, found keyword `unsafe`
33
}
44

55
fn main() {}

src/test/ui/parser/issue-19398.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: expected `fn`, found `unsafe`
1+
error: expected `fn`, found keyword `unsafe`
22
--> $DIR/issue-19398.rs:2:19
33
|
44
LL | extern "Rust" unsafe fn foo();
5-
| ^^^^^^ expected `fn` here
5+
| ^^^^^^ expected `fn`
66

77
error: aborting due to previous error
88

src/test/ui/parser/raw/raw-literal-keywords.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
fn test_if() {
2-
r#if true { } //~ ERROR found `true`
2+
r#if true { } //~ ERROR found keyword `true`
33
}
44

55
fn test_struct() {

src/test/ui/parser/raw/raw-literal-keywords.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `true`
1+
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found keyword `true`
22
--> $DIR/raw-literal-keywords.rs:2:10
33
|
44
LL | r#if true { }

src/test/ui/parser/recover-for-loop-parens-around-head.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn main() {
88
let vec = vec![1, 2, 3];
99

1010
for ( elem in vec ) {
11-
//~^ ERROR expected one of `)`, `,`, `@`, or `|`, found `in`
11+
//~^ ERROR expected one of `)`, `,`, `@`, or `|`, found keyword `in`
1212
//~| ERROR unexpected closing `)`
1313
const RECOVERY_WITNESS: () = 0; //~ ERROR mismatched types
1414
}

src/test/ui/parser/recover-for-loop-parens-around-head.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: expected one of `)`, `,`, `@`, or `|`, found `in`
1+
error: expected one of `)`, `,`, `@`, or `|`, found keyword `in`
22
--> $DIR/recover-for-loop-parens-around-head.rs:10:16
33
|
44
LL | for ( elem in vec ) {

src/test/ui/parser/removed-syntax-static-fn.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `static`
1+
error: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found keyword `static`
22
--> $DIR/removed-syntax-static-fn.rs:4:5
33
|
44
LL | impl S {
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
type mut_box = Box<mut isize>; //~ ERROR expected one of `>`, const, lifetime, or type, found `mut`
1+
type mut_box = Box<mut isize>;
2+
//~^ ERROR expected one of `>`, const, lifetime, or type, found keyword `mut`

src/test/ui/parser/removed-syntax-uniq-mut-ty.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: expected one of `>`, const, lifetime, or type, found `mut`
1+
error: expected one of `>`, const, lifetime, or type, found keyword `mut`
22
--> $DIR/removed-syntax-uniq-mut-ty.rs:1:20
33
|
44
LL | type mut_box = Box<mut isize>;

src/test/ui/parser/underscore_item_not_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ use _ as g; //~ ERROR expected identifier, found reserved identifier `_`
2525
trait _ {} //~ ERROR expected identifier, found reserved identifier `_`
2626
trait _ = Copy; //~ ERROR expected identifier, found reserved identifier `_`
2727
macro_rules! _ { () => {} } //~ ERROR expected identifier, found reserved identifier `_`
28-
union _ { f: u8 } //~ ERROR expected one of `!` or `::`, found `_`
28+
union _ { f: u8 } //~ ERROR expected one of `!` or `::`, found reserved identifier `_`
2929

3030
fn main() {}

src/test/ui/parser/underscore_item_not_const.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ error: expected identifier, found reserved identifier `_`
8282
LL | macro_rules! _ { () => {} }
8383
| ^ expected identifier, found reserved identifier
8484

85-
error: expected one of `!` or `::`, found `_`
85+
error: expected one of `!` or `::`, found reserved identifier `_`
8686
--> $DIR/underscore_item_not_const.rs:28:7
8787
|
8888
LL | union _ { f: u8 }

0 commit comments

Comments
 (0)