diff options
| author | Rob Pilling <robpilling@gmail.com> | 2020-01-29 20:34:28 +0000 |
|---|---|---|
| committer | Rob Pilling <robpilling@gmail.com> | 2020-01-30 22:41:07 +0000 |
| commit | 3c91bdca1d552055e2b92ecac5275c1ebe9a4ee8 (patch) | |
| tree | b7040d4271515c92ffb98f23c45098d2e01ee2b3 /src/test/ui/parser | |
| parent | 212b2c7da87f3086af535b33a9ca6b5242f2d5a7 (diff) | |
| download | rust-3c91bdca1d552055e2b92ecac5275c1ebe9a4ee8.tar.gz rust-3c91bdca1d552055e2b92ecac5275c1ebe9a4ee8.zip | |
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.
Diffstat (limited to 'src/test/ui/parser')
| -rw-r--r-- | src/test/ui/parser/qualified-path-in-turbofish.fixed | 19 | ||||
| -rw-r--r-- | src/test/ui/parser/qualified-path-in-turbofish.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/parser/qualified-path-in-turbofish.stderr | 8 |
3 files changed, 46 insertions, 0 deletions
diff --git a/src/test/ui/parser/qualified-path-in-turbofish.fixed b/src/test/ui/parser/qualified-path-in-turbofish.fixed new file mode 100644 index 00000000000..a4213bdd3fb --- /dev/null +++ b/src/test/ui/parser/qualified-path-in-turbofish.fixed @@ -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 +} diff --git a/src/test/ui/parser/qualified-path-in-turbofish.rs b/src/test/ui/parser/qualified-path-in-turbofish.rs new file mode 100644 index 00000000000..75b2af2aa2e --- /dev/null +++ b/src/test/ui/parser/qualified-path-in-turbofish.rs @@ -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 +} diff --git a/src/test/ui/parser/qualified-path-in-turbofish.stderr b/src/test/ui/parser/qualified-path-in-turbofish.stderr new file mode 100644 index 00000000000..1fe6353b7a0 --- /dev/null +++ b/src/test/ui/parser/qualified-path-in-turbofish.stderr @@ -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 + |
