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/librustc_parse/parser | |
| parent | 45fb7232abc893a06272550ebcad7b39a3cb26c1 (diff) | |
| download | rust-991d2ee282837a0ca3ec5a730e081274d37fa8b0.tar.gz rust-991d2ee282837a0ca3ec5a730e081274d37fa8b0.zip | |
Improve wording and docs for qualified path recovery
Diffstat (limited to 'src/librustc_parse/parser')
| -rw-r--r-- | src/librustc_parse/parser/path.rs | 15 |
1 files changed, 11 insertions, 4 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", |
