]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/regions/regions-lub-ref-ref-rc.rs
New upstream version 1.33.0+dfsg1
[rustc.git] / src / test / run-pass / regions / regions-lub-ref-ref-rc.rs
CommitLineData
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
11use std::rc::Rc;
12
13#[derive(Clone)]
14enum CachedMir<'mir> {
15 Ref(&'mir String),
16 Owned(Rc<String>),
17}
18
19impl<'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
28fn main() { }