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 struct FromOverInto(String);
62 impl Into<FromOverInto> for String {
63 fn into(self) -> FromOverInto {
68 pub fn filter_map_next() {
69 let a = ["1", "lol", "3", "NaN", "5"];
72 let _: Option<u32> = vec![1, 2, 3, 4, 5, 6]
84 #[allow(clippy::no_effect)]
85 #[allow(clippy::short_circuit_statement)]
86 #[allow(clippy::unnecessary_operation)]
87 pub fn manual_range_contains() {
105 fn replace_with_default() {
106 let mut s = String::from("foo");
107 let _ = std::mem::replace(&mut s, String::default());
113 // Check for `option.map(_).unwrap_or(_)` use.
117 // Should lint even though this call is on a separate line.
122 fn missing_const_for_fn() -> i32 {
126 fn unnest_or_patterns() {
128 if let TS(0, x) | TS(1, x) = TS(0, 0) {}
133 checked_conversion();
134 redundant_fieldnames();
135 redundant_static_lifetime();
136 option_as_ref_deref();
137 match_like_matches();
141 manual_range_contains();
143 replace_with_default();
145 missing_const_for_fn();
146 unnest_or_patterns();
150 #![feature(custom_inner_attributes)]
151 #![clippy::msrv = "1.45.0"]
154 let s = "hello, world!";
155 if s.starts_with("hello, ") {
156 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
161 mod just_under_msrv {
162 #![feature(custom_inner_attributes)]
163 #![clippy::msrv = "1.46.0"]
166 let s = "hello, world!";
167 if s.starts_with("hello, ") {
168 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
173 mod just_above_msrv {
174 #![feature(custom_inner_attributes)]
175 #![clippy::msrv = "1.44.0"]
178 let s = "hello, world!";
179 if s.starts_with("hello, ") {
180 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");