]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs
Imported Upstream version 1.1.0+dfsg1
[rustc.git] / src / test / compile-fail / borrowck-borrowed-uniq-rvalue-2.rs
CommitLineData
223e47cc
LB
1// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
1a4d82fc
JJ
11struct defer<'a> {
12 x: &'a [&'a str],
223e47cc
LB
13}
14
1a4d82fc
JJ
15impl<'a> Drop for defer<'a> {
16 fn drop(&mut self) {
223e47cc 17 unsafe {
1a4d82fc 18 println!("{:?}", self.x);
223e47cc
LB
19 }
20 }
21}
22
23fn defer<'r>(x: &'r [&'r str]) -> defer<'r> {
24 defer {
25 x: x
26 }
27}
28
29fn main() {
85aaf69f 30 let x = defer(&vec!("Goodbye", "world!"));
1a4d82fc 31 //~^ ERROR borrowed value does not live long enough
970d7e83 32 x.x[0];
223e47cc 33}