Detect ::
-> :
typo when involving turbofish
This commit is contained in:
parent
d3d28a4920
commit
3bbfc7320b
4 changed files with 21 additions and 1 deletions
|
@ -354,7 +354,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
pub fn maybe_annotate_with_ascription(
|
||||
&self,
|
||||
&mut self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
maybe_expected_semicolon: bool,
|
||||
) {
|
||||
|
@ -395,6 +395,7 @@ impl<'a> Parser<'a> {
|
|||
err.note("for more information, see \
|
||||
https://github.com/rust-lang/rust/issues/23416");
|
||||
}
|
||||
self.last_type_ascription = None;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -397,6 +397,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
let stmt = match self.parse_full_stmt(false) {
|
||||
Err(mut err) => {
|
||||
self.maybe_annotate_with_ascription(&mut err, false);
|
||||
err.emit();
|
||||
self.recover_stmt_(SemiColonMode::Ignore, BlockMode::Ignore);
|
||||
Some(Stmt {
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
fn main() -> Result<(), ()> {
|
||||
vec![Ok(2)].into_iter().collect:<Result<Vec<_>,_>>()?;
|
||||
//~^ ERROR expected `::`, found `(`
|
||||
Ok(())
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
error: expected `::`, found `(`
|
||||
--> $DIR/type-ascription-instead-of-path-2.rs:2:55
|
||||
|
|
||||
LL | vec![Ok(2)].into_iter().collect:<Result<Vec<_>,_>>()?;
|
||||
| - ^ expected `::`
|
||||
| |
|
||||
| tried to parse a type due to this type ascription
|
||||
|
|
||||
= note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`
|
||||
= note: for more information, see https://github.com/rust-lang/rust/issues/23416
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue