diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-05-19 18:08:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-19 18:08:43 +0200 |
| commit | e95315d37ad8906fe2098a47dfb745e6d11f16ba (patch) | |
| tree | d47b5af5c13d74aa20a1d5cdefe4f62bba72c44c /tests | |
| parent | 421230fce76c185ae2fc7d6282b64a73b0b9d781 (diff) | |
| parent | 61059282eb9ea1f37804790b182e5821337924b4 (diff) | |
| download | rust-e95315d37ad8906fe2098a47dfb745e6d11f16ba.tar.gz rust-e95315d37ad8906fe2098a47dfb745e6d11f16ba.zip | |
Rollup merge of #141253 - azhogin:azhogin/async-drop-feature-inconsistency-warning, r=oli-obk
Warning added when dependency crate has async drop types, and the feature is disabled
In continue of https://github.com/rust-lang/rust/pull/141031.
When dependency crate has non-empty `adt_async_destructor` table in metadata, and `async_drop` feature is disabled for local crate, warning will be emitted.
Test `dependency-dropped` has two revisions - with and without feature enabled. With feature enabled, async drop for dropee is executed ("Async drop" printed). Without the feature enabled, sync drop is executed ("Sync drop" printed) and warning is emitted.
Warning example:
```
warning: found async drop types in dependecy `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
```
Diffstat (limited to 'tests')
| -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 |
4 files changed, 15 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..c8670be4e8b 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 dependecy `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..56e49568e10 --- /dev/null +++ b/tests/ui/async-await/async-drop/dependency-dropped.without_feature.stderr @@ -0,0 +1,10 @@ +warning: found async drop types in dependecy `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 + |
