-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 on or_fun_call lint with enum constructor. #1338
Comments
A lot of the clippy lints get turned off within macros. |
This isn't a false positive fwiw, since clippy has no idea how expensive that function call is. |
Can it not check that it's just an enum constructor? I feel like this should definitely be improved, as this is something that will come up a lot more often, as you often have Options that you want to turn into proper Results before using the ? operator on them. |
Fair point. I'm editing the bug report. |
So how could we determine something is a struct/enum constructor? fn name == return type name? |
here's how we do it in miri: https://github.com/solson/miri/blob/ac2bf50f9d853a56ff1a236d456619b2d3b65b64/src/terminator/mod.rs#L236 |
This also applies to
EDIT: maybe not, this yields a different type. |
This is actually a false posative where clippy thinks an enum constructor is a function call: rust-lang/rust-clippy#1338
This should have been fixed by #919, but wasn't, because that only deals with const promotable things. I'll make a PR. |
Ignore non-const ctor expressions in or_fn_call Fixes #1338 Should have been fixed by #919, however that focuses on const ctor expressions only, and `.or(Some(local))` isn't const. This also automatically ignores things like `.or(Some(local.clone())` which we don't actually want to do; I need to figure out what to do here. changelog: Fixed false positive in [`or_fn_call`] pertaining to enum variant constructors r? @oli-obk @phansch
Ignore non-const ctor expressions in or_fn_call Fixes #1338 Should have been fixed by #919, however that focuses on const ctor expressions only, and `.or(Some(local))` isn't const. This also automatically ignores things like `.or(Some(local.clone())` which we don't actually want to do; I need to figure out what to do here. changelog: Fixed false positive in [`or_fn_call`] pertaining to enum variant constructors r? @oli-obk @phansch
Ignore non-const ctor expressions in or_fn_call Fixes #1338 Should have been fixed by #919, however that focuses on const ctor expressions only, and `.or(Some(local))` isn't const. This also automatically ignores things like `.or(Some(local.clone())` which we don't actually want to do; I need to figure out what to do here. changelog: Fixed false positive in [`or_fn_call`] pertaining to enum variant constructors r? @oli-obk @phansch
or_fn_call
shouldn't warn in case the function is just an enum constructor wrapping over local variables.Here's the code:
Warning:
Here's the link to the code in the custom playground: Playground
The text was updated successfully, but these errors were encountered: