2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2018-09-25 21:51:35 +00:00
|
|
|
#![allow(dead_code)]
|
2016-03-17 13:47:58 +00:00
|
|
|
// Test a corner case of LUB coercion. In this case, one arm of the
|
2016-05-05 19:11:41 +00:00
|
|
|
// match requires a deref coercion and the other doesn't, and there
|
2016-03-17 13:47:58 +00:00
|
|
|
// is an extra `&` on the `rc`. We want to be sure that the lifetime
|
|
|
|
// assigned to this `&rc` value is not `'a` but something smaller. In
|
|
|
|
// other words, the type from `rc` is `&'a Rc<String>` and the type
|
|
|
|
// from `&rc` should be `&'x &'a Rc<String>`, where `'x` is something
|
|
|
|
// small.
|
|
|
|
|
|
|
|
use std::rc::Rc;
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
2019-05-17 21:55:04 +00:00
|
|
|
enum Cached<'mir> {
|
2016-03-17 13:47:58 +00:00
|
|
|
Ref(&'mir String),
|
|
|
|
Owned(Rc<String>),
|
|
|
|
}
|
|
|
|
|
2019-05-17 21:55:04 +00:00
|
|
|
impl<'mir> Cached<'mir> {
|
2016-03-17 13:47:58 +00:00
|
|
|
fn get_ref<'a>(&'a self) -> &'a String {
|
|
|
|
match *self {
|
2019-05-17 21:55:04 +00:00
|
|
|
Cached::Ref(r) => r,
|
|
|
|
Cached::Owned(ref rc) => &rc,
|
2016-03-17 13:47:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() { }
|