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
This commit is contained in:
parent
862962b90e
commit
37a11a96a1
39 changed files with 297 additions and 117 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