]> git.lizzy.rs Git - rust.git/blob - tests/ui/async-await/issue-64130-1-sync.rs
Auto merge of #107843 - bjorn3:sync_cg_clif-2023-02-09, r=bjorn3
[rust.git] / tests / ui / async-await / issue-64130-1-sync.rs
1 // revisions: no_drop_tracking drop_tracking drop_tracking_mir
2 // [drop_tracking] compile-flags: -Zdrop-tracking
3 // [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir
4 #![feature(negative_impls)]
5 // edition:2018
6
7 // This tests the specialized async-await-specific error when futures don't implement an
8 // auto trait (which is specifically Sync) due to some type that was captured.
9
10 struct Foo;
11
12 impl !Sync for Foo {}
13
14 fn is_sync<T: Sync>(t: T) { }
15
16 async fn bar() {
17     let x = Foo;
18     baz().await;
19     drop(x);
20 }
21
22 async fn baz() { }
23
24 fn main() {
25     is_sync(bar());
26     //~^ ERROR future cannot be shared between threads safely
27 }