Closed
Description
Summary
See details below
Lint Name
question_mark
Reproducer
I tried this code:
src_pad.add_probe(gst::PadProbeType::BUFFER, |_, probe_info| {
if let Some(gst::PadProbeData::Buffer(ref buffer)) = probe_info.data {
let map = buffer.map_readable().unwrap();
let samples = if let Ok(samples) = map.as_slice_of::<i16>() {
samples
} else {
return gst::PadProbeReturn::Ok;
};
[...]
}
gst::PadProbeReturn::Ok
});
I saw this happen:
warning: this if-let-else may be rewritten with the `?` operator
--> examples/src/bin/pad_probes.rs:54:27
|
54 | let samples = if let Ok(samples) = map.as_slice_of::<i16>() {
| ___________________________^
55 | | samples
56 | | } else {
57 | | return gst::PadProbeReturn::Ok;
58 | | };
| |_____________^ help: replace it with: `map.as_slice_of::<i16>()?`
|
= note: `#[warn(clippy::question_mark)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#question_mark
I expected to see this happen: Nothing because the closure does not return a Result
Version
rustc 1.58.0 (02072b482 2022-01-11)
binary: rustc
commit-hash: 02072b482a8b5357f7fb5e5637444ae30e423c40
commit-date: 2022-01-11
host: x86_64-unknown-linux-gnu
release: 1.58.0
LLVM version: 13.0.0
Additional Labels
@rustbot label +I-suggestion-causes-error