Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unseparated_literal_suffix is very opinion oriented 0u8 versus 0_u8 #7658

Closed
Stargateur opened this issue Sep 10, 2021 · 9 comments · Fixed by #7726
Closed

unseparated_literal_suffix is very opinion oriented 0u8 versus 0_u8 #7658

Stargateur opened this issue Sep 10, 2021 · 9 comments · Fixed by #7726
Assignees
Labels
A-category Area: Categorization of lints good-first-issue These issues are a good way to get started with Clippy

Comments

@Stargateur
Copy link

Stargateur commented Sep 10, 2021

I just found unseparated_literal_suffix with rust-bakery/nom#1387 and I believe this have never been talk about:

  • This has been advice by unnecessary_cast and so I have a problem, 0 as u8 is very clear, clippy lint to just typed the 0 make sense to me, but then advice to add an _ to make it more clear ? when the original code is very clear ?
  • 0u8 is used in a LOT in rust literature without any problem I don't think it's more unclear than 0_u8
  • 0_u8 is longer to write
  • rustfmt doesn't fmt 0u8 to 0_u8
  • there is no talk about this
  • never see 0_u8 anywhere before

Thus I don't understand the lint (and the consequence to other lint) come a little from nowhere in my opinion.

@ghost
Copy link

ghost commented Sep 11, 2021

As far as I can tell, #703 is the original issue for this lint and #1145 is the pull request that implemented it. This lint is more than 5 years old. You've probably never seen it because it's allow by default.

So regarding complaints about "there is no talk about this".
Where did you expect this discussion to happen?
How did you expect to be included in it?

@Stargateur
Copy link
Author

I said I never see 42_u8 before, not the lint itself even if I never see the lint too before. The fact it's 5 years old make it even worse meaning I never see someone apply it in 5 years.

Where did you expect this discussion to happen?
How did you expect to be included in it?

here ?

@ghost
Copy link

ghost commented Sep 11, 2021

I said I never see 42_u8 before, not the lint itself even if I never see the lint too before.

No. You said you'd never see the lint before as well.

I just_found unseparated_literal_suffix ..

..

Where did you expect this discussion to happen?
How did you expect to be included in it?

here ?

Well then this is discussion you're looking for.

..

I don't have any more time for this issue. Good luck getting this lint changed/removed.

@Stargateur
Copy link
Author

Well you kill my wish to make thing better, don't be surprise when people complain about clippy more and more.

@ghost
Copy link

ghost commented Sep 13, 2021

You should reopen this issue as there may be interest in changing it from someone on the team.

I wished you luck because I don't like this lint either. Maybe you thought I was being sarcastic.

@Stargateur Stargateur reopened this Sep 13, 2021
@camsteffen
Copy link
Contributor

I agree - unseparated_literal_suffix is founded on a style assertion that is not well supported outside of Clippy, and one could reasonably have the opposite opinion. Such lints should be in the restriction category.

I think the ability to separate the type with an underscore is an accidental consequence of a language feature intended for grouping like 1_000_000, but I have no proof of this.

@camsteffen camsteffen added A-category Area: Categorization of lints good-first-issue These issues are a good way to get started with Clippy labels Sep 14, 2021
@dswij
Copy link
Member

dswij commented Sep 20, 2021

I think it would be better if unseparated_literal_sufix enforce a consistent style throughout a project, rather than only accepting a style. (and move it to style category, if that makes sense?)

Perhaps we can have a configuration for the lint that specifies said enforced style.

@camsteffen
Copy link
Contributor

I think this is an issue where multiple acceptable opinions exist, and therefore it needs to be a restriction lint. We should support the opposing opinion through a config option or another lint. Related: rust-lang/style-team#155.

@dswij
Copy link
Member

dswij commented Sep 20, 2021

Makes sense. I will try to have a look on this.

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-category Area: Categorization of lints good-first-issue These issues are a good way to get started with Clippy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants