diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-09-07 08:06:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-07 08:06:09 +0200 |
| commit | fae7bc756e622f5cb6ffa432e914a06942e141ff (patch) | |
| tree | 013e7b2b7166773a653dc433ea89f072a34cb683 /src/libsyntax/parse | |
| parent | da61325bfab3f4292843791b10eeaabf2f835741 (diff) | |
| parent | dc613c6d055c1b45f7e11e6ee03e4a3095d5b8a9 (diff) | |
| download | rust-fae7bc756e622f5cb6ffa432e914a06942e141ff.tar.gz rust-fae7bc756e622f5cb6ffa432e914a06942e141ff.zip | |
Rollup merge of #64192 - estebank:turbofish-madness, r=petrochenkov
Bail out when encountering likely missing turbofish in parser When encountering a likely intended turbofish without `::`, bubble up the diagnostic instead of emitting it to allow the parser to recover more gracefully and avoid uneccessary type errors that are likely to be wrong. Fix #61329.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/diagnostics.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser/expr.rs | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/libsyntax/parse/diagnostics.rs b/src/libsyntax/parse/diagnostics.rs index d4e661d1a38..d050d4f4ce7 100644 --- a/src/libsyntax/parse/diagnostics.rs +++ b/src/libsyntax/parse/diagnostics.rs @@ -544,7 +544,7 @@ impl<'a> Parser<'a> { /// Produce an error if comparison operators are chained (RFC #558). /// We only need to check lhs, not rhs, because all comparison ops /// have same precedence and are left-associative - crate fn check_no_chained_comparison(&self, lhs: &Expr, outer_op: &AssocOp) { + crate fn check_no_chained_comparison(&self, lhs: &Expr, outer_op: &AssocOp) -> PResult<'a, ()> { debug_assert!(outer_op.is_comparison(), "check_no_chained_comparison: {:?} is not comparison", outer_op); @@ -563,11 +563,14 @@ impl<'a> Parser<'a> { err.help( "use `::<...>` instead of `<...>` if you meant to specify type arguments"); err.help("or use `(...)` if you meant to specify fn arguments"); + // These cases cause too many knock-down errors, bail out (#61329). + return Err(err); } err.emit(); } _ => {} } + Ok(()) } crate fn maybe_report_ambiguous_plus( diff --git a/src/libsyntax/parse/parser/expr.rs b/src/libsyntax/parse/parser/expr.rs index 59b936a7eb4..e8c8e199fd0 100644 --- a/src/libsyntax/parse/parser/expr.rs +++ b/src/libsyntax/parse/parser/expr.rs @@ -231,7 +231,7 @@ impl<'a> Parser<'a> { self.bump(); if op.is_comparison() { - self.check_no_chained_comparison(&lhs, &op); + self.check_no_chained_comparison(&lhs, &op)?; } // Special cases: if op == AssocOp::As { |
