-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
catch transmuting references which could be pointer casts #2064
Comments
I had a look at what the rules for pointer casts actually are. This section of the first-edition rust book seems to be the most up to date prose reference. Here's the list of rules from the above link:
The rustc code that actually does the check seems to be this |
We can expose that function in rustc so that clippy can access it. |
That function takes a |
I'm not sure how well we can use |
I figured I'd give experimenting with making the relevant parts of rustc_typeck public a go. So I cloned https://github.com/rust-lang/rust, fetched the submodules, and got the version of clippy in Is trying out a change like this inside the rust repo something that has been done before? Is there some documentation on this particular workflow anywhere? |
So, we've abandoned submodules for clippy, meaning that, when working on the rustc repo, you can basically treat clippy as part of rustc. You'd be making a single PR to rustc without touching the clippy repo. If that PR is accepted, then we sync the changes to the clippy repo. To run clippy with the custom built rustc, you run |
Aha. I understood that I'd be making a PR to the rust repo that would be synced later, but I didn't know that I should use |
I've got a branch of the rust repo where I've made some parts of So maybe it would make sense to keep the In case it interests anyone, the parts I needed to make public are mostly shown in this commit, and the single other change was in this one. |
yea, keep it as a separate lint for now |
All right. The PR's here. |
…xperiment, r=oli-obk Clippy pointer cast lint experiment This PR is an experiment about exposing more parts of `rustc_typeck` for use in `clippy`. In particular, the code that checks where a cast is valid or not was exposed, which necessitated exposing [`FnCtxt`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_typeck/check/struct.FnCtxt.html), and figuring out how to create an instance of that type inside `clippy`. This was prompted by [this clippy issue](rust-lang/rust-clippy#2064). r? @oli-obk
…, r=oli-obk Clippy pointer cast lint experiment This PR is an experiment about exposing more parts of `rustc_typeck` for use in `clippy`. In particular, the code that checks where a cast is valid or not was exposed, which necessitated exposing [`FnCtxt`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_typeck/check/struct.FnCtxt.html), and figuring out how to create an instance of that type inside `clippy`. This was prompted by [this clippy issue](rust-lang#2064). r? @oli-obk
Since all the work on the PR (merging and synching back to Clippy) has done, I don't see any reasons to keep this issue opened. Can we close this issue? |
is an example from libcore that isn't caught by clippy. It has been fixed in libcore, but it would be nice if we caught handwritten impls of similar things
The text was updated successfully, but these errors were encountered: