-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Simplify some Deref impls.
#155536
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
Simplify some Deref impls.
#155536
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,7 +64,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { | |
| // declared list of variants -- they can differ with explicitly assigned discriminants. | ||
| // We use "tag" to refer to how the discriminant is encoded in memory, which can be either | ||
| // straight-forward (`TagEncoding::Direct`) or with a niche (`TagEncoding::Niche`). | ||
| let (tag_scalar_layout, tag_encoding, tag_field) = match op.layout().variants { | ||
| let layout = op.layout(); | ||
| let (tag_scalar_layout, tag_encoding, tag_field) = match layout.variants { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like here it doesn't actually simplify things, it forces us to manually spell out the temporary?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The trade-off is that it's arguably worth having a vanilla
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't look that bad to me. If I were to write this function, I'd probably hoist it regardless: let layout = op.layout();
let ty = layout.ty;and then
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree the cost is small, but I also don't see any downside to the current |
||
| Variants::Empty => { | ||
| throw_ub!(UninhabitedEnumVariantRead(None)); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3074,10 +3074,10 @@ struct CallCtxt<'a, 'b, 'tcx> { | |||||
| } | ||||||
|
|
||||||
| impl<'a, 'b, 'tcx> Deref for CallCtxt<'a, 'b, 'tcx> { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These can be changed to placeholder lifetimes:
Suggested change
Same for the other
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In #155549 I eliminaetd one of the lifetimes anyway. |
||||||
| type Target = &'a FnCtxt<'b, 'tcx>; | ||||||
| type Target = FnCtxt<'b, 'tcx>; | ||||||
|
|
||||||
| fn deref(&self) -> &Self::Target { | ||||||
| &self.fn_ctxt | ||||||
| self.fn_ctxt | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.
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 does make the type strictly weaker -- previously one could copy out the inner, longer-lived shared reference to get a
'areference; now that information is lost. I am not sure I agree with this being an improvement, it seems more like a step backwards to me?View changes since the review