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 #[allow(clippy::no_effect)]
77 #[allow(clippy::short_circuit_statement)]
78 #[allow(clippy::unnecessary_operation)]
79 pub fn manual_range_contains() {
97 fn replace_with_default() {
98 let mut s = String::from("foo");
99 let _ = std::mem::replace(&mut s, String::default());
105 // Check for `option.map(_).unwrap_or(_)` use.
109 // Should lint even though this call is on a separate line.
114 fn missing_const_for_fn() -> i32 {
120 checked_conversion();
121 redundant_fieldnames();
122 redundant_static_lifetime();
123 option_as_ref_deref();
124 match_like_matches();
128 manual_range_contains();
130 replace_with_default();
132 missing_const_for_fn();
136 #![feature(custom_inner_attributes)]
137 #![clippy::msrv = "1.45.0"]
140 let s = "hello, world!";
141 if s.starts_with("hello, ") {
142 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
147 mod just_under_msrv {
148 #![feature(custom_inner_attributes)]
149 #![clippy::msrv = "1.46.0"]
152 let s = "hello, world!";
153 if s.starts_with("hello, ") {
154 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
159 mod just_above_msrv {
160 #![feature(custom_inner_attributes)]
161 #![clippy::msrv = "1.44.0"]
164 let s = "hello, world!";
165 if s.starts_with("hello, ") {
166 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");