mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Suppress redundant error
This commit is contained in:
@@ -2370,6 +2370,10 @@ pub fn is_place_expr(&self, mut allow_projections_from: impl FnMut(&Self) -> boo
|
||||
// Lang item paths cannot currently be local variables or statics.
|
||||
ExprKind::Path(QPath::LangItem(..)) => false,
|
||||
|
||||
// Suppress errors for bad expressions.
|
||||
ExprKind::Err(_guar)
|
||||
| ExprKind::Let(&LetExpr { recovered: ast::Recovered::Yes(_guar), .. }) => true,
|
||||
|
||||
// Partially qualified paths in expressions can only legally
|
||||
// refer to associated items which are always rvalues.
|
||||
ExprKind::Path(QPath::TypeRelative(..))
|
||||
@@ -2401,8 +2405,7 @@ pub fn is_place_expr(&self, mut allow_projections_from: impl FnMut(&Self) -> boo
|
||||
| ExprKind::Binary(..)
|
||||
| ExprKind::Yield(..)
|
||||
| ExprKind::Cast(..)
|
||||
| ExprKind::DropTemps(..)
|
||||
| ExprKind::Err(_) => false,
|
||||
| ExprKind::DropTemps(..) => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,5 +10,4 @@ fn main() {
|
||||
// in the AST, the `let` expression was visited first.
|
||||
(let x = 1,) = x;
|
||||
//~^ ERROR expected expression, found `let` statement
|
||||
//~| ERROR invalid left-hand side of assignment
|
||||
}
|
||||
|
||||
@@ -1,19 +1,10 @@
|
||||
error: expected expression, found `let` statement
|
||||
--> $DIR/bad-let-in-destructure.rs:10:4
|
||||
--> $DIR/bad-let-in-destructure.rs:11:4
|
||||
|
|
||||
LL | (let x = 1,) = x;
|
||||
| ^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
error[E0070]: invalid left-hand side of assignment
|
||||
--> $DIR/bad-let-in-destructure.rs:10:16
|
||||
|
|
||||
LL | (let x = 1,) = x;
|
||||
| --------- ^
|
||||
| |
|
||||
| cannot assign to this expression
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0070`.
|
||||
|
||||
Reference in New Issue
Block a user