rust/tests/ui/borrowck/borrowck-uniq-via-ref.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

50 lines
649 B
Rust
Raw Normal View History

// run-pass
#![allow(dead_code)]
// pretty-expanded FIXME #23616
2013-03-07 03:09:17 +00:00
struct Rec {
f: Box<isize>,
2013-03-07 03:09:17 +00:00
}
struct Outer {
f: Inner
}
struct Inner {
g: Innermost
}
struct Innermost {
h: Box<isize>,
2013-03-07 03:09:17 +00:00
}
fn borrow(_v: &isize) {}
fn box_mut(v: &mut Box<isize>) {
borrow(&**v); // OK: &mut -> &imm
}
2013-03-07 03:09:17 +00:00
fn box_mut_rec(v: &mut Rec) {
borrow(&*v.f); // OK: &mut -> &imm
}
2013-03-07 03:09:17 +00:00
fn box_mut_recs(v: &mut Outer) {
borrow(&*v.f.g.h); // OK: &mut -> &imm
}
fn box_imm(v: &Box<isize>) {
borrow(&**v); // OK
}
2013-03-07 03:09:17 +00:00
fn box_imm_rec(v: &Rec) {
borrow(&*v.f); // OK
}
2013-03-07 03:09:17 +00:00
fn box_imm_recs(v: &Outer) {
borrow(&*v.f.g.h); // OK
}
pub fn main() {
}