-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #61138 - varkor:async-await-tests, r=cramertj
Move async/await tests to their own folder This moves run-pass and ui async/await tests to their own folder `src/test/ui/async-await` and organises some into subfolders. (It does not move rustdoc tests for async/await.) I also did some drive-by cleaning up of issues/error code tests into their own folders (which already existed). These are in separate commits, so easy to separate out if that's more desirable. r? @cramertj
- Loading branch information
Showing
112 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
src/test/run-pass/async-await.rs → src/test/ui/async-await/async-await.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// run-pass | ||
|
||
// edition:2018 | ||
// aux-build:arc_wake.rs | ||
|
||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions
2
src/test/run-pass/await-macro.rs → src/test/ui/async-await/await-macro.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// run-pass | ||
|
||
// edition:2018 | ||
// aux-build:arc_wake.rs | ||
|
||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// edition:2018 | ||
|
||
use std::sync::Arc; | ||
use std::task::{ | ||
Waker, RawWaker, RawWakerVTable, | ||
}; | ||
|
||
macro_rules! waker_vtable { | ||
($ty:ident) => { | ||
&RawWakerVTable::new( | ||
clone_arc_raw::<$ty>, | ||
wake_arc_raw::<$ty>, | ||
wake_by_ref_arc_raw::<$ty>, | ||
drop_arc_raw::<$ty>, | ||
) | ||
}; | ||
} | ||
|
||
pub trait ArcWake { | ||
fn wake(self: Arc<Self>); | ||
|
||
fn wake_by_ref(arc_self: &Arc<Self>) { | ||
arc_self.clone().wake() | ||
} | ||
|
||
fn into_waker(wake: Arc<Self>) -> Waker where Self: Sized | ||
{ | ||
let ptr = Arc::into_raw(wake) as *const (); | ||
|
||
unsafe { | ||
Waker::from_raw(RawWaker::new(ptr, waker_vtable!(Self))) | ||
} | ||
} | ||
} | ||
|
||
unsafe fn increase_refcount<T: ArcWake>(data: *const ()) { | ||
// Retain Arc by creating a copy | ||
let arc: Arc<T> = Arc::from_raw(data as *const T); | ||
let arc_clone = arc.clone(); | ||
// Forget the Arcs again, so that the refcount isn't decrased | ||
let _ = Arc::into_raw(arc); | ||
let _ = Arc::into_raw(arc_clone); | ||
} | ||
|
||
unsafe fn clone_arc_raw<T: ArcWake>(data: *const ()) -> RawWaker { | ||
increase_refcount::<T>(data); | ||
RawWaker::new(data, waker_vtable!(T)) | ||
} | ||
|
||
unsafe fn drop_arc_raw<T: ArcWake>(data: *const ()) { | ||
// Drop Arc | ||
let _: Arc<T> = Arc::from_raw(data as *const T); | ||
} | ||
|
||
unsafe fn wake_arc_raw<T: ArcWake>(data: *const ()) { | ||
let arc: Arc<T> = Arc::from_raw(data as *const T); | ||
ArcWake::wake(arc); | ||
} | ||
|
||
unsafe fn wake_by_ref_arc_raw<T: ArcWake>(data: *const ()) { | ||
let arc: Arc<T> = Arc::from_raw(data as *const T); | ||
ArcWake::wake_by_ref(&arc); | ||
let _ = Arc::into_raw(arc); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions
6
src/test/pretty/issue-54752-async-block.rs → ...c-await/issues/issue-54752-async-block.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
#![feature(async_await)] | ||
#![allow(unused_parens)] | ||
// run-pass | ||
|
||
// edition:2018 | ||
// pp-exact | ||
|
||
#![feature(async_await)] | ||
#![allow(unused_parens)] | ||
|
||
fn main() { let _a = (async { }); } |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions
2
src/test/run-pass/generator/issue-59972.rs → ...test/ui/async-await/issues/issue-59972.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// run-pass | ||
|
||
// compile-flags: --edition=2018 | ||
|
||
#![feature(async_await, await_macro)] | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.