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

compile-time lint unsafe code #92

Conversation

ArtemIsmagilov
Copy link
Contributor

@ArtemIsmagilov ArtemIsmagilov commented Dec 24, 2024

I want to propose a compile-time check of the codebase for unsafe code.
This will provide the library with the guarantees given by standard safe Rust.
https://doc.rust-lang.org/nomicon/safe-unsafe-meaning.html

Work demonstration

error: implementation of an `unsafe` method
   --> src/commands/server_commands.rs:864:5
    |
864 | /     unsafe fn memory_help(self) -> PreparedCommand<'a, Self, Vec<String>>
865 | |     where
866 | |         Self: Sized,
867 | |     {
868 | |         prepare_command(self, cmd("MEMORY").arg("HELP"))
869 | |     }
    | |_____^
    |
note: the lint level is defined here
   --> src/lib.rs:1:11
    |
1   | #![forbid(unsafe_code)]
    |           ^^^^^^^^^^^

warning: `rustis` (lib) generated 1 warning
error: could not compile `rustis` (lib) due to 1 previous error;

@mcatanzariti mcatanzariti merged commit 3689230 into dahomey-technologies:main Dec 25, 2024
3 checks passed
@ArtemIsmagilov ArtemIsmagilov deleted the check-on-compile-time-unsafe-code branch December 25, 2024 12:02
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

Successfully merging this pull request may close these issues.

2 participants