rust/tests/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.rs

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

23 lines
375 B
Rust
Raw Normal View History

struct Defer<'a> {
x: &'a [&'a str],
}
impl<'a> Drop for Defer<'a> {
2013-09-17 01:18:07 +00:00
fn drop(&mut self) {
unsafe {
println!("{:?}", self.x);
}
}
}
fn defer<'r>(x: &'r [&'r str]) -> Defer<'r> {
Defer {
2012-09-05 22:58:43 +00:00
x: x
}
}
fn main() {
let x = defer(&vec!["Goodbye", "world!"]); //~ ERROR temporary value dropped while borrowed
2013-03-15 19:24:24 +00:00
x.x[0];
}