]> git.lizzy.rs Git - rust.git/blob - src/test/ui/methods/method-trait-object-with-hrtb.rs
move an `assert!` to the right place
[rust.git] / src / test / ui / methods / method-trait-object-with-hrtb.rs
1 // build-pass (FIXME(62277): could be check-pass?)
2
3 // Check that method probing ObjectCandidate works in the presence of
4 // auto traits and/or HRTBs.
5
6 mod internal {
7     pub trait MyObject<'a> {
8         type Output;
9
10         fn foo(&self) -> Self::Output;
11     }
12
13     impl<'a> MyObject<'a> for () {
14         type Output = &'a u32;
15
16         fn foo(&self) -> Self::Output { &4 }
17     }
18 }
19
20 fn t1(d: &dyn for<'a> internal::MyObject<'a, Output=&'a u32>) {
21     d.foo();
22 }
23
24 fn t2(d: &dyn internal::MyObject<'static, Output=&'static u32>) {
25     d.foo();
26 }
27
28 fn t3(d: &(dyn for<'a> internal::MyObject<'a, Output=&'a u32> + Sync)) {
29     d.foo();
30 }
31
32 fn t4(d: &(dyn internal::MyObject<'static, Output=&'static u32> + Sync)) {
33     d.foo();
34 }
35
36 fn main() {
37     t1(&());
38     t2(&());
39     t3(&());
40     t4(&());
41 }