-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Properly handle Pin<&mut dyn* Trait>
receiver in codegen
#104594
Merged
Merged
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 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
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
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
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
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,52 @@ | ||
// run-pass | ||
// edition:2021 | ||
// check-run-results | ||
|
||
#![feature(dyn_star)] | ||
//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes | ||
|
||
use std::future::Future; | ||
|
||
async fn foo(f: dyn* Future<Output = i32>) { | ||
println!("value: {}", f.await); | ||
} | ||
|
||
async fn async_main() { | ||
foo(Box::pin(async { 1 })).await | ||
} | ||
|
||
// ------------------------------------------------------------------------- // | ||
// Implementation Details Below... | ||
|
||
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(); | ||
|
||
// Poll loop, just to test the future... | ||
let waker = noop_waker(); | ||
let ctx = &mut Context::from_waker(&waker); | ||
|
||
loop { | ||
match unsafe { Pin::new_unchecked(&mut fut).poll(ctx) } { | ||
Poll::Pending => {} | ||
Poll::Ready(()) => break, | ||
} | ||
} | ||
} |
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 @@ | ||
value: 1 |
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,11 @@ | ||
warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/dispatch-on-pin-mut.rs:5:12 | ||
| | ||
LL | #![feature(dyn_star)] | ||
| ^^^^^^^^ | ||
| | ||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
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
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,2 @@ | ||
43 | ||
44 |
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,11 @@ | ||
warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/dont-unsize-coerce-dyn-star.rs:4:12 | ||
| | ||
LL | #![feature(dyn_star)] | ||
| ^^^^^^^^ | ||
| | ||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
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,13 @@ | ||
#![feature(dyn_star, trait_upcasting)] | ||
//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes | ||
|
||
trait A: B {} | ||
trait B {} | ||
impl A for usize {} | ||
impl B for usize {} | ||
|
||
fn main() { | ||
let x: Box<dyn* A> = Box::new(1usize as dyn* A); | ||
let y: Box<dyn* B> = x; | ||
//~^ ERROR mismatched types | ||
} |
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,23 @@ | ||
warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/no-unsize-coerce-dyn-trait.rs:1:12 | ||
| | ||
LL | #![feature(dyn_star, trait_upcasting)] | ||
| ^^^^^^^^ | ||
| | ||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/no-unsize-coerce-dyn-trait.rs:11:26 | ||
| | ||
LL | let y: Box<dyn* B> = x; | ||
| ----------- ^ expected trait `B`, found trait `A` | ||
| | | ||
| expected due to this | ||
| | ||
= note: expected struct `Box<dyn* B>` | ||
found struct `Box<dyn* A>` | ||
|
||
error: aborting due to previous error; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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
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,20 @@ | ||
warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/upcast.rs:3:12 | ||
| | ||
LL | #![feature(dyn_star, trait_upcasting)] | ||
| ^^^^^^^^ | ||
| | ||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
error[E0277]: `dyn* Foo` needs to be a pointer-sized type | ||
--> $DIR/upcast.rs:30:23 | ||
| | ||
LL | let w: dyn* Bar = w; | ||
| ^ `dyn* Foo` needs to be a pointer-sized type | ||
| | ||
= help: the trait `PointerSized` is not implemented for `dyn* Foo` | ||
|
||
error: aborting due to previous error; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
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.
Surprised by this removal
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.
I see the more specific pattern here and in the next file, but doesn't this code have to run for non
dyn*
?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.
Can you be more specific? Did you see the PR description that mentions "Also, disable dyn* trait upcasting"?
Because all this disables is
CoerceUnsized
implementations fromdyn* Trait
todyn* SuperTrait
, which cannot be implemented withCoerceUnsized
and need to be reworked.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.
I see. r=me after rebasing