Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect :: -> : typo when involving turbofish #66098

Merged
merged 2 commits into from
Nov 6, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Detect :: -> : typo when involving turbofish
  • Loading branch information
estebank committed Nov 5, 2019
commit 3bbfc7320ba0f23541f94a84cf5281a210a546cd
3 changes: 2 additions & 1 deletion src/libsyntax/parse/parser/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -354,7 +354,7 @@ impl<'a> Parser<'a> {
}

pub fn maybe_annotate_with_ascription(
&self,
&mut self,
err: &mut DiagnosticBuilder<'_>,
maybe_expected_semicolon: bool,
) {
estebank marked this conversation as resolved.
Show resolved Hide resolved
@@ -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;
}
}

1 change: 1 addition & 0 deletions src/libsyntax/parse/parser/stmt.rs
Original file line number Diff line number Diff line change
@@ -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 {
5 changes: 5 additions & 0 deletions src/test/ui/suggestions/type-ascription-instead-of-path-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() -> Result<(), ()> {
vec![Ok(2)].into_iter().collect:<Result<Vec<_>,_>>()?;
//~^ ERROR expected `::`, found `(`
Ok(())
}
13 changes: 13 additions & 0 deletions src/test/ui/suggestions/type-ascription-instead-of-path-2.stderr
Original file line number Diff line number Diff line change
@@ -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 `::`
estebank marked this conversation as resolved.
Show resolved Hide resolved
| |
| 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