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

False positive assertions_on_constants #5064

Closed
MikailBag opened this issue Jan 18, 2020 · 4 comments
Closed

False positive assertions_on_constants #5064

MikailBag opened this issue Jan 18, 2020 · 4 comments

Comments

@MikailBag
Copy link

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=40fdbfbe2885aeb26531533ee38b450f

While expression can be compile-time evaluated to true, it can make sense to be sure that Foo will always be smaller that Bar.

@JohnTitor
Copy link
Member

JohnTitor commented Jan 20, 2020

Uhm, I feel this isn't false positive, but expected behavior. The more appropriate approach is to use panic!(), unreachable!(), or similar functions/macros.

@flip1995
Copy link
Member

It is expected behavior, how the lint is currently written. A possible change would be to allow comparisons in asserts (only <,<=,>=,>, for the rest there is *_eq/*_ne). We could then add a pedantic lint, that also triggers on comparisons, since this is still a useful lint.

The question now is: Is the lint still useful once comparisons are not linted? Because then it pretty much only lints on literal true/false.

@ghost
Copy link

ghost commented Jan 20, 2020

Maybe continue to lint in the false case but allow the true one since it's useful for documenting assumptions.

@flip1995
Copy link
Member

Duplicate of #8159 , which has some more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants