]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.rs
Rollup merge of #106644 - alexcrichton:update-wasi-toolchain, r=cuviper
[rust.git] / tests / ui / borrowck / borrowck-borrowed-uniq-rvalue-2.rs
1 struct Defer<'a> {
2     x: &'a [&'a str],
3 }
4
5 impl<'a> Drop for Defer<'a> {
6     fn drop(&mut self) {
7         unsafe {
8             println!("{:?}", self.x);
9         }
10     }
11 }
12
13 fn defer<'r>(x: &'r [&'r str]) -> Defer<'r> {
14     Defer {
15         x: x
16     }
17 }
18
19 fn main() {
20     let x = defer(&vec!["Goodbye", "world!"]); //~ ERROR temporary value dropped while borrowed
21     x.x[0];
22 }