Closed
Description
Lint name: question_mark
I tried this code:
let mut cwd: PathBuf = if let Ok(cwd) = env::current_dir() {
cwd
} else {
return Err(Error::NoCWD);
};
I expected to see this happen:
There should be no warning.
Error::NoCWD
is my own error type (an enum) and it does not impl std::convert::From<std::io::Error>
or anything like that. So I can't use ?
on it directly.
Instead, this happened:
warning: this if-let-else may be rewritten with the `?` operator
--> src/commands/local.rs:53:28
|
53 | let mut cwd: PathBuf = if let Ok(cwd) = env::current_dir() {
| ____________________________^
54 | | cwd
55 | | } else {
56 | | return Err(Error::NoCWD);
57 | | };
| |_____^ help: replace it with: `env::current_dir()?`
|
note: the lint level is defined here
Meta
clippy 0.1.58 (68a698b 2021-10-21)
rustc 1.58.0-nightly (68a698baf 2021-10-21)
binary: rustc
commit-hash: 68a698baf6bfc61d85ce6e25122a092c60c7f21a
commit-date: 2021-10-21
host: x86_64-unknown-linux-gnu
release: 1.58.0-nightly
LLVM version: 13.0.0
Rust version (rustc -Vv
):
rustc 1.46.0-nightly (f455e46ea 2020-06-20)
binary: rustc
commit-hash: f455e46eae1a227d735091091144601b467e1565
commit-date: 2020-06-20
host: x86_64-unknown-linux-gnu
release: 1.46.0-nightly
LLVM version: 10.0
@ rustbot label +I-suggestion-causes-error