-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Revert: or_fun_call should lint calls to const fn
s with no args
#6077
Conversation
r? @yaahc (rust_highfive has picked a reviewer for you, use r? to override) |
Just making sure I understood correctly; |
@matthiaskrgr that is my understanding, yep |
Ok 👍 @bors r+ |
📌 Commit ce83d8d has been approved by |
How urgent is this, should this be included in rust-lang/rust#77144 ? (pr was not approved yet) |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
I think this can wait as it's just avoiding false negatives |
Disabling `clippy::or_fun_call` lint for calls to const functions was done with an incorrect understanding that const fns with non arguments would be guaranteed to be const evaluated. This is not the case. See rust-lang/rust-clippy#6077. The revert of this behavior in `clippy::or_fun_call` will land in Rust 1.49.0 due out in a week. This commit removes the pragmas to disable the lint and modifies all callsites to use the lazy `ok_or_else` variant. This commit reverts a change made in #794 and 9a8c14c.
The changes in #5889 and #5984 were done under the incorrect assumption that a
const fn
with no args was guaranteed to be evaluated at compile time. Aconst fn
is only guaranteed to be evaluated at compile time if it's inside a const context (the initializer of aconst
or astatic
).See this zulip conversation for more details on this common misconception.
Given that none of the linted methods by
or_fun_call
can be called in const contexts, the lint should make no exceptions.changelog: [
or_fun_call
] lints again calls toconst fn
with no args