`Some(a).or(b)` should warn and fix remove the or-part
What it does
Admittedly from AI-generated code, but I guess it can happen during refactoring as well. (I found a single case on grep.app).
The point is that the or-part (and or_else and maybe some more) will never be evaluated. Hence, this indicate either a bug or dead code.
Advantage
The or-clause is dead code.
Drawbacks
None(?)
Example
Some(a).or(b)Could be written as:
Some(a)Comparison with existing lints
If the or contains a function, it will be flagged with or_fun_call, but it is not really the same type of issue.
This is similar to unnecessary_literal_unwrap, but again, not identical.
Additional Context
Probably one should identify all functions that will be dead on a known Some.
Suggestions: is_some and is_none (I've found one if Some(a).is_some() in the wild.)
Maybe this should also hold for None.or(b) etc, although that seems more unlikely that someone will write.
Source: rust-lang/rust-clippy