| #![warn(clippy::redundant_pattern_matching)] | |
| #![allow( | |
| clippy::match_like_matches_macro, | |
| clippy::needless_bool, | |
| clippy::needless_ifs, | |
| clippy::uninlined_format_args | |
| )] | |
| use std::net::IpAddr::{self, V4, V6}; | |
| use std::net::{Ipv4Addr, Ipv6Addr}; | |
| fn main() { | |
| let ipaddr: IpAddr = V4(Ipv4Addr::LOCALHOST); | |
| if ipaddr.is_ipv4() {} | |
| //~^ redundant_pattern_matching | |
| if V4(Ipv4Addr::LOCALHOST).is_ipv4() {} | |
| //~^ redundant_pattern_matching | |
| if V6(Ipv6Addr::LOCALHOST).is_ipv6() {} | |
| //~^ redundant_pattern_matching | |
| // Issue 6459 | |
| if V4(Ipv4Addr::LOCALHOST).is_ipv4() {} | |
| //~^ redundant_pattern_matching | |
| // Issue 6459 | |
| if V6(Ipv6Addr::LOCALHOST).is_ipv6() {} | |
| //~^ redundant_pattern_matching | |
| while V4(Ipv4Addr::LOCALHOST).is_ipv4() {} | |
| //~^ redundant_pattern_matching | |
| while V6(Ipv6Addr::LOCALHOST).is_ipv6() {} | |
| //~^ redundant_pattern_matching | |
| if V4(Ipv4Addr::LOCALHOST).is_ipv4() {} | |
| if V6(Ipv6Addr::LOCALHOST).is_ipv6() {} | |
| if let V4(ipaddr) = V4(Ipv4Addr::LOCALHOST) { | |
| println!("{}", ipaddr); | |
| } | |
| V4(Ipv4Addr::LOCALHOST).is_ipv4(); | |
| V4(Ipv4Addr::LOCALHOST).is_ipv6(); | |
| V6(Ipv6Addr::LOCALHOST).is_ipv6(); | |
| V6(Ipv6Addr::LOCALHOST).is_ipv4(); | |
| let _ = if V4(Ipv4Addr::LOCALHOST).is_ipv4() { | |
| //~^ redundant_pattern_matching | |
| true | |
| } else { | |
| false | |
| }; | |
| ipaddr_const(); | |
| let _ = if gen_ipaddr().is_ipv4() { | |
| //~^ redundant_pattern_matching | |
| 1 | |
| } else if gen_ipaddr().is_ipv6() { | |
| //~^ redundant_pattern_matching | |
| 2 | |
| } else { | |
| 3 | |
| }; | |
| } | |
| fn gen_ipaddr() -> IpAddr { | |
| V4(Ipv4Addr::LOCALHOST) | |
| } | |
| const fn ipaddr_const() { | |
| if V4(Ipv4Addr::LOCALHOST).is_ipv4() {} | |
| //~^ redundant_pattern_matching | |
| if V6(Ipv6Addr::LOCALHOST).is_ipv6() {} | |
| //~^ redundant_pattern_matching | |
| while V4(Ipv4Addr::LOCALHOST).is_ipv4() {} | |
| //~^ redundant_pattern_matching | |
| while V6(Ipv6Addr::LOCALHOST).is_ipv6() {} | |
| //~^ redundant_pattern_matching | |
| V4(Ipv4Addr::LOCALHOST).is_ipv4(); | |
| V6(Ipv6Addr::LOCALHOST).is_ipv6(); | |
| } |