]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/pass/validation_lifetime_resolution.rs
Auto merge of #104915 - weihanglo:update-cargo, r=ehuss
[rust.git] / src / tools / miri / tests / pass / validation_lifetime_resolution.rs
1 trait Id {
2     type Out;
3
4     fn id(self) -> Self::Out;
5 }
6
7 impl<'a> Id for &'a mut i32 {
8     type Out = &'a mut i32;
9
10     fn id(self) -> Self {
11         self
12     }
13 }
14
15 impl<'a> Id for &'a mut u32 {
16     type Out = &'a mut u32;
17
18     fn id(self) -> Self {
19         self
20     }
21 }
22
23 fn foo<T>(mut x: T)
24 where
25     for<'a> &'a mut T: Id,
26 {
27     let x = &mut x;
28     let _y = x.id();
29     // Inspecting the trace should show that `_y` has a type involving a local lifetime, when it gets validated.
30     // Unfortunately, there doesn't seem to be a way to actually have a test fail if it does not have the right
31     // type. Currently, this is *not* working correctly; see <https://github.com/rust-lang/miri/issues/298>.
32 }
33
34 fn main() {
35     foo(3)
36 }