-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Detect ::
-> :
typo in type argument
#92788
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 all 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
14 changes: 14 additions & 0 deletions
14
src/test/ui/suggestions/type-ascription-instead-of-path-in-type.rs
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,14 @@ | ||
enum A { | ||
B, | ||
} | ||
|
||
fn main() { | ||
let _: Vec<A:B> = A::B; | ||
//~^ ERROR cannot find trait `B` in this scope | ||
//~| HELP you might have meant to write a path instead of an associated type bound | ||
//~| ERROR associated type bounds are unstable | ||
//~| HELP add `#![feature(associated_type_bounds)]` to the crate attributes to enable | ||
//~| ERROR struct takes at least 1 generic argument but 0 generic arguments were supplied | ||
//~| HELP add missing generic argument | ||
//~| ERROR associated type bindings are not allowed here | ||
} |
46 changes: 46 additions & 0 deletions
46
src/test/ui/suggestions/type-ascription-instead-of-path-in-type.stderr
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,46 @@ | ||
error[E0405]: cannot find trait `B` in this scope | ||
--> $DIR/type-ascription-instead-of-path-in-type.rs:6:18 | ||
| | ||
LL | let _: Vec<A:B> = A::B; | ||
| ^ not found in this scope | ||
| | ||
help: you might have meant to write a path instead of an associated type bound | ||
| | ||
LL | let _: Vec<A::B> = A::B; | ||
| ~~ | ||
Comment on lines
+1
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally we would silence all the errors after this one. It should be possible as a follow up. |
||
|
||
error[E0658]: associated type bounds are unstable | ||
--> $DIR/type-ascription-instead-of-path-in-type.rs:6:16 | ||
| | ||
LL | let _: Vec<A:B> = A::B; | ||
| ^^^ | ||
| | ||
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information | ||
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable | ||
|
||
error[E0107]: this struct takes at least 1 generic argument but 0 generic arguments were supplied | ||
--> $DIR/type-ascription-instead-of-path-in-type.rs:6:12 | ||
| | ||
LL | let _: Vec<A:B> = A::B; | ||
| ^^^ expected at least 1 generic argument | ||
| | ||
note: struct defined here, with at least 1 generic parameter: `T` | ||
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | ||
| | ||
LL | pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> { | ||
| ^^^ - | ||
help: add missing generic argument | ||
| | ||
LL | let _: Vec<T, A:B> = A::B; | ||
| ++ | ||
|
||
error[E0229]: associated type bindings are not allowed here | ||
--> $DIR/type-ascription-instead-of-path-in-type.rs:6:16 | ||
| | ||
LL | let _: Vec<A:B> = A::B; | ||
| ^^^ associated type not allowed here | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
Some errors have detailed explanations: E0107, E0229, E0405, E0658. | ||
For more information about an error, try `rustc --explain E0107`. |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can make the suggestion always accurate by also checking if
ident::trait_ref
would be a valid type.