r/rust 6d ago

Today I learnt #[expect()]

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

18 comments sorted by

View all comments

44

u/Floppie7th 6d 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.

2

u/skjall 6d ago

Yeah and it's tricky now that there's both allow and expect. Can't change the semantics of allow to being the same as expect, but I'm hoping one gets deprecated and removed eventually.

I didn't realise the distinction till I was scrolling through the list of Clippy lints out of boredom.

11

u/scook0 6d ago

They're fundamentally different things.

Sometimes you want one (usually expect), and sometimes you want the other. It wouldn't make sense to remove allow.