-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect
::
-> :
typo in type argument
When writing `Vec<A:B>`, suggest `Vec<A::B>`.
- Loading branch information
Showing
4 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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 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; | ||
| ~~ | ||
|
||
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`. |