Remove support for defaulted trait methods with async
or return-position impl Trait
#108142
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.
Unfortunately, default methods on
async fn
and return-positionimpl Trait
in traits are unsound and pretty unworkable in their current state. To put it in perspective, given the code:The above code cannot bbe desugared like:
because we shouldn't be able to observe the
Self::FooRPIT
->impl Future
projection.Ideally, we could observe this inside the body of
Foo::foo
, but the way that our projection logic implements this is not correct, leading to issues like #107002. Fixing it leads to weird cycles or committing to really nasty hacks in HIR and MIR typeck (#107013).To discourage users from relying on this behavior and hitting issues like #107002, let's just deny this behavior for now. Maybe I can revisit this feature in the future with a clearer mind. I may have some tricks up my sleeve to fix this, but for now, let's not commit to supporting this.
cc @rust-lang/wg-async and @rust-lang/types who may have thoughts about this.
r? @lcnr
Fixes #107002 (not really, but at least closes it)