-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Fix async drop multi crate crash #153274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ValorZard
wants to merge
1
commit into
rust-lang:main
Choose a base branch
from
ValorZard:async-drop-multi-crate-crash
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+96
−23
Open
Fix async drop multi crate crash #153274
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
18 changes: 18 additions & 0 deletions
18
...i/async-await/async-drop/async-drop-run-without-feature/async-drop-run-without-feature.rs
This file contains hidden or 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,18 @@ | ||
| //@ edition: 2024 | ||
| //@ run-pass | ||
| //@ compile-flags: -Z mir-opt-level=0 | ||
| //@ aux-crate: async_drop_crate_dep=async-drop-crate-dep.rs | ||
|
|
||
| use std::{ //~ WARN found async drop types in dependency | ||
| pin::pin, | ||
| task::{Context, Waker}, | ||
| }; | ||
|
|
||
| extern crate async_drop_crate_dep; | ||
|
|
||
| fn main() { | ||
| let mut context = Context::from_waker(Waker::noop()); | ||
| let future = pin!(async { async_drop_crate_dep::run().await }); | ||
| // For some reason, putting this value into a variable is load-bearing. | ||
| let _x = future.poll(&mut context); | ||
| } |
10 changes: 10 additions & 0 deletions
10
...ync-await/async-drop/async-drop-run-without-feature/async-drop-run-without-feature.stderr
This file contains hidden or 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,10 @@ | ||
| warning: found async drop types in dependency `async_drop_crate_dep`, but async_drop feature is disabled for `async_drop_run_without_feature` | ||
| --> $DIR/async-drop-run-without-feature.rs:6:1 | ||
| | | ||
| LL | use std::{ | ||
| | ^ | ||
| | | ||
| = help: if async drop type will be dropped in a crate without `feature(async_drop)`, sync Drop will be used | ||
|
|
||
| warning: 1 warning emitted | ||
|
|
23 changes: 23 additions & 0 deletions
23
...i/async-await/async-drop/async-drop-run-without-feature/auxiliary/async-drop-crate-dep.rs
This file contains hidden or 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,23 @@ | ||
| //@ edition: 2024 | ||
| #![feature(async_drop)] | ||
| use std::future::AsyncDrop; | ||
| use std::pin::Pin; | ||
|
|
||
| pub async fn run() { | ||
| let _st = St; | ||
| } | ||
|
|
||
| struct St; | ||
|
|
||
| impl Drop for St { | ||
| fn drop(&mut self) {} | ||
| } | ||
|
|
||
| impl AsyncDrop for St { | ||
| async fn drop(self: Pin<&mut Self>) { | ||
| // Removing this line makes the program panic "normally" (not abort). | ||
| nothing().await; | ||
| } | ||
| } | ||
|
|
||
| async fn nothing() {} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could do
if self.tcx().features().staged_api() { span_bug!(some_span, "don't use async drop in libstd, it becomes insta-stable") }(and similarly at the other use ofasync_dropinadt_constructor