Skip to content
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

When expecting BoxFuture and using async {}, suggest Box::pin #69082

Merged
merged 5 commits into from
Feb 13, 2020

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Feb 12, 2020

Fix #68197, cc #69083.

@rust-highfive
Copy link
Collaborator

r? @davidtwco

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 12, 2020
| ^
| |
| expected struct `std::boxed::Box`, found type parameter `F`
| help: store this in the heap by calling `Box::new`: `Box::new(x)`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only part that is not ideal, and I can add some logic to avoid this but would make more complex an unrelated part of the codebase...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall it seems okay for now, it seems less likely that they will start with Pin::new. And if they apply the suggestion they'll eventually be presented with a correct one.

@@ -727,6 +727,13 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
/// [`Pin<P>`]: ../pin/struct.Pin.html
/// [`pin module`]: ../../std/pin/index.html
#[stable(feature = "pin", since = "1.33.0")]
#[rustc_on_unimplemented(
on(
_Self = "dyn std::future::Future<Output = i32> + std::marker::Send",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you specifically want i32 here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh damn, you're right, sigh.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to modify rustc_on_unimplemented for this to work, but won't be able to test it until those changes get picked up by beta.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For clarification, the note still appears, it just isn't being tested for regressions. I will reenable those tests after the next release is cut.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine with me, but I don't really understand why we have to wait for beta.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand either, but I remember having the same issue sometime back when extending rustc_on_unimplemented.

| ^
| |
| expected struct `std::boxed::Box`, found type parameter `F`
| help: store this in the heap by calling `Box::new`: `Box::new(x)`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall it seems okay for now, it seems less likely that they will start with Pin::new. And if they apply the suggestion they'll eventually be presented with a correct one.

src/librustc_typeck/check/mod.rs Outdated Show resolved Hide resolved
@estebank
Copy link
Contributor Author

r? @tmandry

@rust-highfive rust-highfive assigned tmandry and unassigned davidtwco Feb 13, 2020
@rust-highfive

This comment has been minimized.

@tmandry
Copy link
Member

tmandry commented Feb 13, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Feb 13, 2020

📌 Commit 248f5a4 has been approved by tmandry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 13, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Feb 13, 2020
When expecting `BoxFuture` and using `async {}`, suggest `Box::pin`

Fix rust-lang#68197, cc rust-lang#69083.
bors added a commit that referenced this pull request Feb 13, 2020
Rollup of 9 pull requests

Successful merges:

 - #67642 (Relax bounds on HashMap/HashSet)
 - #68848 (Hasten macro parsing)
 - #69008 (Properly use parent generics for opaque types)
 - #69048 (Suggestion when encountering assoc types from hrtb)
 - #69049 (Optimize image sizes)
 - #69050 (Micro-optimize the heck out of LEB128 reading and writing.)
 - #69068 (Make the SGX arg cleanup implementation a NOP)
 - #69082 (When expecting `BoxFuture` and using `async {}`, suggest `Box::pin`)
 - #69104 (bootstrap: Configure cmake when building sanitizer runtimes)

Failed merges:

r? @ghost
@bors bors merged commit 248f5a4 into rust-lang:master Feb 13, 2020
@estebank estebank deleted the boxfuture-box-pin branch November 9, 2023 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Confusing error message when expecting BoxFuture
5 participants