2012-12-10 19:32:48 -06:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2014-05-05 20:56:44 -05:00
|
|
|
|
2015-03-22 15:13:15 -05:00
|
|
|
// pretty-expanded FIXME #23616
|
|
|
|
|
2013-03-06 21:09:17 -06:00
|
|
|
struct Rec {
|
2014-05-05 20:56:44 -05:00
|
|
|
f: Box<int>,
|
2013-03-06 21:09:17 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Outer {
|
|
|
|
f: Inner
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Inner {
|
|
|
|
g: Innermost
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Innermost {
|
2014-05-05 20:56:44 -05:00
|
|
|
h: Box<int>,
|
2013-03-06 21:09:17 -06:00
|
|
|
}
|
|
|
|
|
2012-04-26 18:02:01 -05:00
|
|
|
fn borrow(_v: &int) {}
|
|
|
|
|
2014-05-05 20:56:44 -05:00
|
|
|
fn box_mut(v: &mut Box<int>) {
|
2014-07-07 18:35:15 -05:00
|
|
|
borrow(&**v); // OK: &mut -> &imm
|
2012-04-26 18:02:01 -05:00
|
|
|
}
|
|
|
|
|
2013-03-06 21:09:17 -06:00
|
|
|
fn box_mut_rec(v: &mut Rec) {
|
2014-07-07 18:35:15 -05:00
|
|
|
borrow(&*v.f); // OK: &mut -> &imm
|
2012-04-26 18:02:01 -05:00
|
|
|
}
|
|
|
|
|
2013-03-06 21:09:17 -06:00
|
|
|
fn box_mut_recs(v: &mut Outer) {
|
2014-07-07 18:35:15 -05:00
|
|
|
borrow(&*v.f.g.h); // OK: &mut -> &imm
|
2012-04-26 18:02:01 -05:00
|
|
|
}
|
|
|
|
|
2014-05-05 20:56:44 -05:00
|
|
|
fn box_imm(v: &Box<int>) {
|
2014-07-07 18:35:15 -05:00
|
|
|
borrow(&**v); // OK
|
2012-04-26 18:02:01 -05:00
|
|
|
}
|
|
|
|
|
2013-03-06 21:09:17 -06:00
|
|
|
fn box_imm_rec(v: &Rec) {
|
2014-07-07 18:35:15 -05:00
|
|
|
borrow(&*v.f); // OK
|
2012-04-26 18:02:01 -05:00
|
|
|
}
|
|
|
|
|
2013-03-06 21:09:17 -06:00
|
|
|
fn box_imm_recs(v: &Outer) {
|
2014-07-07 18:35:15 -05:00
|
|
|
borrow(&*v.f.g.h); // OK
|
2012-04-26 18:02:01 -05:00
|
|
|
}
|
|
|
|
|
2013-09-25 02:43:37 -05:00
|
|
|
pub fn main() {
|
2012-04-26 18:02:01 -05:00
|
|
|
}
|