-
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
give more help in the unaligned_references lint #91718
Conversation
r? @nagisa (rust-highfive has picked a reviewer for you, use r? to override) |
Hm, from a wording perspective, just “copy the field contents” doesn't really help that much – copy to where, how, and in what way does this help is left for the reader to figure out. I assume what the meaning is here is “make a local variable with a copy of the field's contents and then take a reference to the variable”. Acknowledging that, in an effort to produce reasonably looking diagnostics, we want to limit the length of any specific diagnostic string, I wonder if it we could have I'd also like some input from @estebank about addressing the reader. In the past they argued that messages of the form “consider…” are a poor style and “you can…” is probably not much different. With both points in mind how about something along these lines:
|
I like that wording. However, I am a bit worried people will think 'oh so raw pointers are fine' and not realize that
It's not like this is an extremely common warning, and when it arises then the programmer really needs to be aware of a lot of subtle details. |
I like the final proposed output and agree that given how uncommon this will be in practice, going overboard with detail is better than being too terse. |
19f9284
to
7d18a45
Compare
@bors r+ |
📌 Commit 7d18a45 has been approved by |
…gisa give more help in the unaligned_references lint Cc rust-lang#82523 (comment) `@kaisq`
…askrgr Rollup of 7 pull requests Successful merges: - rust-lang#91617 (Improve the readability of `List<T>`.) - rust-lang#91640 (Simplify collection of in-band lifetimes) - rust-lang#91682 (rustdoc: Show type layout for type aliases) - rust-lang#91711 (Improve `std::iter::zip` example) - rust-lang#91717 (Add deprecation warning for --passes) - rust-lang#91718 (give more help in the unaligned_references lint) - rust-lang#91782 (Correct since attribute for `is_symlink` feature) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Cc #82523 (comment) @kaisq