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 {
128 checked_conversion();
129 redundant_fieldnames();
130 redundant_static_lifetime();
131 option_as_ref_deref();
132 match_like_matches();
136 manual_range_contains();
138 replace_with_default();
140 missing_const_for_fn();
144 #![feature(custom_inner_attributes)]
145 #![clippy::msrv = "1.45.0"]
148 let s = "hello, world!";
149 if s.starts_with("hello, ") {
150 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
155 mod just_under_msrv {
156 #![feature(custom_inner_attributes)]
157 #![clippy::msrv = "1.46.0"]
160 let s = "hello, world!";
161 if s.starts_with("hello, ") {
162 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
167 mod just_above_msrv {
168 #![feature(custom_inner_attributes)]
169 #![clippy::msrv = "1.44.0"]
172 let s = "hello, world!";
173 if s.starts_with("hello, ") {
174 assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");