-
Notifications
You must be signed in to change notification settings - Fork 32
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
lints: add #![forbid]
lints per crate
#375
base: main
Are you sure you want to change the base?
Conversation
#![forbid( | ||
clippy::missing_assert_message, | ||
clippy::missing_docs_in_private_items, | ||
clippy::missing_errors_doc, | ||
clippy::missing_panics_doc, | ||
clippy::should_panic_without_expect, | ||
clippy::single_char_lifetime_names, | ||
missing_docs, | ||
unsafe_code, | ||
unused_results, | ||
missing_copy_implementations, | ||
missing_debug_implementations, | ||
reason = "Crate-specific lints. There should be good reasoning when removing these." | ||
)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the full list of lints, all other crates have some subset of this. Only a few allow unsafe_code
, I will list them:
@@ -69,6 +69,7 @@ impl_thread_percent! { | |||
/// | |||
/// On macOS and *BSD: +20 | |||
/// On Linux: +19 | |||
#[expect(unsafe_code, reason = "Must call C")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cuprate_helper
uses unsafe
1 time here.
@@ -1,5 +1,7 @@ | |||
//! Wrapper type for partially-`unsafe` usage of `T: !Send`. | |||
|
|||
#![expect(unsafe_code)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cuprate_blockchain
uses unsafe
for UnsafeSendable
.
clippy::significant_drop_tightening | ||
clippy::significant_drop_tightening, | ||
)] | ||
#![forbid( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cuprate_database
uses unsafe
for:
pub unsafe trait DatabaseRo
heed
The #[expect]
s everywhere may seem a bit messy although it does mean the rest of cuprate_database
is known not to use unsafe
, this may be worth it.
What
#![forbid]
lints for all crates where applicableunsafe_code = "deny"
toCargo.toml
Why
Allows us to uphold certain static invariants within crates, the most useful one being
unsafe_code
.Within the crates that use
unsafe
, only a small portion of the crate needsunsafe
. Notating the files that need it with#[expect(unsafe_code)]
allows the rest of the crate to be known safe (at least the keyword, obviously usingunsafe
incorrectly can cause safe code to be unsafe).I.e. it defines and restricts the
unsafe
interface to certain portions of the crate.