]>
Commit | Line | Data |
---|---|---|
b7449926 | 1 | // run-pass |
0bf4aa26 | 2 | #![allow(dead_code)] |
54a0048b | 3 | // Test a corner case of LUB coercion. In this case, one arm of the |
a7813a04 | 4 | // match requires a deref coercion and the other doesn't, and there |
54a0048b SL |
5 | // is an extra `&` on the `rc`. We want to be sure that the lifetime |
6 | // assigned to this `&rc` value is not `'a` but something smaller. In | |
7 | // other words, the type from `rc` is `&'a Rc<String>` and the type | |
8 | // from `&rc` should be `&'x &'a Rc<String>`, where `'x` is something | |
9 | // small. | |
10 | ||
11 | use std::rc::Rc; | |
12 | ||
13 | #[derive(Clone)] | |
14 | enum CachedMir<'mir> { | |
15 | Ref(&'mir String), | |
16 | Owned(Rc<String>), | |
17 | } | |
18 | ||
19 | impl<'mir> CachedMir<'mir> { | |
20 | fn get_ref<'a>(&'a self) -> &'a String { | |
21 | match *self { | |
22 | CachedMir::Ref(r) => r, | |
23 | CachedMir::Owned(ref rc) => &rc, | |
24 | } | |
25 | } | |
26 | } | |
27 | ||
28 | fn main() { } |