Suggest path separator for single-colon typos
This commit adds guidance for when a user means to type a path, but ends up typing a single colon, such as `<<Impl as T>:Ty>`. This change seemed pertinent as the current error message is particularly misleading, emitting `error: unmatched angle bracket`, despite the angle bracket being matched later on, leaving the user to track down the typo'd colon.
This commit is contained in:
parent
212b2c7da8
commit
3c91bdca1d
4 changed files with 63 additions and 1 deletions
19
src/test/ui/parser/qualified-path-in-turbofish.fixed
Normal file
19
src/test/ui/parser/qualified-path-in-turbofish.fixed
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// run-rustfix
|
||||
trait T {
|
||||
type Ty;
|
||||
}
|
||||
|
||||
struct Impl;
|
||||
|
||||
impl T for Impl {
|
||||
type Ty = u32;
|
||||
}
|
||||
|
||||
fn template<T>() -> i64 {
|
||||
3
|
||||
}
|
||||
|
||||
fn main() {
|
||||
template::<<Impl as T>::Ty>();
|
||||
//~^ ERROR found single colon where type path was expected
|
||||
}
|
||||
19
src/test/ui/parser/qualified-path-in-turbofish.rs
Normal file
19
src/test/ui/parser/qualified-path-in-turbofish.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// run-rustfix
|
||||
trait T {
|
||||
type Ty;
|
||||
}
|
||||
|
||||
struct Impl;
|
||||
|
||||
impl T for Impl {
|
||||
type Ty = u32;
|
||||
}
|
||||
|
||||
fn template<T>() -> i64 {
|
||||
3
|
||||
}
|
||||
|
||||
fn main() {
|
||||
template::<<Impl as T>:Ty>();
|
||||
//~^ ERROR found single colon where type path was expected
|
||||
}
|
||||
8
src/test/ui/parser/qualified-path-in-turbofish.stderr
Normal file
8
src/test/ui/parser/qualified-path-in-turbofish.stderr
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
error: found single colon where type path was expected
|
||||
--> $DIR/qualified-path-in-turbofish.rs:17:27
|
||||
|
|
||||
LL | template::<<Impl as T>:Ty>();
|
||||
| ^ help: use double colon: `::`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue