diff --git a/compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs b/compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs index 0373035a09ad8..beacf301cae27 100644 --- a/compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs +++ b/compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs @@ -192,6 +192,7 @@ impl ItemLikeVisitor<'v> for InherentOverlapChecker<'tcx> { .collect::>(); // Sort the id list so that the algorithm is deterministic ids.sort_unstable(); + ids.dedup(); let ids = ids; match &ids[..] { // Create a new connected region diff --git a/src/test/ui/inherent-impls-overlap-check/no-overlap.rs b/src/test/ui/inherent-impls-overlap-check/no-overlap.rs index 341bfc7b605fc..450e6d4202c07 100644 --- a/src/test/ui/inherent-impls-overlap-check/no-overlap.rs +++ b/src/test/ui/inherent-impls-overlap-check/no-overlap.rs @@ -31,4 +31,23 @@ repeat::repeat_with_idents!(impl Bar { fn IDENT() {} }); impl Bar { fn foo() {} } impl Bar { fn foo() {} } +// Regression test for issue #89820: + +impl Bar { + pub fn a() {} + pub fn aa() {} +} + +impl Bar { + pub fn b() {} + pub fn bb() {} +} + +impl Bar { + pub fn a() {} + pub fn aa() {} + pub fn bb() {} + pub fn b() {} +} + fn main() {}