]> git.lizzy.rs Git - rust.git/blob - tests/ui/chalkify/type_inference.rs
Auto merge of #106711 - albertlarsan68:use-ci-llvm-when-lld, r=jyn514
[rust.git] / tests / ui / chalkify / type_inference.rs
1 // compile-flags: -Z trait-solver=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     // FIXME(chalk): order of these two errors is non-deterministic,
22     // so let's just hide one for now
23     //only_foo(x); // ERROR the trait bound `f64: Foo` is not satisfied
24
25     // Here we have two solutions so we get back the behavior of the old-style
26     // trait solver.
27     only_bar(x); //~ ERROR the trait bound `{float}: Bar` is not satisfied
28 }