Uh oh!
There was an error while loading. Please reload this page.
Reword clarification on lifetime for ptr->ref safety docs - #96136
Conversation
rust-highfive
commented
Apr 17, 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 17, 2022
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
CAD97
left a comment
There was a problem hiding this comment.
Obviously I think this is a positive change.
RalfJung
commented
Apr 17, 2022
I might have written those previous comments, and I basically wanted to be on the safe side -- but I agree that, with high probability, the aliasing model Rust will end up with will care about how references are actually used, not about their lifetime annotations. There are some wrinkles here though -- the word "exists" is doing a lot of work here, and it is not very precise. It seems to be reasonable cautious though, the actual rules are likely even less strict (more like "while the reference is being used to access memory, and also while any functions that received this reference as an argument are still running", or so). |
RalfJung
commented
Apr 17, 2022
So, r=me, unless you want to wait for someone from the libs team. |
thomcc
commented
Apr 17, 2022
Hm, I probably should have requested your review, 🤷. But it doesn't hurt for someone to sign off that "yes, this makes more sense than the previous" I suppose. |
m-ou-se
commented
Apr 18, 2022
"while this reference exists" is not very precise; one could argue it doesn't cover copies of that reference. (But making it more precise probably also makes it needlessly more confusing though.) @bors r=RalfJung |
bors
commented
Apr 18, 2022
📌 Commit be30e40 has been approved by |
Rollup of 5 pull requests Successful merges: - rust-lang#96032 (Update books) - rust-lang#96136 (Reword clarification on lifetime for ptr->ref safety docs) - rust-lang#96143 (Fix snapshot --bless not working anymore in htmldocck) - rust-lang#96148 (Use revisions instead of nll compare mode for `/self/` ui tests) - rust-lang#96156 (Replace u8to64_le macro with u64::from_le_bytes) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
I believe the current wording of the safety comment is somewhat misleading, and that this is more accurate. Suggested by @CAD97 in this thread on the topic https://rust-lang.zulipchat.com/#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/Lifetime.20of.20reference.20pointer.20docs.20issue
Just to check that this is correct, CC @RalfJung.
I suppose it's open for interpretation as to whether or not this is more clear. I think it is.