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 7f78f5fb8a7b..602e0a904f8b 100644 --- a/compiler/rustc_hir_typeck/src/demand.rs +++ b/compiler/rustc_hir_typeck/src/demand.rs @@ -30,6 +30,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { 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