Fix suggestions when returning a bare trait from an async fn.#131882
Fix suggestions when returning a bare trait from an async fn.#131882hirschenberger wants to merge 1 commit intorust-lang:masterfrom
Conversation
|
r? @davidtwco rustbot has assigned @davidtwco. Use |
|
HIR ty lowering was modified cc @fmease These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
Don't assume we always return a trait object and suggest the dyn keyword. Suggest adding impl instead.
d63cc44 to
5642733
Compare
|
The job Click to see the possible cause of the failure (guessed by this bot) |
| /// returns the `i32`. | ||
| /// | ||
| /// [`OpaqueDef`]: hir::TyKind::OpaqueDef | ||
| pub fn get_future_inner_return_ty<'a>(hir_ty: &'a hir::Ty<'a>) -> Option<&'a hir::Ty<'a>> { |
There was a problem hiding this comment.
Just make this an inherent method please. There's no use of &self. Also rename the 'a to 'tcx, as it is more consistent.
There was a problem hiding this comment.
This function/method was moved from Mir to Hir. I thought compiler stages should only have access to previous stages, not following ones, right? I hope this is ok.
I saw that in the definition of get_future_inner_return_ty in Mir, self was not used so I made it a non-inherent (static?) method to provide access to the one place in Mir where it is used.
There was a problem hiding this comment.
Sorry, typo, I mean make it a free function. There's no reason to put this into an impl :)
| tcx.parent_hir_node(self_ty.hir_id), | ||
| hir::Node::Ty(hir::Ty { kind: hir::TyKind::Ref(..), .. }) | ||
| ); | ||
| let is_non_trait_object = |ty: &'tcx hir::Ty<'_>| { |
There was a problem hiding this comment.
This feels unfortunately somewhat ad-hoc, since any place we want to inspect the hir::TyKind, like for any diagnostics, we'll need to call the get_future_inner_return_ty.
|
I'm working on this, as some cases are not correct yet. So feel free to delay reviews, although I appreciate your feedback. |
|
☔ The latest upstream changes (presumably #132371) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@hirschenberger any updates on this? thanks |
If it's urgent, feel free to reassign. I hope I find some time to fix this in some weeks. |
|
Closing this as it has been inactive for a long time. I think it's better to do it fresh when you have the time for it. Thanks for contributing. |
Don't assume we always return a trait object and suggest the dyn keyword. Suggest adding impl instead.
fixes #131661