-
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
false positive: question_mark when returning custom Error type #7859
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
I-suggestion-causes-error
Issue: The suggestions provided by this Lint cause an ICE/error when applied
Comments
matthiaskrgr
added
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
I-suggestion-causes-error
Issue: The suggestions provided by this Lint cause an ICE/error when applied
labels
Oct 22, 2021
Code that clippy suggests:
|
@rustbot claim |
dswij
added a commit
to dswij/rust-clippy
that referenced
this issue
Oct 22, 2021
dtolnay
added a commit
to dtolnay/serde-yaml
that referenced
this issue
Oct 23, 2021
rust-lang/rust-clippy#7859 error: this block may be rewritten with the `?` operator --> src/ser.rs:871:9 | 871 | / if self.writer.write_all(s.as_bytes()).is_err() { 872 | | return Err(fmt::Error); 873 | | } | |_________^ help: replace it with: `self.writer.write_all(s.as_bytes())?;` | = note: `-D clippy::question-mark` implied by `-D clippy::all` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#question_mark Clippy's suggested replacement does not compile. error[E0277]: `?` couldn't convert the error to `std::fmt::Error` --> src/ser.rs:871:44 | 871 | self.writer.write_all(s.as_bytes())?; | ^ the trait `std::convert::From<std::io::Error>` is not implemented for `std::fmt::Error` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = note: required because of the requirements on the impl of `std::ops::FromResidual<std::result::Result<std::convert::Infallible, std::io::Error>>` for `std::result::Result<(), std::fmt::Error>` note: required by `std::ops::FromResidual::from_residual` --> nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/try_trait.rs:339:5 | 339 | fn from_residual(residual: R) -> Self; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
dswij
added a commit
to dswij/rust-clippy
that referenced
this issue
Oct 26, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
I-suggestion-causes-error
Issue: The suggestions provided by this Lint cause an ICE/error when applied
Lint name: question_mark
I tried this code:
I expected to see this happen:
There should be no warning.
Error::NoCWD
is my own error type (an enum) and it does not implstd::convert::From<std::io::Error>
or anything like that. So I can't use?
on it directly.Instead, this happened:
Meta
clippy 0.1.58 (68a698b 2021-10-21)
Rust version (
rustc -Vv
):@ rustbot label +I-suggestion-causes-error
The text was updated successfully, but these errors were encountered: