Closed
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