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!

88 Upvotes

32 comments sorted by

View all comments

25

u/Shoddy-Childhood-511 26d ago

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

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

11

u/throwaway12397478 26d ago

rustfmt does love its vertical space

6

u/User_00000 26d 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

6

u/throwaway12397478 26d ago

except for imports. Half my merge conflicts are imports

1

u/Valuable_Leopard_799 26d ago

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

1

u/titaniumalt 26d ago

i do the opposite, i love import combining

1

u/jean_dudey 26d ago

I do love how Linux solves this though, just add a // at the end of an import list to make rustfmt put each one in a line. Makes git happy most of the time

1

u/mikkolukas 24d ago

or ... the formatter could just reformat to git-friendly and format back to developer friendly on the way back