Skip to content

Commit 61b2928

Browse files
committed
add more tests for msrv
1 parent af095db commit 61b2928

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

tests/ui/min_rust_version_attr.rs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn match_same_arms2() {
3535
};
3636
}
3737

38-
fn manual_strip_msrv() {
38+
pub fn manual_strip_msrv() {
3939
let s = "hello, world!";
4040
if s.starts_with("hello, ") {
4141
assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
@@ -49,3 +49,39 @@ fn main() {
4949
match_same_arms2();
5050
manual_strip_msrv();
5151
}
52+
53+
mod meets_msrv {
54+
#![feature(custom_inner_attributes)]
55+
#![clippy::msrv = "1.45.0"]
56+
57+
fn main() {
58+
let s = "hello, world!";
59+
if s.starts_with("hello, ") {
60+
assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
61+
}
62+
}
63+
}
64+
65+
mod just_under_msrv {
66+
#![feature(custom_inner_attributes)]
67+
#![clippy::msrv = "1.46.0"]
68+
69+
fn main() {
70+
let s = "hello, world!";
71+
if s.starts_with("hello, ") {
72+
assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
73+
}
74+
}
75+
}
76+
77+
mod just_above_msrv {
78+
#![feature(custom_inner_attributes)]
79+
#![clippy::msrv = "1.44.0"]
80+
81+
fn main() {
82+
let s = "hello, world!";
83+
if s.starts_with("hello, ") {
84+
assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
85+
}
86+
}
87+
}

tests/ui/min_rust_version_attr.stderr

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
error: stripping a prefix manually
2+
--> $DIR/min_rust_version_attr.rs:60:24
3+
|
4+
LL | assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: `-D clippy::manual-strip` implied by `-D warnings`
8+
note: the prefix was tested here
9+
--> $DIR/min_rust_version_attr.rs:59:9
10+
|
11+
LL | if s.starts_with("hello, ") {
12+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13+
help: try using the `strip_prefix` method
14+
|
15+
LL | if let Some(<stripped>) = s.strip_prefix("hello, ") {
16+
LL | assert_eq!(<stripped>.to_uppercase(), "WORLD!");
17+
|
18+
19+
error: stripping a prefix manually
20+
--> $DIR/min_rust_version_attr.rs:72:24
21+
|
22+
LL | assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
23+
| ^^^^^^^^^^^^^^^^^^^^
24+
|
25+
note: the prefix was tested here
26+
--> $DIR/min_rust_version_attr.rs:71:9
27+
|
28+
LL | if s.starts_with("hello, ") {
29+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30+
help: try using the `strip_prefix` method
31+
|
32+
LL | if let Some(<stripped>) = s.strip_prefix("hello, ") {
33+
LL | assert_eq!(<stripped>.to_uppercase(), "WORLD!");
34+
|
35+
36+
error: aborting due to 2 previous errors
37+

0 commit comments

Comments
 (0)