Change:
I thought this code would provide one of the nice suggestions that implemented in , but it doesn't. (By the way, making a reference to will give an ICE because of .) () Errors:
Reopening as per
This is fixed in beta now: It is still quite verbose (too many errors), but we lead people in the right direction.

Discussion:
let mut err = self.demand_suptype_diag(expr.span, expected_ty, actual_ty).unwrap(); let lhs_ty = self.check_expr(&lhs); let rhs_ty = self.check_expr(&rhs); <del> if self.can_coerce(lhs_ty, rhs_ty) { if !lhs.is_syntactic_place_expr() { // Do not suggest `if let x = y` as `==` is way more likely to be the intention. if let hir::Node::Expr(hir::Expr { kind: ExprKind::Match(_, _, hir::MatchSource::IfDesugar { .. }), .. }) = self.tcx.hir().get( self.tcx.hir().get_parent_node(self.tcx.hir().get_parent_node(expr.hir_id)), ) { // Likely `if let` intended. err.span_suggestion_verbose( expr.span.shrink_to_lo(), "you might have meant to use pattern matching", "let ".to_string(), Applicability::MaybeIncorrect, ); } </del> <ins> let (applicability, eq) = if self.can_coerce(rhs_ty, lhs_ty) { (Applicability::MachineApplicable, true) } else { (Applicability::MaybeIncorrect, false) }; if !lhs.is_syntactic_place_expr() { // Do not suggest `if let x = y` as `==` is way more likely to be the intention. if let hir::Node::Expr(hir::Expr { kind: ExprKind::Match( _, _, hir::MatchSource::IfDesugar { .. } | hir::MatchSource::WhileDesugar, ), .. }) = self.tcx.hir().get( self.tcx.hir().get_parent_node(self.tcx.hir().get_parent_node(expr.hir_id)), ) { // Likely `if let` intended. err.span_suggestion_verbose( expr.span.shrink_to_lo(), "you might have meant to use pattern matching", "let ".to_string(), applicability, ); </ins> } <ins> } if eq { </ins> err.span_suggestion_verbose( *span, "you might have meant to compare for equality", "==".to_string(), <del> Applicability::MaybeIncorrect, </del> <ins> applicability, </ins> ); <del> } else { // Do this to cause extra errors about the assignment. let lhs_ty = self.check_expr_with_needs(&lhs, Needs::MutPlace); let _ = self.check_expr_coercable_to_type(&rhs, lhs_ty, Some(lhs)); </del> } if self.sess().if_let_suggestions.borrow().get(&expr.span).is_some() {

<ins> fn main() { let value = [7u8]; while Some(0) = value.get(0) { //~ ERROR mismatched types //~^ NOTE expected `bool`, found `()` //~| HELP you might have meant to use pattern matching } } </ins>

<ins> error[E0308]: mismatched types --> $DIR/issue-77218.rs:3:11 | LL |     while Some(0) = value.get(0) { |           ^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()` | help: you might have meant to use pattern matching | LL |     while let Some(0) = value.get(0) { |           ^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. </ins>

if Some(x) = foo {} //~ ERROR cannot find value `x` in this scope if Some(foo) = bar {} //~ ERROR mismatched types if 3 = foo {} //~ ERROR mismatched types <del> //~^ ERROR mismatched types </del> if Some(3) = foo {} //~ ERROR mismatched types }

|                  ^^ error[E0308]: mismatched types <del> --> $DIR/if-let-typo.rs:6:12 | LL |     if 3 = foo {} |            ^^^ expected integer, found enum `Option` | = note: expected type `{integer}` found enum `Option<{integer}>` error[E0308]: mismatched types </del> --> $DIR/if-let-typo.rs:6:8 | LL |     if 3 = foo {} |        ^^^^^^^ expected `bool`, found `()` <ins> | help: you might have meant to use pattern matching | LL |     if let 3 = foo {} |        ^^^ </ins> error[E0308]: mismatched types <del> --> $DIR/if-let-typo.rs:8:8 </del> <ins> --> $DIR/if-let-typo.rs:7:8 </ins> | LL |     if Some(3) = foo {} |        ^^^^^^^^^^^^^ expected `bool`, found `()`

LL |     if Some(3) == foo {} |                ^^ <del> error: aborting due to 5 previous errors </del> <ins> error: aborting due to 4 previous errors </ins> Some errors have detailed explanations: E0308, E0425. For more information about an error, try `rustc --explain E0308`.