add more tests for msrv

This commit is contained in:
Suyash458 2020-11-29 17:08:56 +05:30
parent af095db64c
commit 61b29281e7
2 changed files with 74 additions and 1 deletions

View file

@ -35,7 +35,7 @@ fn match_same_arms2() {
};
}
fn manual_strip_msrv() {
pub fn manual_strip_msrv() {
let s = "hello, world!";
if s.starts_with("hello, ") {
assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
@ -49,3 +49,39 @@ fn main() {
match_same_arms2();
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!");
}
}
}

View 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