-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.
Description
or_fn_call
shouldn't warn in case the function is just an enum constructor wrapping over local variables.
Here's the code:
pub enum Error<'a> {
Path(&'a str),
}
pub fn question_mark(path: &str) -> Result<(), Error> {
None.ok_or(Error::Path(path))?;
Ok(())
}
pub fn try(path: &str) -> Result<(), Error> {
try!(None.ok_or(Error::Path(path)));
Ok(())
}
Warning:
Compiling playground v0.0.1 (file:///playground)
warning: use of `ok_or` followed by a function call, #[warn(or_fun_call)] on by default
--> src/main.rs:6:5
|
6 | None.ok_or(Error::Path(path))?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: try this
| None.ok_or_else(|| Error::Path(path))?;
= help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#or_fun_call
Here's the link to the code in the custom playground: Playground
giodamelio and hcpl
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.