-
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
Reword clarification on lifetime for ptr->ref safety docs #96136
Conversation
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
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.
Obviously I think this is a positive change.
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). |
So, r=me, unless you want to wait for someone from the libs team. |
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. |
"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 |
📌 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.