about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChayim Refael Friedman <chayimfr@gmail.com>2025-09-15 06:02:57 +0000
committerGitHub <noreply@github.com>2025-09-15 06:02:57 +0000
commit3c82a25860547ece12081be3e2df7caff6bfd0ca (patch)
treeaa2310fad0621e38713860cd0fbfd70fb264d6bf
parentc88fb5036a840d91c10b8e03e09893cb04eae56e (diff)
parentf40e71c9de3d5d1075fa9fd94fccdd6126ae1ad4 (diff)
downloadrust-3c82a25860547ece12081be3e2df7caff6bfd0ca.tar.gz
rust-3c82a25860547ece12081be3e2df7caff6bfd0ca.zip
Merge pull request #20667 from ChayimFriedman2/ns-cleanup2
internal: Add Regression Test For The One And The Only Issue #5514
-rw-r--r--src/tools/rust-analyzer/crates/hir-ty/src/tests/regression/new_solver.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/tests/regression/new_solver.rs b/src/tools/rust-analyzer/crates/hir-ty/src/tests/regression/new_solver.rs
index f559230fee3..82d670cef2b 100644
--- a/src/tools/rust-analyzer/crates/hir-ty/src/tests/regression/new_solver.rs
+++ b/src/tools/rust-analyzer/crates/hir-ty/src/tests/regression/new_solver.rs
@@ -129,6 +129,40 @@ trait T2: Sized {
 }
 
 #[test]
+fn regression_type_checker_does_not_eagerly_select_predicates_from_where_clauses() {
+    // This was a very long standing issue (#5514) with a lot of duplicates, that was
+    // fixed by the switch to the new trait solver, so it deserves a long name and a
+    // honorable mention.
+    check_infer(
+        r#"
+//- minicore: from
+
+struct Foo;
+impl Foo {
+    fn method(self) -> i32 { 0 }
+}
+
+fn f<T: Into<Foo>>(u: T) {
+    let x = u.into();
+    x.method();
+}
+    "#,
+        expect![[r#"
+            38..42 'self': Foo
+            51..56 '{ 0 }': i32
+            53..54 '0': i32
+            79..80 'u': T
+            85..126 '{     ...d(); }': ()
+            95..96 'x': Foo
+            99..100 'u': T
+            99..107 'u.into()': Foo
+            113..114 'x': Foo
+            113..123 'x.method()': i32
+        "#]],
+    );
+}
+
+#[test]
 fn opaque_generics() {
     check_infer(
         r#"