Skip to content
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

as_ref suggestions should warn about UB concerns #61786

Closed
RalfJung opened this issue Jun 12, 2019 · 2 comments · Fixed by #62685
Closed

as_ref suggestions should warn about UB concerns #61786

RalfJung opened this issue Jun 12, 2019 · 2 comments · Fixed by #62685
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@RalfJung
Copy link
Member

With #61444 we are now suggesting people to use as_ref when they have a raw pointer and need a reference. With #61785 as_ref gets some expanded documentation on UB avoidance. It might be a good idea to mention that also in the actual suggestion, so people don't have to open the docs to be aware of this.

Cc @estebank

@jonas-schievink jonas-schievink added A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 12, 2019
@estebank estebank added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. P-medium Medium priority A-diagnostics Area: Messages for errors, warnings, and lints labels Jun 12, 2019
@imbrem
Copy link
Contributor

imbrem commented Jun 20, 2019

Can I take this on, since no one seems to have done it yet?

@RalfJung
Copy link
Member Author

Sure, it's yours!

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jul 15, 2019
…tebank

Add info about undefined behavior to as_ref suggestions

Fixes rust-lang#61786. A very small fix, but suggestions on wording/content are welcomed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants