]> git.proxmox.com Git - rustc.git/blame - src/test/ui/impl-trait/auto-trait-leak2.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / impl-trait / auto-trait-leak2.rs
CommitLineData
94b46f34
XL
1use std::cell::Cell;
2use std::rc::Rc;
3
4// Fast path, main can see the concrete type returned.
5fn before() -> impl Fn(i32) {
923072b8
FG
6//~^ NOTE within this `impl Fn
7//~| NOTE within the type `impl Fn
8//~| NOTE expansion of desugaring
94b46f34 9 let p = Rc::new(Cell::new(0));
923072b8 10 move |x| p.set(x) //~ NOTE used within this closure
94b46f34
XL
11}
12
13fn send<T: Send>(_: T) {}
923072b8
FG
14//~^ NOTE required by a bound
15//~| NOTE required by a bound
16//~| NOTE required by this bound
17//~| NOTE required by this bound
94b46f34
XL
18
19fn main() {
20 send(before());
1b1a35ee 21 //~^ ERROR `Rc<Cell<i32>>` cannot be sent between threads safely
923072b8
FG
22 //~| NOTE `Rc<Cell<i32>>` cannot be sent between threads safely
23 //~| NOTE required by a bound
94b46f34
XL
24
25 send(after());
1b1a35ee 26 //~^ ERROR `Rc<Cell<i32>>` cannot be sent between threads safely
923072b8
FG
27 //~| NOTE `Rc<Cell<i32>>` cannot be sent between threads safely
28 //~| NOTE required by a bound
94b46f34
XL
29}
30
31// Deferred path, main has to wait until typeck finishes,
32// to check if the return type of after is Send.
33fn after() -> impl Fn(i32) {
923072b8
FG
34//~^ NOTE within this `impl Fn(i32)`
35//~| NOTE in this expansion
36//~| NOTE appears within the type
94b46f34 37 let p = Rc::new(Cell::new(0));
923072b8 38 move |x| p.set(x) //~ NOTE used within this closure
94b46f34 39}