-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Recover keywords in trait bounds #99915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// edition:2018 | ||
|
||
fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn()) | ||
//~^ ERROR expected identifier, found keyword `fn` | ||
//~| ERROR expected identifier, found keyword `fn` | ||
//~| ERROR expected identifier, found keyword `fn` | ||
//~| ERROR cannot find trait `r#fn` in this scope | ||
//~| ERROR cannot find trait `r#fn` in this scope | ||
//~| ERROR cannot find trait `r#fn` in this scope | ||
//~| HELP a trait with a similar name exists | ||
//~| HELP a trait with a similar name exists | ||
//~| HELP a trait with a similar name exists | ||
//~| HELP escape `fn` to use it as an identifier | ||
//~| HELP escape `fn` to use it as an identifier | ||
//~| HELP escape `fn` to use it as an identifier | ||
where | ||
G: fn(), | ||
//~^ ERROR expected identifier, found keyword `fn` | ||
//~| ERROR cannot find trait `r#fn` in this scope | ||
//~| HELP a trait with a similar name exists | ||
//~| HELP escape `fn` to use it as an identifier | ||
{} | ||
|
||
fn _g<A: struct, B>(_: impl struct, _: &dyn struct) | ||
//~^ ERROR expected identifier, found keyword `struct` | ||
//~| ERROR expected identifier, found keyword `struct` | ||
//~| ERROR expected identifier, found keyword `struct` | ||
//~| ERROR cannot find trait `r#struct` in this scope | ||
//~| ERROR cannot find trait `r#struct` in this scope | ||
//~| ERROR cannot find trait `r#struct` in this scope | ||
//~| HELP a trait with a similar name exists | ||
//~| HELP a trait with a similar name exists | ||
//~| HELP a trait with a similar name exists | ||
//~| HELP escape `struct` to use it as an identifier | ||
//~| HELP escape `struct` to use it as an identifier | ||
//~| HELP escape `struct` to use it as an identifier | ||
where | ||
B: struct, | ||
//~^ ERROR expected identifier, found keyword `struct` | ||
//~| ERROR cannot find trait `r#struct` in this scope | ||
//~| HELP a trait with a similar name exists | ||
//~| HELP escape `struct` to use it as an identifier | ||
{} | ||
|
||
trait Struct {} | ||
|
||
fn main() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
error: expected identifier, found keyword `fn` | ||
--> $DIR/kw-in-trait-bounds.rs:3:10 | ||
| | ||
LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn()) | ||
| ^^ expected identifier, found keyword | ||
| | ||
help: escape `fn` to use it as an identifier | ||
| | ||
LL | fn _f<F: r#fn(), G>(_: impl fn(), _: &dyn fn()) | ||
| ++ | ||
|
||
error: expected identifier, found keyword `fn` | ||
--> $DIR/kw-in-trait-bounds.rs:3:27 | ||
| | ||
LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn()) | ||
| ^^ expected identifier, found keyword | ||
| | ||
help: escape `fn` to use it as an identifier | ||
| | ||
LL | fn _f<F: fn(), G>(_: impl r#fn(), _: &dyn fn()) | ||
| ++ | ||
|
||
error: expected identifier, found keyword `fn` | ||
--> $DIR/kw-in-trait-bounds.rs:3:41 | ||
| | ||
LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn()) | ||
| ^^ expected identifier, found keyword | ||
| | ||
help: escape `fn` to use it as an identifier | ||
| | ||
LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn r#fn()) | ||
| ++ | ||
|
||
error: expected identifier, found keyword `fn` | ||
--> $DIR/kw-in-trait-bounds.rs:17:4 | ||
| | ||
LL | G: fn(), | ||
| ^^ expected identifier, found keyword | ||
| | ||
help: escape `fn` to use it as an identifier | ||
| | ||
LL | G: r#fn(), | ||
| ++ | ||
|
||
error: expected identifier, found keyword `struct` | ||
--> $DIR/kw-in-trait-bounds.rs:24:10 | ||
| | ||
LL | fn _g<A: struct, B>(_: impl struct, _: &dyn struct) | ||
| ^^^^^^ expected identifier, found keyword | ||
| | ||
help: escape `struct` to use it as an identifier | ||
| | ||
LL | fn _g<A: r#struct, B>(_: impl struct, _: &dyn struct) | ||
| ++ | ||
|
||
error: expected identifier, found keyword `struct` | ||
--> $DIR/kw-in-trait-bounds.rs:24:29 | ||
| | ||
LL | fn _g<A: struct, B>(_: impl struct, _: &dyn struct) | ||
| ^^^^^^ expected identifier, found keyword | ||
| | ||
help: escape `struct` to use it as an identifier | ||
| | ||
LL | fn _g<A: struct, B>(_: impl r#struct, _: &dyn struct) | ||
| ++ | ||
|
||
error: expected identifier, found keyword `struct` | ||
--> $DIR/kw-in-trait-bounds.rs:24:45 | ||
| | ||
LL | fn _g<A: struct, B>(_: impl struct, _: &dyn struct) | ||
| ^^^^^^ expected identifier, found keyword | ||
| | ||
help: escape `struct` to use it as an identifier | ||
| | ||
LL | fn _g<A: struct, B>(_: impl struct, _: &dyn r#struct) | ||
| ++ | ||
|
||
error: expected identifier, found keyword `struct` | ||
--> $DIR/kw-in-trait-bounds.rs:38:8 | ||
| | ||
LL | B: struct, | ||
| ^^^^^^ expected identifier, found keyword | ||
| | ||
help: escape `struct` to use it as an identifier | ||
| | ||
LL | B: r#struct, | ||
| ++ | ||
|
||
error[E0405]: cannot find trait `r#fn` in this scope | ||
--> $DIR/kw-in-trait-bounds.rs:3:10 | ||
| | ||
LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn()) | ||
| ^^ help: a trait with a similar name exists (notice the capitalization): `Fn` | ||
| | ||
::: $SRC_DIR/core/src/ops/function.rs:LL:COL | ||
| | ||
LL | pub trait Fn<Args>: FnMut<Args> { | ||
| ------------------------------- similarly named trait `Fn` defined here | ||
|
||
error[E0405]: cannot find trait `r#fn` in this scope | ||
--> $DIR/kw-in-trait-bounds.rs:17:4 | ||
| | ||
LL | G: fn(), | ||
| ^^ help: a trait with a similar name exists (notice the capitalization): `Fn` | ||
| | ||
::: $SRC_DIR/core/src/ops/function.rs:LL:COL | ||
| | ||
LL | pub trait Fn<Args>: FnMut<Args> { | ||
| ------------------------------- similarly named trait `Fn` defined here | ||
|
||
error[E0405]: cannot find trait `r#fn` in this scope | ||
--> $DIR/kw-in-trait-bounds.rs:3:27 | ||
| | ||
LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn()) | ||
| ^^ help: a trait with a similar name exists (notice the capitalization): `Fn` | ||
| | ||
::: $SRC_DIR/core/src/ops/function.rs:LL:COL | ||
| | ||
LL | pub trait Fn<Args>: FnMut<Args> { | ||
| ------------------------------- similarly named trait `Fn` defined here | ||
|
||
error[E0405]: cannot find trait `r#fn` in this scope | ||
--> $DIR/kw-in-trait-bounds.rs:3:41 | ||
| | ||
LL | fn _f<F: fn(), G>(_: impl fn(), _: &dyn fn()) | ||
| ^^ help: a trait with a similar name exists (notice the capitalization): `Fn` | ||
| | ||
::: $SRC_DIR/core/src/ops/function.rs:LL:COL | ||
| | ||
LL | pub trait Fn<Args>: FnMut<Args> { | ||
| ------------------------------- similarly named trait `Fn` defined here | ||
|
||
error[E0405]: cannot find trait `r#struct` in this scope | ||
--> $DIR/kw-in-trait-bounds.rs:24:10 | ||
| | ||
LL | fn _g<A: struct, B>(_: impl struct, _: &dyn struct) | ||
| ^^^^^^ help: a trait with a similar name exists (notice the capitalization): `Struct` | ||
... | ||
LL | trait Struct {} | ||
| ------------ similarly named trait `Struct` defined here | ||
|
||
error[E0405]: cannot find trait `r#struct` in this scope | ||
--> $DIR/kw-in-trait-bounds.rs:38:8 | ||
| | ||
LL | B: struct, | ||
| ^^^^^^ help: a trait with a similar name exists (notice the capitalization): `Struct` | ||
... | ||
LL | trait Struct {} | ||
| ------------ similarly named trait `Struct` defined here | ||
|
||
error[E0405]: cannot find trait `r#struct` in this scope | ||
--> $DIR/kw-in-trait-bounds.rs:24:29 | ||
| | ||
LL | fn _g<A: struct, B>(_: impl struct, _: &dyn struct) | ||
| ^^^^^^ help: a trait with a similar name exists (notice the capitalization): `Struct` | ||
... | ||
LL | trait Struct {} | ||
| ------------ similarly named trait `Struct` defined here | ||
|
||
error[E0405]: cannot find trait `r#struct` in this scope | ||
--> $DIR/kw-in-trait-bounds.rs:24:45 | ||
| | ||
LL | fn _g<A: struct, B>(_: impl struct, _: &dyn struct) | ||
| ^^^^^^ help: a trait with a similar name exists (notice the capitalization): `Struct` | ||
... | ||
LL | trait Struct {} | ||
| ------------ similarly named trait `Struct` defined here | ||
|
||
error: aborting due to 16 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0405`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
error: expected one of `!`, `(`, `,`, `=`, `>`, `?`, `for`, `~`, lifetime, or path, found keyword `const` | ||
error: expected identifier, found keyword `const` | ||
--> $DIR/without-tilde.rs:5:13 | ||
| | ||
LL | struct S<T: const Tr>; | ||
| ^^^^^ expected one of 10 possible tokens | ||
| ^^^^^ expected identifier, found keyword | ||
|
||
error: aborting due to previous error | ||
error: expected one of `(`, `+`, `,`, `::`, `<`, `=`, or `>`, found `Tr` | ||
--> $DIR/without-tilde.rs:5:19 | ||
| | ||
LL | struct S<T: const Tr>; | ||
| ^^ expected one of 7 possible tokens | ||
|
||
error: aborting due to 2 previous errors | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.