Skip to content

Commit 622b267

Browse files
Merge pull request #20667 from ChayimFriedman2/ns-cleanup2
internal: Add Regression Test For The One And The Only Issue #5514
2 parents 6f9a6ba + b9797aa commit 622b267

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

crates/hir-ty/src/tests/regression/new_solver.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,40 @@ trait T2: Sized {
128128
);
129129
}
130130

131+
#[test]
132+
fn regression_type_checker_does_not_eagerly_select_predicates_from_where_clauses() {
133+
// This was a very long standing issue (#5514) with a lot of duplicates, that was
134+
// fixed by the switch to the new trait solver, so it deserves a long name and a
135+
// honorable mention.
136+
check_infer(
137+
r#"
138+
//- minicore: from
139+
140+
struct Foo;
141+
impl Foo {
142+
fn method(self) -> i32 { 0 }
143+
}
144+
145+
fn f<T: Into<Foo>>(u: T) {
146+
let x = u.into();
147+
x.method();
148+
}
149+
"#,
150+
expect![[r#"
151+
38..42 'self': Foo
152+
51..56 '{ 0 }': i32
153+
53..54 '0': i32
154+
79..80 'u': T
155+
85..126 '{ ...d(); }': ()
156+
95..96 'x': Foo
157+
99..100 'u': T
158+
99..107 'u.into()': Foo
159+
113..114 'x': Foo
160+
113..123 'x.method()': i32
161+
"#]],
162+
);
163+
}
164+
131165
#[test]
132166
fn opaque_generics() {
133167
check_infer(

0 commit comments

Comments
 (0)