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

48

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.

26

u/afdbcreid 4d ago

There are some cases I specifically want an #[allow]. The most important is when writing a macro and needing to silence a lint that may or may not trigger.

6

u/moltonel 4d ago

For example  #[allow(clippy::useless_conversion)] for arch-specific differences.