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

0 commit comments

Comments
 (0)