summaryrefslogtreecommitdiffstats
path: root/tests/ui/async-await/in-trait
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/async-await/in-trait')
-rw-r--r--tests/ui/async-await/in-trait/async-default-fn-overridden.rs24
-rw-r--r--tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr6
-rw-r--r--tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr2
-rw-r--r--tests/ui/async-await/in-trait/async-example-desugared-manual.stderr2
-rw-r--r--tests/ui/async-await/in-trait/async-recursive-generic.stderr2
-rw-r--r--tests/ui/async-await/in-trait/async-recursive.stderr2
-rw-r--r--tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs25
-rw-r--r--tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr26
-rw-r--r--tests/ui/async-await/in-trait/fn-not-async-err.stderr2
-rw-r--r--tests/ui/async-await/in-trait/generics-mismatch.stderr2
-rw-r--r--tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr10
-rw-r--r--tests/ui/async-await/in-trait/lifetime-mismatch.stderr2
-rw-r--r--tests/ui/async-await/in-trait/missing-send-bound.stderr2
-rw-r--r--tests/ui/async-await/in-trait/object-safety.stderr2
-rw-r--r--tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.stderr2
-rw-r--r--tests/ui/async-await/in-trait/return-type-suggestion.stderr2
-rw-r--r--tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.stderr2
-rw-r--r--tests/ui/async-await/in-trait/unconstrained-impl-region.stderr2
-rw-r--r--tests/ui/async-await/in-trait/warn.stderr2
19 files changed, 54 insertions, 65 deletions
diff --git a/tests/ui/async-await/in-trait/async-default-fn-overridden.rs b/tests/ui/async-await/in-trait/async-default-fn-overridden.rs
index c8fd2d8f6..491dfcc6a 100644
--- a/tests/ui/async-await/in-trait/async-default-fn-overridden.rs
+++ b/tests/ui/async-await/in-trait/async-default-fn-overridden.rs
@@ -1,6 +1,7 @@
// run-pass
// edition:2021
+#![feature(noop_waker)]
use std::future::Future;
@@ -32,33 +33,18 @@ async fn async_main() {
// ------------------------------------------------------------------------- //
// Implementation Details Below...
-use std::pin::Pin;
+use std::pin::pin;
use std::task::*;
-pub fn noop_waker() -> Waker {
- let raw = RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE);
-
- // SAFETY: the contracts for RawWaker and RawWakerVTable are upheld
- unsafe { Waker::from_raw(raw) }
-}
-
-const NOOP_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(noop_clone, noop, noop, noop);
-
-unsafe fn noop_clone(_p: *const ()) -> RawWaker {
- RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE)
-}
-
-unsafe fn noop(_p: *const ()) {}
-
fn main() {
- let mut fut = async_main();
+ let mut fut = pin!(async_main());
// Poll loop, just to test the future...
- let waker = noop_waker();
+ let waker = Waker::noop();
let ctx = &mut Context::from_waker(&waker);
loop {
- match unsafe { Pin::new_unchecked(&mut fut).poll(ctx) } {
+ match fut.as_mut().poll(ctx) {
Poll::Pending => {}
Poll::Ready(()) => break,
}
diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr
index b70b36adb..54df0edf5 100644
--- a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr
+++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr
@@ -9,9 +9,9 @@ note: type in trait
|
LL | fn foo(&self) -> Pin<Box<dyn Future<Output = i32> + '_>>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- = note: expected signature `fn(&i32) -> Pin<Box<dyn Future<Output = i32>>>`
- found signature `fn(&i32) -> impl Future<Output = i32>`
+ = note: expected signature `fn(&_) -> Pin<Box<dyn Future<Output = i32>>>`
+ found signature `fn(&_) -> impl Future<Output = i32>`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0053`.
diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr
index 6392ce86e..1462c694e 100644
--- a/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr
+++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr
@@ -7,5 +7,5 @@ LL | async fn foo(&self) -> i32;
LL | fn foo(&self) -> Pin<Box<dyn Future<Output = i32> + '_>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr b/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr
index 1eda6fe65..a2f1060e3 100644
--- a/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr
+++ b/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr
@@ -7,5 +7,5 @@ LL | async fn foo(&self) -> i32;
LL | fn foo(&self) -> MyFuture {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/async-await/in-trait/async-recursive-generic.stderr b/tests/ui/async-await/in-trait/async-recursive-generic.stderr
index cf0bcd741..11489c18a 100644
--- a/tests/ui/async-await/in-trait/async-recursive-generic.stderr
+++ b/tests/ui/async-await/in-trait/async-recursive-generic.stderr
@@ -7,6 +7,6 @@ LL | async fn foo_recursive(&self, n: usize) -> T {
= note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`
= note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0733`.
diff --git a/tests/ui/async-await/in-trait/async-recursive.stderr b/tests/ui/async-await/in-trait/async-recursive.stderr
index b959652ea..587962857 100644
--- a/tests/ui/async-await/in-trait/async-recursive.stderr
+++ b/tests/ui/async-await/in-trait/async-recursive.stderr
@@ -7,6 +7,6 @@ LL | async fn foo_recursive(&self, n: usize) -> i32 {
= note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`
= note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0733`.
diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs
index 18b0fa485..f21abf012 100644
--- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs
+++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs
@@ -2,6 +2,7 @@
// known-bug: #108309
#![feature(min_specialization)]
+#![feature(noop_waker)]
struct MyStruct;
@@ -35,34 +36,18 @@ async fn indirection<T>(x: T) -> &'static str {
// ------------------------------------------------------------------------- //
// Implementation Details Below...
-use std::future::Future;
-use std::pin::Pin;
+use std::pin::{pin, Pin};
use std::task::*;
-pub fn noop_waker() -> Waker {
- let raw = RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE);
-
- // SAFETY: the contracts for RawWaker and RawWakerVTable are upheld
- unsafe { Waker::from_raw(raw) }
-}
-
-const NOOP_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(noop_clone, noop, noop, noop);
-
-unsafe fn noop_clone(_p: *const ()) -> RawWaker {
- RawWaker::new(std::ptr::null(), &NOOP_WAKER_VTABLE)
-}
-
-unsafe fn noop(_p: *const ()) {}
-
fn main() {
- let mut fut = async_main();
+ let mut fut = pin!(async_main());
// Poll loop, just to test the future...
- let waker = noop_waker();
+ let waker = Waker::noop();
let ctx = &mut Context::from_waker(&waker);
loop {
- match unsafe { Pin::new_unchecked(&mut fut).poll(ctx) } {
+ match fut.as_mut().poll(ctx) {
Poll::Pending => {}
Poll::Ready(()) => break,
}
diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr
index 5e2be0862..0560cd9c5 100644
--- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr
+++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr
@@ -1,11 +1,11 @@
error[E0053]: method `foo` has an incompatible type for trait
- --> $DIR/dont-project-to-specializable-projection.rs:13:5
+ --> $DIR/dont-project-to-specializable-projection.rs:14:5
|
LL | default async fn foo(_: T) -> &'static str {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found future
|
note: type in trait
- --> $DIR/dont-project-to-specializable-projection.rs:9:5
+ --> $DIR/dont-project-to-specializable-projection.rs:10:5
|
LL | async fn foo(_: T) -> &'static str;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -13,13 +13,29 @@ LL | async fn foo(_: T) -> &'static str;
found signature `fn(_) -> impl Future<Output = &'static str>`
error: async associated function in trait cannot be specialized
- --> $DIR/dont-project-to-specializable-projection.rs:13:5
+ --> $DIR/dont-project-to-specializable-projection.rs:14:5
|
LL | default async fn foo(_: T) -> &'static str {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: specialization behaves in inconsistent and surprising ways with async functions in traits, and for now is disallowed
-error: aborting due to 2 previous errors
+error[E0599]: no method named `poll` found for struct `Pin<&mut impl Future<Output = ()>>` in the current scope
+ --> $DIR/dont-project-to-specializable-projection.rs:50:28
+ |
+LL | match fut.as_mut().poll(ctx) {
+ | ^^^^ method not found in `Pin<&mut impl Future<Output = ()>>`
+ --> $SRC_DIR/core/src/future/future.rs:LL:COL
+ |
+ = note: the method is available for `Pin<&mut impl Future<Output = ()>>` here
+ |
+ = help: items from traits can only be used if the trait is in scope
+help: the following trait is implemented but not in scope; perhaps add a `use` for it:
+ |
+LL + use std::future::Future;
+ |
+
+error: aborting due to 3 previous errors
-For more information about this error, try `rustc --explain E0053`.
+Some errors have detailed explanations: E0053, E0599.
+For more information about an error, try `rustc --explain E0053`.
diff --git a/tests/ui/async-await/in-trait/fn-not-async-err.stderr b/tests/ui/async-await/in-trait/fn-not-async-err.stderr
index cd085074a..f75ccb65d 100644
--- a/tests/ui/async-await/in-trait/fn-not-async-err.stderr
+++ b/tests/ui/async-await/in-trait/fn-not-async-err.stderr
@@ -7,5 +7,5 @@ LL | async fn foo(&self) -> i32;
LL | fn foo(&self) -> i32 {
| ^^^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/async-await/in-trait/generics-mismatch.stderr b/tests/ui/async-await/in-trait/generics-mismatch.stderr
index 647cc698f..5f7aeb171 100644
--- a/tests/ui/async-await/in-trait/generics-mismatch.stderr
+++ b/tests/ui/async-await/in-trait/generics-mismatch.stderr
@@ -11,6 +11,6 @@ LL | impl Foo for () {
LL | async fn foo<const N: usize>() {}
| ^^^^^^^^^^^^^^ found const parameter of type `usize`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0053`.
diff --git a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr
index ce02c1e99..8e573b512 100644
--- a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr
+++ b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr
@@ -1,10 +1,12 @@
-error[E0391]: cycle detected when computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:33:27: 35:6}`
+error[E0391]: cycle detected when computing layout of `core::mem::maybe_uninit::MaybeUninit<{async fn body@$DIR/indirect-recursion-issue-112047.rs:33:27: 35:6}>`
|
- = note: ...which requires computing layout of `<<A as First>::Second as Second>::{opaque#0}`...
- = note: ...which again requires computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:33:27: 35:6}`, completing the cycle
+ = note: ...which requires computing layout of `core::mem::manually_drop::ManuallyDrop<{async fn body@$DIR/indirect-recursion-issue-112047.rs:33:27: 35:6}>`...
+ = note: ...which requires computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:33:27: 35:6}`...
+ = note: ...which requires computing layout of `core::mem::maybe_uninit::MaybeUninit<<<A as First>::Second as Second>::{opaque#0}>`...
+ = note: ...which again requires computing layout of `core::mem::maybe_uninit::MaybeUninit<{async fn body@$DIR/indirect-recursion-issue-112047.rs:33:27: 35:6}>`, completing the cycle
= note: cycle used when computing layout of `{async block@$DIR/indirect-recursion-issue-112047.rs:6:13: 8:6}`
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0391`.
diff --git a/tests/ui/async-await/in-trait/lifetime-mismatch.stderr b/tests/ui/async-await/in-trait/lifetime-mismatch.stderr
index 3841ab934..6b8716d2a 100644
--- a/tests/ui/async-await/in-trait/lifetime-mismatch.stderr
+++ b/tests/ui/async-await/in-trait/lifetime-mismatch.stderr
@@ -7,6 +7,6 @@ LL | async fn foo<'a>(&self);
LL | async fn foo(&self) {}
| ^ lifetimes do not match method in trait
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0195`.
diff --git a/tests/ui/async-await/in-trait/missing-send-bound.stderr b/tests/ui/async-await/in-trait/missing-send-bound.stderr
index 139bd06c7..aeabb5931 100644
--- a/tests/ui/async-await/in-trait/missing-send-bound.stderr
+++ b/tests/ui/async-await/in-trait/missing-send-bound.stderr
@@ -21,5 +21,5 @@ LL - async fn bar();
LL + fn bar() -> impl std::future::Future<Output = ()> + Send;
|
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/async-await/in-trait/object-safety.stderr b/tests/ui/async-await/in-trait/object-safety.stderr
index 5b9fd98ac..f45e6a2c8 100644
--- a/tests/ui/async-await/in-trait/object-safety.stderr
+++ b/tests/ui/async-await/in-trait/object-safety.stderr
@@ -13,6 +13,6 @@ LL | async fn foo(&self);
| ^^^ ...because method `foo` is `async`
= help: consider moving `foo` to another trait
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0038`.
diff --git a/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.stderr b/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.stderr
index a66dd13bb..84e0a6434 100644
--- a/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.stderr
+++ b/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.stderr
@@ -4,6 +4,6 @@ error[E0412]: cannot find type `Missing` in this scope
LL | fn bar() -> Wrapper<Missing<impl Sized>>;
| ^^^^^^^ not found in this scope
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0412`.
diff --git a/tests/ui/async-await/in-trait/return-type-suggestion.stderr b/tests/ui/async-await/in-trait/return-type-suggestion.stderr
index 363870619..4947b7fec 100644
--- a/tests/ui/async-await/in-trait/return-type-suggestion.stderr
+++ b/tests/ui/async-await/in-trait/return-type-suggestion.stderr
@@ -7,6 +7,6 @@ LL | Ok(())
= note: expected unit type `()`
found enum `Result<(), _>`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.stderr b/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.stderr
index 482707351..dd38e205b 100644
--- a/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.stderr
+++ b/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.stderr
@@ -18,6 +18,6 @@ note: required by a bound in `needs_send`
LL | fn needs_send(_: impl Send) {}
| ^^^^ required by this bound in `needs_send`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/async-await/in-trait/unconstrained-impl-region.stderr b/tests/ui/async-await/in-trait/unconstrained-impl-region.stderr
index 2cb0da2e8..ef7e4ef0e 100644
--- a/tests/ui/async-await/in-trait/unconstrained-impl-region.stderr
+++ b/tests/ui/async-await/in-trait/unconstrained-impl-region.stderr
@@ -4,6 +4,6 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait,
LL | impl<'a> Actor for () {
| ^^ unconstrained lifetime parameter
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0207`.
diff --git a/tests/ui/async-await/in-trait/warn.stderr b/tests/ui/async-await/in-trait/warn.stderr
index d0278628c..c741a23c6 100644
--- a/tests/ui/async-await/in-trait/warn.stderr
+++ b/tests/ui/async-await/in-trait/warn.stderr
@@ -16,5 +16,5 @@ LL - async fn not_send();
LL + fn not_send() -> impl std::future::Future<Output = ()> + Send;
|
-error: aborting due to previous error
+error: aborting due to 1 previous error