]> git.lizzy.rs Git - rust.git/blob - tests/ui/span/issue-29106.rs
Rollup merge of #106441 - mllken:abstract-socket-noref, r=joshtriplett
[rust.git] / tests / ui / span / issue-29106.rs
1 use std::rc::Rc;
2 use std::sync::Arc;
3
4 struct Foo<'a>(&'a String);
5
6 impl<'a> Drop for Foo<'a> {
7     fn drop(&mut self) {
8         println!("{:?}", self.0);
9     }
10 }
11
12 fn main() {
13     {
14         let (y, x);
15         x = "alive".to_string();
16         y = Arc::new(Foo(&x));
17     }
18     //~^^ ERROR `x` does not live long enough
19
20     {
21         let (y, x);
22         x = "alive".to_string();
23         y = Rc::new(Foo(&x));
24     }
25     //~^^ ERROR `x` does not live long enough
26 }