Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/hir-ty/src/lower.rs12
-rw-r--r--crates/hir-ty/src/tests/regression.rs28
2 files changed, 36 insertions, 4 deletions
diff --git a/crates/hir-ty/src/lower.rs b/crates/hir-ty/src/lower.rs
index 71a7db6559..a7b159a5c5 100644
--- a/crates/hir-ty/src/lower.rs
+++ b/crates/hir-ty/src/lower.rs
@@ -1869,10 +1869,14 @@ fn resolve_type_param_assoc_type_shorthand(
.skip_binder();
let args = EarlyBinder::bind(args).instantiate(interner, bounded_trait_ref.args);
let current_result = StoredEarlyBinder::bind((assoc_type, args.store()));
- if let Some(this_trait_resolution) = this_trait_resolution {
- return AssocTypeShorthandResolution::Ambiguous {
- sub_trait_resolution: Some(this_trait_resolution),
- };
+ if let Some(this_trait_resolution) = &this_trait_resolution {
+ if *this_trait_resolution == current_result {
+ continue;
+ } else {
+ return AssocTypeShorthandResolution::Ambiguous {
+ sub_trait_resolution: Some(this_trait_resolution.clone()),
+ };
+ }
} else if let Some(prev_resolution) = &supertraits_resolution {
if let AssocTypeShorthandResolution::Ambiguous {
sub_trait_resolution: Some(prev_resolution),
diff --git a/crates/hir-ty/src/tests/regression.rs b/crates/hir-ty/src/tests/regression.rs
index d3dfc44c22..a559ad9b91 100644
--- a/crates/hir-ty/src/tests/regression.rs
+++ b/crates/hir-ty/src/tests/regression.rs
@@ -2856,3 +2856,31 @@ fn foo<T: B>(v: T::T) {}
"#,
);
}
+
+#[test]
+fn regression_() {
+ check_types(
+ r#"
+//- minicore: fn
+trait Super {
+ type Assoc;
+ fn foo(self) -> Self::Assoc
+ where
+ Self: Sub,
+ { loop {} }
+}
+trait Sub: Super {}
+
+struct Struct;
+impl Super for Struct {
+ type Assoc = u8;
+}
+impl Sub for Struct {}
+
+fn foo() {
+ Struct.foo();
+ // ^^^^^^^^^^^^ u8
+}
+ "#,
+ );
+}