That's definitely a bug. I filed a bug report it about it for you here: https://github.com/mozilla/rust/issues/4760
On Fri, Feb 1, 2013 at 8:13 PM, Alexander Stavonin <[email protected]>wrote: > Looks like I'd like to do something extremely difficult %) > > 7 impl <T>(T, T): TupleVal<T> { > 8 fn _1(&self) -> &self/T { > 9 let &(ref a, _) = self; > 10 a > 11 } > > > Assertion failed: (getOperand(0)->getType() == > cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must > be a pointer to Val type!"), function AssertOK, file > /Volumes/Home/astavonin/Projects/rust/src/llvm/lib/VMCore/Instructions.cpp, > line 1062. > zsh: abort rustc test.rs > > > On Feb 2, 2013, at 12:47 PM, Niko Matsakis <[email protected]> wrote: > > > Sorry, I told you wrong. When you write: > > > > let &(a, _) = self; > > &a > > > > You are actually copying the value out of `self` and into the stack > variable `a`. The error message is telling you that you are returning a > pointer into your stack frame, which is of course unsafe. > > > > What you actually want is this: > > > > let &(ref a, _) = self; > > a > > > > The `ref` keyword indicates that the `a` variable should be a pointer > into the value being matched (here, `self`) and not copied out. > > > > > > Niko > > _______________________________________________ > 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
