2018-09-04 10:05:53 +00:00
|
|
|
// run-pass
|
2018-09-25 21:51:35 +00:00
|
|
|
#![allow(dead_code)]
|
2014-05-06 01:56:44 +00:00
|
|
|
|
2015-03-22 20:13:15 +00:00
|
|
|
// pretty-expanded FIXME #23616
|
|
|
|
|
2013-03-07 03:09:17 +00:00
|
|
|
struct Rec {
|
2015-03-26 00:06:52 +00:00
|
|
|
f: Box<isize>,
|
2013-03-07 03:09:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Outer {
|
|
|
|
f: Inner
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Inner {
|
|
|
|
g: Innermost
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Innermost {
|
2015-03-26 00:06:52 +00:00
|
|
|
h: Box<isize>,
|
2013-03-07 03:09:17 +00:00
|
|
|
}
|
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
fn borrow(_v: &isize) {}
|
2012-04-26 23:02:01 +00:00
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
fn box_mut(v: &mut Box<isize>) {
|
2014-07-07 23:35:15 +00:00
|
|
|
borrow(&**v); // OK: &mut -> &imm
|
2012-04-26 23:02:01 +00:00
|
|
|
}
|
|
|
|
|
2013-03-07 03:09:17 +00:00
|
|
|
fn box_mut_rec(v: &mut Rec) {
|
2014-07-07 23:35:15 +00:00
|
|
|
borrow(&*v.f); // OK: &mut -> &imm
|
2012-04-26 23:02:01 +00:00
|
|
|
}
|
|
|
|
|
2013-03-07 03:09:17 +00:00
|
|
|
fn box_mut_recs(v: &mut Outer) {
|
2014-07-07 23:35:15 +00:00
|
|
|
borrow(&*v.f.g.h); // OK: &mut -> &imm
|
2012-04-26 23:02:01 +00:00
|
|
|
}
|
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
fn box_imm(v: &Box<isize>) {
|
2014-07-07 23:35:15 +00:00
|
|
|
borrow(&**v); // OK
|
2012-04-26 23:02:01 +00:00
|
|
|
}
|
|
|
|
|
2013-03-07 03:09:17 +00:00
|
|
|
fn box_imm_rec(v: &Rec) {
|
2014-07-07 23:35:15 +00:00
|
|
|
borrow(&*v.f); // OK
|
2012-04-26 23:02:01 +00:00
|
|
|
}
|
|
|
|
|
2013-03-07 03:09:17 +00:00
|
|
|
fn box_imm_recs(v: &Outer) {
|
2014-07-07 23:35:15 +00:00
|
|
|
borrow(&*v.f.g.h); // OK
|
2012-04-26 23:02:01 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 07:43:37 +00:00
|
|
|
pub fn main() {
|
2012-04-26 23:02:01 +00:00
|
|
|
}
|