Skip to content

Commit

Permalink
Add ui test for incompatible_msrv lint
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jan 25, 2024
1 parent 6b96de0 commit 2093bf1
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/ui-toml/min_rust_version/min_rust_version.fixed
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::redundant_clone, clippy::unnecessary_operation)]
#![allow(clippy::redundant_clone, clippy::unnecessary_operation, clippy::incompatible_msrv)]
#![warn(clippy::manual_non_exhaustive, clippy::borrow_as_ptr, clippy::manual_bits)]

use std::mem::{size_of, size_of_val};
Expand Down
2 changes: 1 addition & 1 deletion tests/ui-toml/min_rust_version/min_rust_version.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::redundant_clone, clippy::unnecessary_operation)]
#![allow(clippy::redundant_clone, clippy::unnecessary_operation, clippy::incompatible_msrv)]
#![warn(clippy::manual_non_exhaustive, clippy::borrow_as_ptr, clippy::manual_bits)]

use std::mem::{size_of, size_of_val};
Expand Down
23 changes: 23 additions & 0 deletions tests/ui/incompatible_msrv.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#![warn(clippy::incompatible_msrv)]
#![feature(custom_inner_attributes)]
#![clippy::msrv = "1.3.0"]

use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::thread::sleep;
use std::time::Duration;

fn foo() {
let mut map: HashMap<&str, u32> = HashMap::new();
// Stable since 1.10, so should not warn.
assert_eq!(map.entry("poneyland").key(), &"poneyland");
if let Entry::Vacant(v) = map.entry("poneyland") {
v.into_key();
//~^ ERROR: MSRV is `1.3.0` but this item is stable since `1.12.0`
}
// Should warn for `sleep` but not for `Duration` (which was added in `1.3.0`).
sleep(Duration::new(1, 0));
//~^ ERROR: MSRV is `1.3.0` but this item is stable since `1.4.0`
}

fn main() {}
23 changes: 23 additions & 0 deletions tests/ui/incompatible_msrv.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
error: current MSRV is `1.3.0` but this item is stable since `1.10.0`
--> $DIR/incompatible_msrv.rs:13:39
|
LL | assert_eq!(map.entry("poneyland").key(), &"poneyland");
| ^^^^^
|
= note: `-D clippy::incompatible-msrv` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::incompatible_msrv)]`

error: current MSRV is `1.3.0` but this item is stable since `1.12.0`
--> $DIR/incompatible_msrv.rs:15:11
|
LL | v.into_key();
| ^^^^^^^^^^

error: current MSRV is `1.3.0` but this item is stable since `1.4.0`
--> $DIR/incompatible_msrv.rs:19:5
|
LL | sleep(Duration::new(1, 0));
| ^^^^^

error: aborting due to 3 previous errors

0 comments on commit 2093bf1

Please sign in to comment.