From 312d6b8e9afce578fd5bd89b3c73153fe0be7539 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 10 Nov 2022 20:21:13 +0000 Subject: [PATCH] Don't emit coerce suggestions for a type into itself --- compiler/rustc_hir_typeck/src/demand.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs index 7f78f5fb8a7..602e0a904f8 100644 --- a/compiler/rustc_hir_typeck/src/demand.rs +++ b/compiler/rustc_hir_typeck/src/demand.rs @@ -30,6 +30,10 @@ pub fn emit_coerce_suggestions( expected_ty_expr: Option<&'tcx hir::Expr<'tcx>>, error: Option>, ) { + if expr_ty == expected { + return; + } + self.annotate_expected_due_to_let_ty(err, expr, error); // Use `||` to give these suggestions a precedence -- 2.44.0