]> git.lizzy.rs Git - rust.git/blob - tests/ui/chalkify/inherent_impl.rs
Auto merge of #106711 - albertlarsan68:use-ci-llvm-when-lld, r=jyn514
[rust.git] / tests / ui / chalkify / inherent_impl.rs
1 // run-pass
2 // compile-flags: -Z trait-solver=chalk
3
4 trait Foo { }
5
6 impl Foo for i32 { }
7
8 struct S<T: Foo> {
9     x: T,
10 }
11
12 fn only_foo<T: Foo>(_x: &T) { }
13
14 impl<T> S<T> {
15     // Test that we have the correct environment inside an inherent method.
16     fn dummy_foo(&self) {
17         only_foo(&self.x)
18     }
19 }
20
21 trait Bar { }
22 impl Bar for u32 { }
23
24 fn only_bar<T: Bar>() { }
25
26 impl<T> S<T> {
27     // Test that the environment of `dummy_bar` adds up with the environment
28     // of the inherent impl.
29     fn dummy_bar<U: Bar>(&self) {
30         only_foo(&self.x);
31         only_bar::<U>();
32     }
33 }
34
35 fn main() {
36     let s = S {
37         x: 5,
38     };
39
40     s.dummy_bar::<u32>();
41     s.dummy_foo();
42 }