1 #![allow(clippy::redundant_clone)]
2 #![feature(custom_inner_attributes)]
3 #![clippy::msrv = "1.0.0"]
5 use std::ops::{Deref, RangeFrom};
7 fn option_as_ref_deref() {
8 let mut opt = Some(String::from("123"));
10 let _ = opt.as_ref().map(String::as_str);
11 let _ = opt.as_ref().map(|x| x.as_str());
12 let _ = opt.as_mut().map(String::as_mut_str);
13 let _ = opt.as_mut().map(|x| x.as_mut_str());
16 fn match_like_matches() {
17 let _y = match Some(5) {
23 fn match_same_arms() {
26 (.., 3) => 42, //~ ERROR match arms have same body
31 fn match_same_arms2() {
32 let _ = match Some(42) {
34 None => 24, //~ ERROR match arms have same body
38 pub fn manual_strip_msrv() {
39 let s = "hello, world!";
40 if s.starts_with("hello, ") {
41 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
45 pub fn redundant_fieldnames() {
47 let _ = RangeFrom { start: start };
50 pub fn redundant_static_lifetime() {
51 const VAR_ONE: &'static str = "Test constant #1";
54 pub fn checked_conversion() {
56 let _ = value <= (u32::max_value() as i64) && value >= 0;
57 let _ = value <= (u32::MAX as i64) && value >= 0;
60 pub fn filter_map_next() {
61 let a = ["1", "lol", "3", "NaN", "5"];
64 let _: Option<u32> = vec![1, 2, 3, 4, 5, 6]
76 pub fn manual_range_contains() {
93 fn replace_with_default() {
94 let mut s = String::from("foo");
95 let _ = std::mem::replace(s, String::default());
101 // Check for `option.map(_).unwrap_or(_)` use.
105 // Should lint even though this call is on a separate line.
111 checked_conversion();
112 redundant_fieldnames();
113 redundant_static_lifetime();
114 option_as_ref_deref();
115 match_like_matches();
119 manual_range_contains();
121 replace_with_default();
126 #![feature(custom_inner_attributes)]
127 #![clippy::msrv = "1.45.0"]
130 let s = "hello, world!";
131 if s.starts_with("hello, ") {
132 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
137 mod just_under_msrv {
138 #![feature(custom_inner_attributes)]
139 #![clippy::msrv = "1.46.0"]
142 let s = "hello, world!";
143 if s.starts_with("hello, ") {
144 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
149 mod just_above_msrv {
150 #![feature(custom_inner_attributes)]
151 #![clippy::msrv = "1.44.0"]
154 let s = "hello, world!";
155 if s.starts_with("hello, ") {
156 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");