-
Notifications
You must be signed in to change notification settings - Fork 67
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
Expressions in unsafe functions does not count as unsafe #71
Comments
Thank you for the report! I will find the time to read it and reply during the weekend. |
Excellent examples, this is clearly a bug. Traversing into an unsafe function during scanning should put the scanner context into the "count unsafe" state during the entire function scope. Would you be interested in making a PR? |
Looking at the code makes me think there's another bug related to unsafe scopes: The |
Awesome @anderejd, thanks! |
No problem, thank you for the excellent bug report! :) |
Released in 0.8. |
Awesome, thanks! |
The following code makes
cargo-geiger
report 1 unsafe function and 0 unsafe expressions:But if I change it into the following, it is reported as 1 unsafe function and 1 unsafe expression (but with a warning about superfluous unsafe of course):
Both contain the exact same amount of expressions that could potentially be unsound. Both libraries are equally unsafe. But
cargo-geiger
thinks the latter is more unsafe.I think
cargo-geiger
need to count every expression inunsafe fn
s as unsafe expressions, because they are allowed to do anything you can do in unsafe Rust.Another point to show the same thing. If I refactor the following:
Into:
Then
cargo-geiger
reports that I have one unsafe function less, but more unsafe expressions than before. While in reality I have proven to the compiler and the reader thatsafe()
is indeed safe, everything else is the same as before. I made fewer expressions compile as unsafe Rust. This does not feel like a very fair way of counting the unsafety of my library.The text was updated successfully, but these errors were encountered: