]> git.lizzy.rs Git - rust.git/blob - src/test/ui/span/issue-29106.rs
Rollup merge of #46751 - michaelwoerister:c-incremental, r=alexcrichton
[rust.git] / src / test / ui / span / issue-29106.rs
1 // Copyright 2015 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
11 use std::rc::Rc;
12 use std::sync::Arc;
13
14 struct Foo<'a>(&'a String);
15
16 impl<'a> Drop for Foo<'a> {
17     fn drop(&mut self) {
18         println!("{:?}", self.0);
19     }
20 }
21
22 fn main() {
23     {
24         let (y, x);
25         x = "alive".to_string();
26         y = Arc::new(Foo(&x));
27     }
28     //~^^ ERROR `x` does not live long enough
29
30     {
31         let (y, x);
32         x = "alive".to_string();
33         y = Rc::new(Foo(&x));
34     }
35     //~^^ ERROR `x` does not live long enough
36 }