Auto merge of #85102 - estebank:point-at-assignment, r=oli-obk
Diagnostic tweaks * On type mismatch caused by assignment, point at the source of the expectation * Hide redundant errors * Suggest `while let` when `let` is missing in some cases
This commit is contained in:
commit
9adfd9db78
40 changed files with 324 additions and 116 deletions
|
@ -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![];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue