Uh oh!
There was an error while loading. Please reload this page.
Change NonNull::as_uninit_* to take self by value (as opposed to reference), matching primitive pointers. - #96100
Conversation
reference to taking `self` by value. This is consistent with the methods of the same names on primitive pointers. The returned lifetime was already previously unbounded.
rust-highfive
commented
Apr 16, 2022
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
rust-highfive
commented
Apr 16, 2022
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @thomcc (or someone else) soon. Please see the contribution instructions for more information. |
thomcc
commented
Apr 16, 2022
I'm in favor (because using &self here can lead to having to cast away lifetimes for no reason), but this is an API change, so r? rust-lang/libs-api @rustbot label +T-libs-api -T-lib |
I just noticed |
thomcc
commented
Apr 16, 2022
Yes, I don't think anything can be done there. In #80771 I made them return unbounded lifetimes which avoids most of the issues, but going further than that can't be done without breaking code. |
Raekye
commented
Apr 16, 2022
Personally, I think it's better still for But in that case, I think |
thomcc
commented
Apr 16, 2022
I think it's better to take by value. If we could change the others compatibly, I think we would. The fact that it will lead to an inconsistency in lints seems fairly minor, I doubt anybody would notice. |
Uh oh!
There was an error while loading. Please reload this page.
RalfJung
commented
Apr 16, 2022
Personally I am leaning slightly towards consistency with other NonNull methods, but don't have a strong opinion. Let's see what @rust-lang/libs-api says. |
Raekye
commented
Apr 16, 2022
Changing Aside from that, is there/what code actually breaks specifically because of the API change? (Is there a chance all the methods can be made consistent in a new edition? I can try to do a crater run) |
thomcc
commented
Apr 16, 2022
I don't think the change can be made. It would also break code that tries to pass |
Raekye
commented
Apr 16, 2022
I see, I didn't think about function pointers. That's fair enough |
Actually thinking about it more, I think it's better for |
RalfJung
commented
Apr 16, 2022
I agree. That's also consistent with |
thomcc
commented
Apr 16, 2022
Right, but these are not consistent with the methods on pointer types, e.g. https://doc.rust-lang.org/nightly/core/primitive.pointer.html#method.as_uninit_mut So I don't know that consistency is an unambiguous argument. |
yaahc
commented
Apr 29, 2022
I'm reassigning this PR because I'm taking a break from the review rotation for a little while. Thank you for your patience. r? rust-lang/libs-api |
dtolnay
commented
May 23, 2022
@bors r+ |
bors
commented
May 23, 2022
📌 Commit d5f96e6 has been approved by |
bors
commented
May 23, 2022
bors
commented
May 23, 2022
☀️ Test successful - checks-actions |
rust-timer
commented
May 23, 2022
Finished benchmarking commit (03c8b0b): comparison url. Instruction count
Max RSS (memory usage)Results
CyclesResults
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression Footnotes |
Copied from my comment on #75402:
I realized the change is trivial (if desired) so here I am creating my first PR. I think it's not a breaking change since (it's on nightly and)
NonNullisCopy; all previous usages of these methods takingselfby reference should continue to compile. However, it might cause warnings to appear on usages ofNonNull::as_uninit_mut, which used to require the theNonNullvariable be declaredmut, but now it's not necessary.