]> git.proxmox.com Git - rustc.git/blob - src/test/ui/impl-trait/auto-trait-leak2.rs
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / src / test / ui / impl-trait / auto-trait-leak2.rs
1 use std::cell::Cell;
2 use std::rc::Rc;
3
4 // Fast path, main can see the concrete type returned.
5 fn before() -> impl Fn(i32) {
6 let p = Rc::new(Cell::new(0));
7 move |x| p.set(x)
8 }
9
10 fn send<T: Send>(_: T) {}
11
12 fn main() {
13 send(before());
14 //~^ ERROR `Rc<Cell<i32>>` cannot be sent between threads safely
15
16 send(after());
17 //~^ ERROR `Rc<Cell<i32>>` cannot be sent between threads safely
18 }
19
20 // Deferred path, main has to wait until typeck finishes,
21 // to check if the return type of after is Send.
22 fn after() -> impl Fn(i32) {
23 let p = Rc::new(Cell::new(0));
24 move |x| p.set(x)
25 }