1 #![allow(clippy::redundant_clone)]
2 #![feature(custom_inner_attributes)]
3 #![clippy::msrv = "1.0.0"]
5 use std::ops::{Deref, RangeFrom};
8 let log2_10 = 3.321928094887362;
9 let log10_2 = 0.301029995663981;
12 fn cloned_instead_of_copied() {
13 let _ = [1].iter().cloned();
16 fn option_as_ref_deref() {
17 let mut opt = Some(String::from("123"));
19 let _ = opt.as_ref().map(String::as_str);
20 let _ = opt.as_ref().map(|x| x.as_str());
21 let _ = opt.as_mut().map(String::as_mut_str);
22 let _ = opt.as_mut().map(|x| x.as_mut_str());
25 fn match_like_matches() {
26 let _y = match Some(5) {
32 fn match_same_arms() {
35 (.., 3) => 42, //~ ERROR match arms have same body
40 fn match_same_arms2() {
41 let _ = match Some(42) {
43 None => 24, //~ ERROR match arms have same body
47 pub fn manual_strip_msrv() {
48 let s = "hello, world!";
49 if s.starts_with("hello, ") {
50 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
54 pub fn redundant_fieldnames() {
56 let _ = RangeFrom { start: start };
59 pub fn redundant_static_lifetime() {
60 const VAR_ONE: &'static str = "Test constant #1";
63 pub fn checked_conversion() {
65 let _ = value <= (u32::max_value() as i64) && value >= 0;
66 let _ = value <= (u32::MAX as i64) && value >= 0;
69 pub struct FromOverInto(String);
71 impl Into<FromOverInto> for String {
72 fn into(self) -> FromOverInto {
77 pub fn filter_map_next() {
78 let a = ["1", "lol", "3", "NaN", "5"];
81 let _: Option<u32> = vec![1, 2, 3, 4, 5, 6]
93 #[allow(clippy::no_effect)]
94 #[allow(clippy::short_circuit_statement)]
95 #[allow(clippy::unnecessary_operation)]
96 pub fn manual_range_contains() {
114 fn replace_with_default() {
115 let mut s = String::from("foo");
116 let _ = std::mem::replace(&mut s, String::default());
122 // Check for `option.map(_).unwrap_or(_)` use.
126 // Should lint even though this call is on a separate line.
131 fn missing_const_for_fn() -> i32 {
135 fn unnest_or_patterns() {
137 if let TS(0, x) | TS(1, x) = TS(0, 0) {}
142 checked_conversion();
143 redundant_fieldnames();
144 redundant_static_lifetime();
145 option_as_ref_deref();
146 match_like_matches();
150 manual_range_contains();
152 replace_with_default();
154 missing_const_for_fn();
155 unnest_or_patterns();
159 #![feature(custom_inner_attributes)]
160 #![clippy::msrv = "1.45.0"]
163 let s = "hello, world!";
164 if s.starts_with("hello, ") {
165 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
170 mod just_under_msrv {
171 #![feature(custom_inner_attributes)]
172 #![clippy::msrv = "1.46.0"]
175 let s = "hello, world!";
176 if s.starts_with("hello, ") {
177 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
182 mod just_above_msrv {
183 #![feature(custom_inner_attributes)]
184 #![clippy::msrv = "1.44.0"]
187 let s = "hello, world!";
188 if s.starts_with("hello, ") {
189 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");