diff options
| author | Rob Pilling <robpilling@gmail.com> | 2020-02-01 19:21:54 +0000 |
|---|---|---|
| committer | Rob Pilling <robpilling@gmail.com> | 2020-02-01 19:38:52 +0000 |
| commit | 991d2ee282837a0ca3ec5a730e081274d37fa8b0 (patch) | |
| tree | 7a786a6f7d71fdf63183fefa2dcd4478626c8813 /src | |
| parent | 45fb7232abc893a06272550ebcad7b39a3cb26c1 (diff) | |
Improve wording and docs for qualified path recovery
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_parse/parser/path.rs | 15 | ||||
| -rw-r--r-- | src/test/ui/parser/qualified-path-in-turbofish.fixed | 2 | ||||
| -rw-r--r-- | src/test/ui/parser/qualified-path-in-turbofish.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/parser/qualified-path-in-turbofish.stderr | 2 |
4 files changed, 14 insertions, 7 deletions
diff --git a/src/librustc_parse/parser/path.rs b/src/librustc_parse/parser/path.rs index 027380eaa2a..5aa14c1739f 100644 --- a/src/librustc_parse/parser/path.rs +++ b/src/librustc_parse/parser/path.rs @@ -81,17 +81,24 @@ impl<'a> Parser<'a> { Ok((qself, Path { segments: path.segments, span: lo.to(self.prev_span) })) } + /// Recover from an invalid single colon, when the user likely meant a qualified path. + /// + /// ```ignore (diagnostics) + /// <Bar as Baz<T>>:Qux + /// ^ help: use double colon + /// ``` fn recover_colon_before_qpath_proj(&mut self) -> bool { if self.token.kind != token::Colon { return false; } - // <Bar as Baz<T>>:Qux - // ^ - self.bump(); + self.bump(); // colon self.diagnostic() - .struct_span_err(self.prev_span, "found single colon where type path was expected") + .struct_span_err( + self.prev_span, + "found single colon before projection in qualified path", + ) .span_suggestion( self.prev_span, "use double colon", diff --git a/src/test/ui/parser/qualified-path-in-turbofish.fixed b/src/test/ui/parser/qualified-path-in-turbofish.fixed index a4213bdd3fb..404d2f7762d 100644 --- a/src/test/ui/parser/qualified-path-in-turbofish.fixed +++ b/src/test/ui/parser/qualified-path-in-turbofish.fixed @@ -15,5 +15,5 @@ fn template<T>() -> i64 { fn main() { template::<<Impl as T>::Ty>(); - //~^ ERROR found single colon where type path was expected + //~^ ERROR found single colon before projection in qualified path } diff --git a/src/test/ui/parser/qualified-path-in-turbofish.rs b/src/test/ui/parser/qualified-path-in-turbofish.rs index 75b2af2aa2e..2f4b2ed348b 100644 --- a/src/test/ui/parser/qualified-path-in-turbofish.rs +++ b/src/test/ui/parser/qualified-path-in-turbofish.rs @@ -15,5 +15,5 @@ fn template<T>() -> i64 { fn main() { template::<<Impl as T>:Ty>(); - //~^ ERROR found single colon where type path was expected + //~^ ERROR found single colon before projection in qualified path } diff --git a/src/test/ui/parser/qualified-path-in-turbofish.stderr b/src/test/ui/parser/qualified-path-in-turbofish.stderr index 1fe6353b7a0..8857d2ef30c 100644 --- a/src/test/ui/parser/qualified-path-in-turbofish.stderr +++ b/src/test/ui/parser/qualified-path-in-turbofish.stderr @@ -1,4 +1,4 @@ -error: found single colon where type path was expected +error: found single colon before projection in qualified path --> $DIR/qualified-path-in-turbofish.rs:17:27 | LL | template::<<Impl as T>:Ty>(); |
