about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
diff options
context:
space:
mode:
authorDaniel Xu <dxu@dxuuu.xyz>2022-07-08 21:03:03 -0500
committerDaniel Xu <dxu@dxuuu.xyz>2022-07-08 21:03:03 -0500
commit34e9e6dff1449bddd9a66e744423797e01aec43c (patch)
tree3fa4ba6ab1c5b3b8f83b698e480fca9f29ff2dff /compiler/rustc_trait_selection/src/traits
parent06754d8852bea286a3a76d373ccd17e66afb5a8b (diff)
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 .
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits')
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs3
1 files changed, 3 insertions, 0 deletions
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!(