diff options
Diffstat (limited to 'tests/ui/async-await/async-drop')
| -rw-r--r-- | tests/ui/async-await/async-drop/dependency-dropped.rs | 5 | ||||
| -rw-r--r-- | tests/ui/async-await/async-drop/dependency-dropped.with_feature.run.stdout (renamed from tests/ui/async-await/async-drop/dependency-dropped.run.stdout) | 0 | ||||
| -rw-r--r-- | tests/ui/async-await/async-drop/dependency-dropped.without_feature.run.stdout | 1 | ||||
| -rw-r--r-- | tests/ui/async-await/async-drop/dependency-dropped.without_feature.stderr | 10 | ||||
| -rw-r--r-- | tests/ui/async-await/async-drop/deref-later-projection.rs | 26 | ||||
| -rw-r--r-- | tests/ui/async-await/async-drop/elaborate-index-out-of-bounds.rs | 17 | ||||
| -rw-r--r-- | tests/ui/async-await/async-drop/elaborate-index-out-of-bounds.stderr | 11 | ||||
| -rw-r--r-- | tests/ui/async-await/async-drop/open-drop-error2.rs | 21 | ||||
| -rw-r--r-- | tests/ui/async-await/async-drop/open-drop-error2.stderr | 19 |
9 files changed, 109 insertions, 1 deletions
diff --git a/tests/ui/async-await/async-drop/dependency-dropped.rs b/tests/ui/async-await/async-drop/dependency-dropped.rs index f763bb32b17..d7f415e19aa 100644 --- a/tests/ui/async-await/async-drop/dependency-dropped.rs +++ b/tests/ui/async-await/async-drop/dependency-dropped.rs @@ -1,9 +1,12 @@ //@ run-pass //@ check-run-results +//@ revisions: with_feature without_feature //@ aux-build:async-drop-dep.rs //@ edition:2021 -#![feature(async_drop)] +#![cfg_attr(with_feature, feature(async_drop))] +//[without_feature]~^ WARN found async drop types in dependency `async_drop_dep`, but async_drop feature is disabled for `dependency_dropped` + #![allow(incomplete_features)] extern crate async_drop_dep; diff --git a/tests/ui/async-await/async-drop/dependency-dropped.run.stdout b/tests/ui/async-await/async-drop/dependency-dropped.with_feature.run.stdout index 7aaf70c12d6..7aaf70c12d6 100644 --- a/tests/ui/async-await/async-drop/dependency-dropped.run.stdout +++ b/tests/ui/async-await/async-drop/dependency-dropped.with_feature.run.stdout diff --git a/tests/ui/async-await/async-drop/dependency-dropped.without_feature.run.stdout b/tests/ui/async-await/async-drop/dependency-dropped.without_feature.run.stdout new file mode 100644 index 00000000000..80eeeefc222 --- /dev/null +++ b/tests/ui/async-await/async-drop/dependency-dropped.without_feature.run.stdout @@ -0,0 +1 @@ +Sync drop diff --git a/tests/ui/async-await/async-drop/dependency-dropped.without_feature.stderr b/tests/ui/async-await/async-drop/dependency-dropped.without_feature.stderr new file mode 100644 index 00000000000..96a4572055c --- /dev/null +++ b/tests/ui/async-await/async-drop/dependency-dropped.without_feature.stderr @@ -0,0 +1,10 @@ +warning: found async drop types in dependency `async_drop_dep`, but async_drop feature is disabled for `dependency_dropped` + --> $DIR/dependency-dropped.rs:7:1 + | +LL | #![cfg_attr(with_feature, feature(async_drop))] + | ^ + | + = help: if async drop type will be dropped in a crate without `feature(async_drop)`, sync Drop will be used + +warning: 1 warning emitted + diff --git a/tests/ui/async-await/async-drop/deref-later-projection.rs b/tests/ui/async-await/async-drop/deref-later-projection.rs new file mode 100644 index 00000000000..baf81daf766 --- /dev/null +++ b/tests/ui/async-await/async-drop/deref-later-projection.rs @@ -0,0 +1,26 @@ +// Ex-ICE: #140975 +//@ compile-flags: -Zvalidate-mir +//@ build-pass +//@ edition:2021 +#![crate_type = "lib"] +#![feature(async_drop)] +#![allow(incomplete_features)] + +use std::{future::AsyncDrop, pin::Pin}; + +struct HasAsyncDrop ; +impl Drop for HasAsyncDrop { + fn drop(&mut self) {} +} +impl AsyncDrop for HasAsyncDrop { + async fn drop(self: Pin<&mut Self>) {} +} + +struct Holder { + inner: HasAsyncDrop, +} +async fn bar() { + Holder { + inner: HasAsyncDrop + }; +} diff --git a/tests/ui/async-await/async-drop/elaborate-index-out-of-bounds.rs b/tests/ui/async-await/async-drop/elaborate-index-out-of-bounds.rs new file mode 100644 index 00000000000..bd0a95eb1e4 --- /dev/null +++ b/tests/ui/async-await/async-drop/elaborate-index-out-of-bounds.rs @@ -0,0 +1,17 @@ +//@ edition: 2024 +// Ex-ICE: #140974 +#![crate_type = "lib"] +#![allow(incomplete_features)] +#![feature(async_drop)] +use core::future::AsyncDrop; + +async fn fun(_: HasIncompleteAsyncDrop) {} + +struct HasIncompleteAsyncDrop; +impl Drop for HasIncompleteAsyncDrop { + fn drop(&mut self) {} +} +impl AsyncDrop for HasIncompleteAsyncDrop { + //~^ ERROR: not all trait items implemented, missing: `drop` [E0046] + // not implemented yet.. +} diff --git a/tests/ui/async-await/async-drop/elaborate-index-out-of-bounds.stderr b/tests/ui/async-await/async-drop/elaborate-index-out-of-bounds.stderr new file mode 100644 index 00000000000..d8582398c79 --- /dev/null +++ b/tests/ui/async-await/async-drop/elaborate-index-out-of-bounds.stderr @@ -0,0 +1,11 @@ +error[E0046]: not all trait items implemented, missing: `drop` + --> $DIR/elaborate-index-out-of-bounds.rs:14:1 + | +LL | impl AsyncDrop for HasIncompleteAsyncDrop { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `drop` in implementation + | + = help: implement the missing item: `async fn drop(self: Pin<&mut Self>) { todo!() }` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/async-await/async-drop/open-drop-error2.rs b/tests/ui/async-await/async-drop/open-drop-error2.rs new file mode 100644 index 00000000000..b2a7b68190e --- /dev/null +++ b/tests/ui/async-await/async-drop/open-drop-error2.rs @@ -0,0 +1,21 @@ +//@compile-flags: -Zvalidate-mir -Zinline-mir=yes --crate-type=lib + +#![feature(async_drop)] +#![allow(incomplete_features)] + +use std::{ + future::{Future, async_drop_in_place}, + pin::pin, + task::Context, +}; + +fn wrong() -> impl Sized { + //~^ ERROR: the size for values of type `str` cannot be known at compilation time + *"abc" // Doesn't implement Sized +} +fn weird(context: &mut Context<'_>) { + let mut e = wrong(); + let h = unsafe { async_drop_in_place(&raw mut e) }; + let i = pin!(h); + i.poll(context); +} diff --git a/tests/ui/async-await/async-drop/open-drop-error2.stderr b/tests/ui/async-await/async-drop/open-drop-error2.stderr new file mode 100644 index 00000000000..e849829b1c7 --- /dev/null +++ b/tests/ui/async-await/async-drop/open-drop-error2.stderr @@ -0,0 +1,19 @@ +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/open-drop-error2.rs:12:15 + | +LL | fn wrong() -> impl Sized { + | ^^^^^^^^^^ doesn't have a size known at compile-time +LL | +LL | *"abc" // Doesn't implement Sized + | ------ return type was inferred to be `str` here + | + = help: the trait `Sized` is not implemented for `str` +help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression + | +LL - *"abc" // Doesn't implement Sized +LL + "abc" // Doesn't implement Sized + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. |
