-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathincompatible_msrv.rs
113 lines (95 loc) · 3.06 KB
/
incompatible_msrv.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#![warn(clippy::incompatible_msrv)]
#![feature(custom_inner_attributes)]
#![allow(stable_features)]
#![feature(strict_provenance)] // For use in test
#![clippy::msrv = "1.3.0"]
use std::collections::HashMap;
use std::collections::hash_map::Entry;
use std::future::Future;
use std::thread::sleep;
use std::time::Duration;
fn foo() {
let mut map: HashMap<&str, u32> = HashMap::new();
assert_eq!(map.entry("poneyland").key(), &"poneyland");
//~^ incompatible_msrv
//~| NOTE: `-D clippy::incompatible-msrv` implied by `-D warnings`
//~| HELP: to override `-D warnings` add `#[allow(clippy::incompatible_msrv)]`
if let Entry::Vacant(v) = map.entry("poneyland") {
v.into_key();
//~^ incompatible_msrv
}
// Should warn for `sleep` but not for `Duration` (which was added in `1.3.0`).
sleep(Duration::new(1, 0));
//~^ incompatible_msrv
}
#[test]
fn test() {
sleep(Duration::new(1, 0));
}
#[clippy::msrv = "1.63.0"]
async fn issue12273(v: impl Future<Output = ()>) {
// `.await` desugaring has a call to `IntoFuture::into_future` marked #[stable(since = "1.64.0")],
// but its stability is ignored
v.await;
}
fn core_special_treatment(p: bool) {
// Do not lint code coming from `core` macros expanding into `core` function calls
if p {
panic!("foo"); // Do not lint
}
// But still lint code calling `core` functions directly
if p {
let _ = core::iter::once_with(|| 0);
//~^ incompatible_msrv
}
// Lint code calling `core` from non-`core` macros
macro_rules! my_panic {
($msg:expr) => {
let _ = core::iter::once_with(|| $msg);
//~^ incompatible_msrv
};
}
my_panic!("foo");
// Lint even when the macro comes from `core` and calls `core` functions
assert!(core::iter::once_with(|| 0).next().is_some());
//~^ incompatible_msrv
}
#[clippy::msrv = "1.26.0"]
fn lang_items() {
// Do not lint lang items. `..=` will expand into `RangeInclusive::new()`, which was introduced
// in Rust 1.27.0.
let _ = 1..=3;
}
#[clippy::msrv = "1.80.0"]
fn issue14212() {
let _ = std::iter::repeat_n((), 5);
//~^ incompatible_msrv
}
fn local_msrv_change_suggestion() {
let _ = std::iter::repeat_n((), 5);
//~^ incompatible_msrv
#[cfg(any(test, not(test)))]
{
let _ = std::iter::repeat_n((), 5);
//~^ incompatible_msrv
//~| NOTE: you may want to conditionally increase the MSRV
// Emit the additional note only once
let _ = std::iter::repeat_n((), 5);
//~^ incompatible_msrv
}
}
#[clippy::msrv = "1.78.0"]
fn feature_enable_14425(ptr: *const u8) -> usize {
// Do not warn, because it is enabled through a feature even though
// it is stabilized only since Rust 1.84.0.
let r = ptr.addr();
// Warn about this which has been introduced in the same Rust version
// but is not allowed through a feature.
r.isqrt()
//~^ incompatible_msrv
}
fn non_fn_items() {
let _ = std::io::ErrorKind::CrossesDevices;
//~^ incompatible_msrv
}
fn main() {}