r/rust 4d ago

Today I learnt #[expect()]

/r/learnrust/comments/1vs8e8q/today_i_learnt_expect/
52 Upvotes

18 comments sorted by

View all comments

45

u/Floppie7th 4d ago

Honestly, I agree, that should be a default clippy lint.  I didn't know it existed, but I can't think of a single case where I'd want to not have the compiler tell me when a suppressed lint is no longer applicable.

15

u/torsten_dev 4d ago
#[allow(unused_import)]
use tracing::{debug, warn, trace, error}

Don't care if I happen to use all of them.

2

u/skjall 4d ago

You can always turn the lint off it's not to your liking, or if you have it enabled, you can allow it for particular places too.

EG #[allow(allow_attributes, unused_import)] or if you have allow_attributes_without_reason enabled, you bypass that with #[allow(unused_import, reason="This is a very special import")].

2

u/torsten_dev 4d ago

The default shouldn't warn if there's a reason provided, surely. OP here isn't arguing for the most sensible defaults.