about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRyo Yoshida <low.ryoshida@gmail.com>2022-12-14 21:56:55 +0900
committerRyo Yoshida <low.ryoshida@gmail.com>2022-12-14 23:07:43 +0900
commitbb99d2a6fbcbd5db75a004fa4135413b24ebe3dc (patch)
treee7ad7cb5497f50e91287c8a94671212f9a9b079f
parent4596847a88abb0d5077c5111c3093e724673d7a0 (diff)
downloadrust-bb99d2a6fbcbd5db75a004fa4135413b24ebe3dc.tar.gz
rust-bb99d2a6fbcbd5db75a004fa4135413b24ebe3dc.zip
fix: resolve all inference vars in `InferenceResult::assoc_resolutions`
-rw-r--r--crates/hir-ty/src/infer.rs3
-rw-r--r--crates/ide/src/hover/tests.rs31
2 files changed, 34 insertions, 0 deletions
diff --git a/crates/hir-ty/src/infer.rs b/crates/hir-ty/src/infer.rs
index a42f8a0ac02..7cf4fb10506 100644
--- a/crates/hir-ty/src/infer.rs
+++ b/crates/hir-ty/src/infer.rs
@@ -535,6 +535,9 @@ impl<'a> InferenceContext<'a> {
         for (_, subst) in result.method_resolutions.values_mut() {
             *subst = table.resolve_completely(subst.clone());
         }
+        for (_, subst) in result.assoc_resolutions.values_mut() {
+            *subst = table.resolve_completely(subst.clone());
+        }
         for adjustment in result.expr_adjustments.values_mut().flatten() {
             adjustment.target = table.resolve_completely(adjustment.target.clone());
         }
diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs
index 62404afc4b7..3580c457026 100644
--- a/crates/ide/src/hover/tests.rs
+++ b/crates/ide/src/hover/tests.rs
@@ -4080,6 +4080,37 @@ const FOO$0: f64 = 1.0f64;
 }
 
 #[test]
+fn hover_const_eval_in_generic_trait() {
+    // Doesn't compile, but we shouldn't crash.
+    check(
+        r#"
+trait Trait<T> {
+    const FOO: bool = false;
+}
+struct S<T>(T);
+impl<T> Trait<T> for S<T> {
+    const FOO: bool = true;
+}
+
+fn test() {
+    S::FOO$0;
+}
+"#,
+        expect![[r#"
+            *FOO*
+
+            ```rust
+            test
+            ```
+
+            ```rust
+            const FOO: bool = true
+            ```
+        "#]],
+    );
+}
+
+#[test]
 fn hover_const_pat() {
     check(
         r#"