]> git.lizzy.rs Git - rust.git/blob - src/test/ui/no-send-res-ports.rs
Auto merge of #54720 - davidtwco:issue-51191, r=nikomatsakis
[rust.git] / src / test / ui / no-send-res-ports.rs
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
11 use std::thread;
12 use std::rc::Rc;
13
14 #[derive(Debug)]
15 struct Port<T>(Rc<T>);
16
17 fn main() {
18     #[derive(Debug)]
19     struct foo {
20       _x: Port<()>,
21     }
22
23     impl Drop for foo {
24         fn drop(&mut self) {}
25     }
26
27     fn foo(x: Port<()>) -> foo {
28         foo {
29             _x: x
30         }
31     }
32
33     let x = foo(Port(Rc::new(())));
34
35     thread::spawn(move|| {
36         //~^ ERROR `std::rc::Rc<()>` cannot be sent between threads safely
37         let y = x;
38         println!("{:?}", y);
39     });
40 }