Comments (7)
Right the suggestion will introduce more errors. Could we limit it to just a warning and suspicious?
from rust-clippy.
I accidentally created such a bug and the only reason I caught it was because my condition was _ => if ...
and not (_, 1) => if ...
, and thus rustc complained about the final wildcard being unreachable.
from rust-clippy.
This may catch bugs, but it would have far too many false positives. For correct code the suggestion conflicts with match_same_arms
/wildcard_in_or_patterns
also
Notably rustfmt does not allow you to have PAT => if ...
, it will always wrap it in a block to reduce the confusion here
from rust-clippy.
IMO the number of false positives would make it unable to be above restriction
A perhaps equivalent restriction lint would be to lint on all uses of guards in match arms
from rust-clippy.
But that's not the same, is it? the intention is basically to disallow pat => if
and pat => { if ... {rest} }
and instead recommend pat if ... => {rest}
from rust-clippy.
The other way, requiring every guard (pat if ... =>
) to become pat if ... => { ... }; pat => { ... }
seems equivalent but less direct than forbidding guards, so instead pat => { if ... { ... } else { ... } }
from rust-clippy.
That makes sense. It feels too restrictive though, doesn't it? It increases nesting by an additional level.
I think we can close this as not to be implemented, but I'd love a way to ensure this accident doesn't happen.
from rust-clippy.
Related Issues (20)
- `--fix` with `-Zthreads=8` on large workspace hangs HOT 1
- Can we not get attribute from other crate? HOT 2
- `manual_unwrap_or_default` suggested fix fails to compile due to missing type annotation
- `let_unit_value` and `no_effect` trigger for static assertions HOT 2
- Paths printed with {:?} instead of .display() HOT 2
- Unit-like structs should not trigger `exhaustive_structs` HOT 2
- rustc_codegen_ssa::mir::locals Unexpected initial operand type
- `missing_const_for_fn` misses some cases with generics involved HOT 1
- Check that the return type and parameters of a trait method without a body are `Sized`
- Warning emitted for non-canonical implementations conflicts with denying implicit and needless returns HOT 1
- box_default causes type error HOT 1
- `overly_complex_bool_expr` triggers wrongly
- cast-lossless suggests calling macro in itself
- clippy-driver acts as a bogus rustc wrapper HOT 2
- lint: Unnecessary intermediary conversion HOT 2
- ICE when using `tracing::debug!("").await` in a non-async fn HOT 2
- `haystack.ends_with(needle)` doesn't silence `clippy::arithmetic_side_effects` caused by `haystack.len()-needle.len()` HOT 1
- Clippy gives unit_arg warning when using `black_box` HOT 4
- string_slice should detect on Cow
- assigning_clones false positive for Option<T> where T uses default clone_from impl HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-clippy.