about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorbohan <bohan-zhang@foxmail.com>2023-05-23 22:00:07 +0800
committerbohan <bohan-zhang@foxmail.com>2023-05-27 00:52:07 +0800
commitf78369b3afedd4d662cc6f92eee825bc94bf1e8e (patch)
treec6cead09e9947da29a0500e4190ab230054cdecf /compiler
parent1221e43bdf413f7c405e9b17ef19d76c88222098 (diff)
downloadrust-f78369b3afedd4d662cc6f92eee825bc94bf1e8e.tar.gz
rust-f78369b3afedd4d662cc6f92eee825bc94bf1e8e.zip
fix: dedup `static_candidates` before report
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_hir_typeck/src/method/suggest.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs
index 8555c20204a..9ee967dc7a9 100644
--- a/compiler/rustc_hir_typeck/src/method/suggest.rs
+++ b/compiler/rustc_hir_typeck/src/method/suggest.rs
@@ -473,6 +473,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         let mut custom_span_label = false;
 
         let static_candidates = &mut no_match_data.static_candidates;
+
+        // `static_candidates` may have same candidates appended by
+        // inherent and extension, which may result in incorrect
+        // diagnostic.
+        static_candidates.dedup();
+
         if !static_candidates.is_empty() {
             err.note(
                 "found the following associated functions; to be used as methods, \