-
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
Fix suggestions when returning a bare trait from an async fn. #131882
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, typo, I mean make it a free function. There's no reason to put this into an impl :)
@@ -223,10 +223,17 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
Don't assume we always return a trait object and suggest the dyn keyword. Suggest adding impl instead.
fixes #131661