-
Notifications
You must be signed in to change notification settings - Fork 47
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
Forbid unsafe code #10
Comments
As far as I understand, |
Ah yes, you are correct. I believe there is a way to modify the But it requires some bootstrapping of the project, it's not available by default. |
Thanks to your comments, I realize that the mention:
in the TODO can be misleading. There are in fact two separate problems:
As outlined by @Ekleog, the For the second one, cargo-geiger may be a good option. The reason it has not been mentioned in the guide yet is that it doesn't detect unsafe code inside macros, and may have some issues (see opened issues on cargo-geiger).
This could be a path to checking unsafe code in dependencies (I think that clippy is not required here, the |
Regarding the One way to pass flags to Sadly it does not seem to work for non-local crates, so a more sophisticated method (such as a custom toolchain) would indeed be needed. |
It looks like you could be interested in the latest version of cargo-geiger, it will scan for |
This is great news and very nice improvement of the cargo-geiger tool! |
The current text of the Rule LANG-UNSAFE has:
This talks about "code base", which is misleading. It doesn't point out that this will not scrutinize dependencies. I think "current crate" or a stronger warning are in order here. It also talks about "main.rs", whereas this can be used in libraries as much as in binaries. When advocating tools like
|
I noticed the chapter on unsafe code.
There's a TODO mentioning:
You can do that without tools, if you add
#![forbid(unsafe_code)
at the top of yourlib.rs
ormain.rs
.Having said that, this not only forbids unsafe code in imported libraries, but also your own code. But it could be argued that well maintained open source unsafe code might be safer than the one your write in a more closed/less scrutinized environment.
I know Cargo-geiger was already mentioned before, and wasn't considered an option, so I thought I'd mention this potential solution.
The text was updated successfully, but these errors were encountered: