This is actually bug 3148: https://github.com/mozilla/rust/issues/3148
You can use explicit type declarations as a workaround for the time being. Your rewrite also works in the same manner: it overcomes a shortcoming in the region inferencer. I hope we can fix this soon, it's not terribly difficult.
Niko Steven Blenkinsop wrote:
Turns out the issue was borrowing from a reborrowed value. i.e. this doesn't work:fn rereborrow(v: &r/int) -> &r/int { &*&*v } I've filed an issue: https://github.com/mozilla/rust/issues/4285Incidentally, I can make my original code work by eliminating the intermediate borrow:struct T1 { value: int } struct T2 { t1: option::Option<~T1> } fn value(t2: &r/T2, def: &r/int) -> &r/int { match t2.t1 { Some(~T1{value: ref value}) => value, None => def } } fn main() { let t2 = ~T2{ t1: Some(~T1{ value: 5 }) }; let def = ~0; io::println(fmt!("%d", *value(t2, def))); } _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
