1 #![allow(clippy::redundant_clone)]
2 #![feature(custom_inner_attributes)]
3 #![clippy::msrv = "1.0.0"]
5 use std::ops::{Deref, RangeFrom};
7 fn cloned_instead_of_copied() {
8 let _ = [1].iter().cloned();
11 fn option_as_ref_deref() {
12 let mut opt = Some(String::from("123"));
14 let _ = opt.as_ref().map(String::as_str);
15 let _ = opt.as_ref().map(|x| x.as_str());
16 let _ = opt.as_mut().map(String::as_mut_str);
17 let _ = opt.as_mut().map(|x| x.as_mut_str());
20 fn match_like_matches() {
21 let _y = match Some(5) {
27 fn match_same_arms() {
30 (.., 3) => 42, //~ ERROR match arms have same body
35 fn match_same_arms2() {
36 let _ = match Some(42) {
38 None => 24, //~ ERROR match arms have same body
42 pub fn manual_strip_msrv() {
43 let s = "hello, world!";
44 if s.starts_with("hello, ") {
45 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
49 pub fn redundant_fieldnames() {
51 let _ = RangeFrom { start: start };
54 pub fn redundant_static_lifetime() {
55 const VAR_ONE: &'static str = "Test constant #1";
58 pub fn checked_conversion() {
60 let _ = value <= (u32::max_value() as i64) && value >= 0;
61 let _ = value <= (u32::MAX as i64) && value >= 0;
64 pub struct FromOverInto(String);
66 impl Into<FromOverInto> for String {
67 fn into(self) -> FromOverInto {
72 pub fn filter_map_next() {
73 let a = ["1", "lol", "3", "NaN", "5"];
76 let _: Option<u32> = vec![1, 2, 3, 4, 5, 6]
88 #[allow(clippy::no_effect)]
89 #[allow(clippy::short_circuit_statement)]
90 #[allow(clippy::unnecessary_operation)]
91 pub fn manual_range_contains() {
109 fn replace_with_default() {
110 let mut s = String::from("foo");
111 let _ = std::mem::replace(&mut s, String::default());
117 // Check for `option.map(_).unwrap_or(_)` use.
121 // Should lint even though this call is on a separate line.
126 fn missing_const_for_fn() -> i32 {
130 fn unnest_or_patterns() {
132 if let TS(0, x) | TS(1, x) = TS(0, 0) {}
137 checked_conversion();
138 redundant_fieldnames();
139 redundant_static_lifetime();
140 option_as_ref_deref();
141 match_like_matches();
145 manual_range_contains();
147 replace_with_default();
149 missing_const_for_fn();
150 unnest_or_patterns();
154 #![feature(custom_inner_attributes)]
155 #![clippy::msrv = "1.45.0"]
158 let s = "hello, world!";
159 if s.starts_with("hello, ") {
160 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
165 mod just_under_msrv {
166 #![feature(custom_inner_attributes)]
167 #![clippy::msrv = "1.46.0"]
170 let s = "hello, world!";
171 if s.starts_with("hello, ") {
172 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
177 mod just_above_msrv {
178 #![feature(custom_inner_attributes)]
179 #![clippy::msrv = "1.44.0"]
182 let s = "hello, world!";
183 if s.starts_with("hello, ") {
184 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");