diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2021-05-06 19:09:35 -0700 |
|---|---|---|
| committer | Esteban Kuber <esteban@kuber.com.ar> | 2021-11-25 18:04:33 +0000 |
| commit | 37a11a96a1b3ad68c40cc293270cf8ffbe7904de (patch) | |
| tree | 1247cf8878724a5f024a4c156055102641559d01 /compiler/rustc_ast_lowering/src | |
| parent | 862962b90e59c5c1e217df74de80d3a81eee42f4 (diff) | |
| download | rust-37a11a96a1b3ad68c40cc293270cf8ffbe7904de.tar.gz rust-37a11a96a1b3ad68c40cc293270cf8ffbe7904de.zip | |
On type mismatch caused by assignment, point at assignee
* Do not emit unnecessary E0308 after E0070 * Show fewer errors on `while let` missing `let` * Hide redundant E0308 on `while let` missing `let` * Point at binding definition when possible on invalid assignment * do not point at closure twice * do not suggest `if let` for literals in lhs * account for parameter types
Diffstat (limited to 'compiler/rustc_ast_lowering/src')
| -rw-r--r-- | compiler/rustc_ast_lowering/src/expr.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index a0a63620c08..9c579209fe5 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -915,14 +915,22 @@ impl<'hir> LoweringContext<'_, 'hir> { ); } if !self.sess.features_untracked().destructuring_assignment { - feature_err( + let mut err = feature_err( &self.sess.parse_sess, sym::destructuring_assignment, eq_sign_span, "destructuring assignments are unstable", - ) - .span_label(lhs.span, "cannot assign to this expression") - .emit(); + ); + err.span_label(lhs.span, "cannot assign to this expression"); + if self.is_in_loop_condition { + err.span_suggestion_verbose( + lhs.span.shrink_to_lo(), + "you might have meant to use pattern destructuring", + "let ".to_string(), + rustc_errors::Applicability::MachineApplicable, + ); + } + err.emit(); } let mut assignments = vec![]; |
