diff options
Diffstat (limited to 'src/tools/clippy/src/docs/redundant_pattern_matching.txt')
-rw-r--r-- | src/tools/clippy/src/docs/redundant_pattern_matching.txt | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/src/tools/clippy/src/docs/redundant_pattern_matching.txt b/src/tools/clippy/src/docs/redundant_pattern_matching.txt deleted file mode 100644 index 77b1021e0..000000000 --- a/src/tools/clippy/src/docs/redundant_pattern_matching.txt +++ /dev/null @@ -1,45 +0,0 @@ -### What it does -Lint for redundant pattern matching over `Result`, `Option`, -`std::task::Poll` or `std::net::IpAddr` - -### Why is this bad? -It's more concise and clear to just use the proper -utility function - -### Known problems -This will change the drop order for the matched type. Both `if let` and -`while let` will drop the value at the end of the block, both `if` and `while` will drop the -value before entering the block. For most types this change will not matter, but for a few -types this will not be an acceptable change (e.g. locks). See the -[reference](https://doc.rust-lang.org/reference/destructors.html#drop-scopes) for more about -drop order. - -### Example -``` -if let Ok(_) = Ok::<i32, i32>(42) {} -if let Err(_) = Err::<i32, i32>(42) {} -if let None = None::<()> {} -if let Some(_) = Some(42) {} -if let Poll::Pending = Poll::Pending::<()> {} -if let Poll::Ready(_) = Poll::Ready(42) {} -if let IpAddr::V4(_) = IpAddr::V4(Ipv4Addr::LOCALHOST) {} -if let IpAddr::V6(_) = IpAddr::V6(Ipv6Addr::LOCALHOST) {} -match Ok::<i32, i32>(42) { - Ok(_) => true, - Err(_) => false, -}; -``` - -The more idiomatic use would be: - -``` -if Ok::<i32, i32>(42).is_ok() {} -if Err::<i32, i32>(42).is_err() {} -if None::<()>.is_none() {} -if Some(42).is_some() {} -if Poll::Pending::<()>.is_pending() {} -if Poll::Ready(42).is_ready() {} -if IpAddr::V4(Ipv4Addr::LOCALHOST).is_ipv4() {} -if IpAddr::V6(Ipv6Addr::LOCALHOST).is_ipv6() {} -Ok::<i32, i32>(42).is_ok(); -```
\ No newline at end of file |