]> git.lizzy.rs Git - rust.git/blob - src/test/ui/chalkify/type_inference.rs
Rollup merge of #57107 - mjbshaw:thread_local_test, r=nikomatsakis
[rust.git] / src / test / ui / chalkify / type_inference.rs
1 // compile-flags: -Z chalk
2
3 trait Foo { }
4 impl Foo for i32 { }
5
6 trait Bar { }
7 impl Bar for i32 { }
8 impl Bar for u32 { }
9
10 fn only_foo<T: Foo>(_x: T) { }
11
12 fn only_bar<T: Bar>(_x: T) { }
13
14 fn main() {
15     let x = 5.0;
16
17     // The only type which implements `Foo` is `i32`, so the chalk trait solver
18     // is expecting a variable of type `i32`. This behavior differs from the
19     // old-style trait solver. I guess this will change, that's why I'm
20     // adding that test.
21     only_foo(x); //~ ERROR mismatched types
22
23     // Here we have two solutions so we get back the behavior of the old-style
24     // trait solver.
25     only_bar(x); //~ ERROR the trait bound `{float}: Bar` is not satisfied
26 }