Improve wording and docs for qualified path recovery
This commit is contained in:
parent
45fb7232ab
commit
991d2ee282
4 changed files with 14 additions and 7 deletions
|
@ -81,17 +81,24 @@ impl<'a> Parser<'a> {
|
||||||
Ok((qself, Path { segments: path.segments, span: lo.to(self.prev_span) }))
|
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 {
|
fn recover_colon_before_qpath_proj(&mut self) -> bool {
|
||||||
if self.token.kind != token::Colon {
|
if self.token.kind != token::Colon {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <Bar as Baz<T>>:Qux
|
self.bump(); // colon
|
||||||
// ^
|
|
||||||
self.bump();
|
|
||||||
|
|
||||||
self.diagnostic()
|
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(
|
.span_suggestion(
|
||||||
self.prev_span,
|
self.prev_span,
|
||||||
"use double colon",
|
"use double colon",
|
||||||
|
|
|
@ -15,5 +15,5 @@ fn template<T>() -> i64 {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
template::<<Impl as T>::Ty>();
|
template::<<Impl as T>::Ty>();
|
||||||
//~^ ERROR found single colon where type path was expected
|
//~^ ERROR found single colon before projection in qualified path
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,5 +15,5 @@ fn template<T>() -> i64 {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
template::<<Impl as T>:Ty>();
|
template::<<Impl as T>:Ty>();
|
||||||
//~^ ERROR found single colon where type path was expected
|
//~^ ERROR found single colon before projection in qualified path
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
--> $DIR/qualified-path-in-turbofish.rs:17:27
|
||||||
|
|
|
|
||||||
LL | template::<<Impl as T>:Ty>();
|
LL | template::<<Impl as T>:Ty>();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue