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

Lint for unsafe code style tips #1554

Closed
F001 opened this issue Feb 18, 2017 · 1 comment
Closed

Lint for unsafe code style tips #1554

F001 opened this issue Feb 18, 2017 · 1 comment

Comments

@F001
Copy link
Contributor

F001 commented Feb 18, 2017

In unsafe block, it is very easy to make a bunch of mistakes which rustc can't detect.
A few examples from my head:

  1. transmuting &T to *mut T or &mut T.
    Just like std::vec::IntoIter::as_mut_slice borrows &self, returns &mut of contents. rust#39465 showed, even experienced programmers may overlook this kind of errors. Glad to see the progress here: https://github.com/Manishearth/rust-clippy/pull/1528.

  2. types based on Unique<T> should not allow alias
    Example: LinkedList implementation violates aliasing rules rust#34417.

  3. types containing raw pointers probably need a PhantomData field

  4. Raw pointers which are never assigned by null, could be wrapped in NonZero

This list could be very long. These kind of issues are vital to memory safety.

My intent of this issue is to discuss what kind of checkers could be added into our backlist.

@F001
Copy link
Contributor Author

F001 commented Feb 20, 2017

@Manishearth If there is no informative discussion here, could you please help to close this issue?

I have a vague idea of this area, but the idea is not matured enough to form more constructive input.

@F001 F001 closed this as completed Feb 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant