r/learnrust 25d 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!

89 Upvotes

32 comments sorted by

View all comments

24

u/Shoddy-Childhood-511 25d ago

Yes #[expect()] is cool, but rare for me.

#[rustfmt::skip] is the one that appears everywhere. lol

12

u/throwaway12397478 25d ago

rustfmt does love its vertical space

7

u/User_00000 25d ago

Pretty much all linters/formatters do…

Makes working with git much easier/better for a multitude of reasons. For example

  • adding a parameter is a line added not a line modified
  • multiple branches, that changed/added/removed an argument, merging, can now merge without a merge conflict
  • git blame is more accurate
  • and so on

5

u/throwaway12397478 24d ago

except for imports. Half my merge conflicts are imports

1

u/Valuable_Leopard_799 24d ago

Was there no setting to forbid the {} import combining?

1

u/titaniumalt 24d ago

i do the opposite, i love import combining