add more tests for msrv
This commit is contained in:
parent
af095db64c
commit
61b29281e7
@ -35,7 +35,7 @@ fn match_same_arms2() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn manual_strip_msrv() {
|
pub fn manual_strip_msrv() {
|
||||||
let s = "hello, world!";
|
let s = "hello, world!";
|
||||||
if s.starts_with("hello, ") {
|
if s.starts_with("hello, ") {
|
||||||
assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
|
assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
|
||||||
@ -49,3 +49,39 @@ fn main() {
|
|||||||
match_same_arms2();
|
match_same_arms2();
|
||||||
manual_strip_msrv();
|
manual_strip_msrv();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod meets_msrv {
|
||||||
|
#![feature(custom_inner_attributes)]
|
||||||
|
#![clippy::msrv = "1.45.0"]
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let s = "hello, world!";
|
||||||
|
if s.starts_with("hello, ") {
|
||||||
|
assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod just_under_msrv {
|
||||||
|
#![feature(custom_inner_attributes)]
|
||||||
|
#![clippy::msrv = "1.46.0"]
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let s = "hello, world!";
|
||||||
|
if s.starts_with("hello, ") {
|
||||||
|
assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod just_above_msrv {
|
||||||
|
#![feature(custom_inner_attributes)]
|
||||||
|
#![clippy::msrv = "1.44.0"]
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let s = "hello, world!";
|
||||||
|
if s.starts_with("hello, ") {
|
||||||
|
assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
37
tests/ui/min_rust_version_attr.stderr
Normal file
37
tests/ui/min_rust_version_attr.stderr
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
error: stripping a prefix manually
|
||||||
|
--> $DIR/min_rust_version_attr.rs:60:24
|
||||||
|
|
|
||||||
|
LL | assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: `-D clippy::manual-strip` implied by `-D warnings`
|
||||||
|
note: the prefix was tested here
|
||||||
|
--> $DIR/min_rust_version_attr.rs:59:9
|
||||||
|
|
|
||||||
|
LL | if s.starts_with("hello, ") {
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
help: try using the `strip_prefix` method
|
||||||
|
|
|
||||||
|
LL | if let Some(<stripped>) = s.strip_prefix("hello, ") {
|
||||||
|
LL | assert_eq!(<stripped>.to_uppercase(), "WORLD!");
|
||||||
|
|
|
||||||
|
|
||||||
|
error: stripping a prefix manually
|
||||||
|
--> $DIR/min_rust_version_attr.rs:72:24
|
||||||
|
|
|
||||||
|
LL | assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: the prefix was tested here
|
||||||
|
--> $DIR/min_rust_version_attr.rs:71:9
|
||||||
|
|
|
||||||
|
LL | if s.starts_with("hello, ") {
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
help: try using the `strip_prefix` method
|
||||||
|
|
|
||||||
|
LL | if let Some(<stripped>) = s.strip_prefix("hello, ") {
|
||||||
|
LL | assert_eq!(<stripped>.to_uppercase(), "WORLD!");
|
||||||
|
|
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user