From 34e9e6dff1449bddd9a66e744423797e01aec43c Mon Sep 17 00:00:00 2001 From: Daniel Xu Date: Fri, 8 Jul 2022 21:03:03 -0500 Subject: Fix duplicated type annotation suggestion Before, there was more or less duplicated suggestions to add type hints. Fix by clearing more generic suggestions when a more specific suggestion is possible. This fixes #93506 . --- compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'compiler/rustc_trait_selection/src/traits') diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index aa1c9136289..875831cf78b 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -2074,6 +2074,9 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { // | // = note: cannot satisfy `_: Tt` + // Clear any more general suggestions in favor of our specific one + err.clear_suggestions(); + err.span_suggestion_verbose( span.shrink_to_hi(), &format!( -- cgit 1.4.1-3-g733a5