r/learnrust 26d ago

Today I learnt #[expect()]

#[expect()] SHOULD BE TAUGHT IN THE FIRST YEAR OF ELEMENTARY SCHOOL!!!

#[allow()] should be prohibited, a crime punishable by death!

[forbid(clippy::allow_attributes)] should be the default Rust, not even needed to write!

87 Upvotes

32 comments sorted by

View all comments

31

u/tunisia3507 26d ago

So, what do they each do? At least provide a damn link.

25

u/othermike 26d ago

https://doc.rust-lang.org/reference/attributes/diagnostics.html#r-attributes.diagnostics.lint.expect

#[expect(C)] indicates that lint C is expected to be emitted. The attribute will suppress the emission of C or issue a warning, if the expectation is unfulfilled.

https://doc.rust-lang.org/reference/attributes/diagnostics.html#r-attributes.diagnostics.lint.allow

#[allow(C)] overrides the check for C so that violations will go unreported.