-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Remove extra call to upvar_tys #78725
Conversation
Running tests |
I'm curious if we will ever call Iterator for NeedDrop and ty/layout in case the types haven't been inferred yet? I'm assuming this is fine, we won't be working with basic blocks if we have uninferred types. |
@arora-aman the In fact, I think we could rewrite the layout code the same way -- the layout of the closure is just the same as |
8e58641
to
7cf5728
Compare
|
||
// Discriminant field for enums (where applicable). | ||
Variants::Multiple { ref tag, .. } => { | ||
assert_eq!(i, 0); | ||
return tag_layout(tag); | ||
return Err(tag_layout(tag)); |
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 don't think this is necessarily an err ...
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 am using the Err not because it is an error, but to know whether to return or to pass as parameter the output of ty_and_layout_kind
into layout_of
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.
Nvm, I see what you mean now: #78725 (comment)
cx: &C, | ||
i: usize, | ||
ty: C::Ty, | ||
) -> Result<C::Ty, C::TyAndLayout> { |
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'd probably add an enum which is
// Name can probably be better.
enum TyMaybeWithLayout {
Ty(C::Ty),
TyAndLayout(C::TyAndLayout)
}
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.
Oh I see, I guess that way I don't need to use result and use "Err" as a workaround
Other locations where
Not an issue since we
Should be fine since call takes place in
Not an issue since we call
Should be fine since call takes place in
Should be fine since call takes place in
Should be fine since call takes place in
This could be bad, there doesn't seem to be any check for ty::Infer
Should be fine since call takes place in
Should be fine since call takes place in
Should be fine since call takes place in
Not an issue since we call
Not an issue since we call
Should be fine since call takes place in |
It already throws a bug if the type there is Infer and the way it's right now it would be somewhat better-explained error message "Using upvar_tys before capture analysis" or something along those lines) and redirecting to tuple might not be what we want since it will use |
Let me know when this is ready for review (latest commits seem good) |
@nikomatsakis Right sorry forgot to ping you here. @rustbot modify labels: +S-waiting-on-review -S-waiting-on-author |
compiler/rustc_ty/src/needs_drop.rs
Outdated
for upvar_ty in substs.as_closure().upvar_tys() { | ||
queue_type(self, upvar_ty); | ||
// Ensure that the upvar tys has been inferred | ||
if substs.as_closure().is_valid() { |
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 think this could be queue_type(substs.as_closure().tupled_upvars_ty())
, no?
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.
(same with generators)
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.
done
c0efdd4
to
589fa91
Compare
@nikomatsakis Ready for review @rustbot modify labels: +S-waiting-on-review -S-waiting-on-author |
☔ The latest upstream changes (presumably #78863) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:
|
@nikomatsakis Merge conflict has been resolved @rustbot modify labels: +S-waiting-on-review -S-waiting-on-author |
@bors r+ |
📌 Commit e35e46c has been approved by |
☀️ Test successful - checks-actions |
@arora-aman @nikomatsakis this change caused a moderate regression in the const eval stress test. Perhaps an investigation is warranted into why that is. |
We already visit the tuple of upvar_tys, we don't need to visit each individual type.
Fixes #78720
r? @ghost