Skip to content

Commit 2093bf1

Browse files
Add ui test for incompatible_msrv lint
1 parent 6b96de0 commit 2093bf1

File tree

4 files changed

+48
-2
lines changed

4 files changed

+48
-2
lines changed

tests/ui-toml/min_rust_version/min_rust_version.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(clippy::redundant_clone, clippy::unnecessary_operation)]
1+
#![allow(clippy::redundant_clone, clippy::unnecessary_operation, clippy::incompatible_msrv)]
22
#![warn(clippy::manual_non_exhaustive, clippy::borrow_as_ptr, clippy::manual_bits)]
33

44
use std::mem::{size_of, size_of_val};

tests/ui-toml/min_rust_version/min_rust_version.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(clippy::redundant_clone, clippy::unnecessary_operation)]
1+
#![allow(clippy::redundant_clone, clippy::unnecessary_operation, clippy::incompatible_msrv)]
22
#![warn(clippy::manual_non_exhaustive, clippy::borrow_as_ptr, clippy::manual_bits)]
33

44
use std::mem::{size_of, size_of_val};

tests/ui/incompatible_msrv.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#![warn(clippy::incompatible_msrv)]
2+
#![feature(custom_inner_attributes)]
3+
#![clippy::msrv = "1.3.0"]
4+
5+
use std::collections::hash_map::Entry;
6+
use std::collections::HashMap;
7+
use std::thread::sleep;
8+
use std::time::Duration;
9+
10+
fn foo() {
11+
let mut map: HashMap<&str, u32> = HashMap::new();
12+
// Stable since 1.10, so should not warn.
13+
assert_eq!(map.entry("poneyland").key(), &"poneyland");
14+
if let Entry::Vacant(v) = map.entry("poneyland") {
15+
v.into_key();
16+
//~^ ERROR: MSRV is `1.3.0` but this item is stable since `1.12.0`
17+
}
18+
// Should warn for `sleep` but not for `Duration` (which was added in `1.3.0`).
19+
sleep(Duration::new(1, 0));
20+
//~^ ERROR: MSRV is `1.3.0` but this item is stable since `1.4.0`
21+
}
22+
23+
fn main() {}

tests/ui/incompatible_msrv.stderr

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error: current MSRV is `1.3.0` but this item is stable since `1.10.0`
2+
--> $DIR/incompatible_msrv.rs:13:39
3+
|
4+
LL | assert_eq!(map.entry("poneyland").key(), &"poneyland");
5+
| ^^^^^
6+
|
7+
= note: `-D clippy::incompatible-msrv` implied by `-D warnings`
8+
= help: to override `-D warnings` add `#[allow(clippy::incompatible_msrv)]`
9+
10+
error: current MSRV is `1.3.0` but this item is stable since `1.12.0`
11+
--> $DIR/incompatible_msrv.rs:15:11
12+
|
13+
LL | v.into_key();
14+
| ^^^^^^^^^^
15+
16+
error: current MSRV is `1.3.0` but this item is stable since `1.4.0`
17+
--> $DIR/incompatible_msrv.rs:19:5
18+
|
19+
LL | sleep(Duration::new(1, 0));
20+
| ^^^^^
21+
22+
error: aborting due to 3 previous errors
23+

0 commit comments

Comments
 (0)