-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Don't create adjustments from a type to itself #28428
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
I just noticed that this fails in a number of cases, probably because of region mismatches in various &[u8] types. Is there a way to compare types while ignoring regions? |
The problem is that the adjustments are needed for the type system to be happy. I think we can trivially detect and optimize this sort of thing once MIR lands, however, which is probably my preferred strategy. Alternatively, it'd probably be fairly easy to detect and do a kind of peephole optimization for this case in trans. |
Oh, right, I completely forgot about that. I guess the equality check as is
|
@dotdash yeah, the equality check seems harmless. This by the way is an example of a case where it'd be nice to get some kind of unit test to help us ensure that micro-optimizations of generated code don't get lost. |
52a20d9
to
bc201fe
Compare
Added a test. Some time soon, I'll remember to add those right away... |
📌 Commit bc201fe has been approved by |
⌛ Testing commit bc201fe with merge d8d8830... |
💔 Test failed - auto-mac-32-opt |
Currently, we're generating adjustments, for example, to get from &[u8] to &[u8], which is unneeded and kicks us out of trans_into() into trans() which means an additional stack slot and copy in the unoptimized code.
bc201fe
to
6def06c
Compare
Currently, we're generating adjustments, for example, to get from &[u8] to &[u8], which is unneeded and kicks us out of trans_into() into trans() which means an additional stack slot and copy in the unoptimized code.
The original blog post referred to examples by their file names, and now that it's in guide form, there is no file name. So edit the text so that it makes a bit more sense. Fixes rust-lang#28428
The original blog post referred to examples by their file names, and now that it's in guide form, there is no file name. So edit the text so that it makes a bit more sense. Fixes rust-lang#28428
Currently, we're generating adjustments, for example, to get from &[u8]
to &[u8], which is unneeded and kicks us out of trans_into()
into trans() which means an additional stack slot and copy in the
unoptimized code.