add test for missing_const_for_fn. fix test stderr

This commit is contained in:
Suyash458 2020-12-09 16:39:33 +05:30
parent 8df11e431b
commit 9f27b74283
2 changed files with 42 additions and 23 deletions

View file

@ -73,7 +73,11 @@ pub fn filter_map_next() {
.next();
}
#[allow(clippy::no_effect)]
#[allow(clippy::short_circuit_statement)]
#[allow(clippy::unnecessary_operation)]
pub fn manual_range_contains() {
let x = 5;
x >= 8 && x < 12;
}
@ -92,7 +96,7 @@ pub fn use_self() {
fn replace_with_default() {
let mut s = String::from("foo");
let _ = std::mem::replace(s, String::default());
let _ = std::mem::replace(&mut s, String::default());
}
fn map_unwrap_or() {
@ -106,6 +110,11 @@ fn map_unwrap_or() {
.unwrap_or(0);
}
// Could be const
fn missing_const_for_fn() -> i32 {
1
}
fn main() {
filter_map_next();
checked_conversion();
@ -120,6 +129,7 @@ fn main() {
use_self();
replace_with_default();
map_unwrap_or();
missing_const_for_fn();
}
mod meets_msrv {

View file

@ -1,28 +1,37 @@
error[E0425]: cannot find value `x` in this scope
--> $DIR/min_rust_version_attr.rs:77:5
error: stripping a prefix manually
--> $DIR/min_rust_version_attr.rs:142:24
|
LL | x >= 8 && x < 12;
| ^ not found in this scope
error[E0425]: cannot find value `x` in this scope
--> $DIR/min_rust_version_attr.rs:77:15
LL | assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
| ^^^^^^^^^^^^^^^^^^^^
|
LL | x >= 8 && x < 12;
| ^ not found in this scope
error[E0308]: mismatched types
--> $DIR/min_rust_version_attr.rs:95:31
= note: `-D clippy::manual-strip` implied by `-D warnings`
note: the prefix was tested here
--> $DIR/min_rust_version_attr.rs:141:9
|
LL | let _ = std::mem::replace(s, String::default());
| ^
| |
| expected `&mut _`, found struct `std::string::String`
| help: consider mutably borrowing here: `&mut s`
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!");
|
= note: expected mutable reference `&mut _`
found struct `std::string::String`
error: aborting due to 3 previous errors
error: stripping a prefix manually
--> $DIR/min_rust_version_attr.rs:154:24
|
LL | assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
| ^^^^^^^^^^^^^^^^^^^^
|
note: the prefix was tested here
--> $DIR/min_rust_version_attr.rs:153: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
Some errors have detailed explanations: E0308, E0425.
For more information about an error, try `rustc --explain E0308`.