]> git.proxmox.com Git - rustc.git/blame - src/test/ui/no-send-res-ports.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / no-send-res-ports.rs
CommitLineData
85aaf69f 1use std::thread;
1a4d82fc
JJ
2use std::rc::Rc;
3
85aaf69f 4#[derive(Debug)]
1a4d82fc 5struct Port<T>(Rc<T>);
223e47cc
LB
6
7fn main() {
85aaf69f 8 #[derive(Debug)]
0731742a 9 struct Foo {
223e47cc
LB
10 _x: Port<()>,
11 }
12
0731742a 13 impl Drop for Foo {
1a4d82fc 14 fn drop(&mut self) {}
223e47cc
LB
15 }
16
0731742a
XL
17 fn foo(x: Port<()>) -> Foo {
18 Foo {
223e47cc
LB
19 _x: x
20 }
21 }
22
1a4d82fc 23 let x = foo(Port(Rc::new(())));
223e47cc 24
85aaf69f 25 thread::spawn(move|| {
1b1a35ee 26 //~^ ERROR `Rc<()>` cannot be sent between threads safely
1a4d82fc
JJ
27 let y = x;
28 println!("{:?}", y);
29 });
223e47cc 30}