Auto merge of #10391 - ldm0:ldm0_fix_unwrap_in_tests, r=xFrednet
Fix test function checker in `unwrap_used`, `expect_used` After #9686 , `unwrap` and `expect` in integration tests and raw test functions won't be allowed. fixes #10011 fixes #10238 fixes #10264 --- changelog: Fix: [`expect_used`], [`unwrap_used`], [`dbg_macro`], [`print_stdout`], [`print_stderr`]: No longer lint in test functions, if the related configuration is set [#10391](https://github.com/rust-lang/rust-clippy/pull/10391) <!-- changelog_checked -->
This commit is contained in:
commit
b528cc90bc
7 changed files with 38 additions and 14 deletions
|
|
@ -16,6 +16,18 @@ fn main() {
|
|||
expect_result();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_expect_option() {
|
||||
let opt = Some(0);
|
||||
let _ = opt.expect("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_expect_result() {
|
||||
let res: Result<u8, ()> = Ok(0);
|
||||
let _ = res.expect("");
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod issue9612 {
|
||||
// should not lint in `#[cfg(test)]` modules
|
||||
|
|
|
|||
|
|
@ -66,6 +66,12 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
let boxed_slice: Box<[u8]> = Box::new([0, 1, 2, 3]);
|
||||
let _ = boxed_slice.get(1).unwrap();
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod issue9612 {
|
||||
// should not lint in `#[cfg(test)]` modules
|
||||
|
|
|
|||
|
|
@ -188,10 +188,16 @@ LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec();
|
|||
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
|
||||
|
||||
error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
|
||||
--> $DIR/unwrap_used.rs:84:17
|
||||
--> $DIR/unwrap_used.rs:72:13
|
||||
|
|
||||
LL | let _ = boxed_slice.get(1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&boxed_slice[1]`
|
||||
|
||||
error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
|
||||
--> $DIR/unwrap_used.rs:90:17
|
||||
|
|
||||
LL | let _ = Box::new([0]).get(1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&Box::new([0])[1]`
|
||||
|
||||
error: aborting due to 27 previous errors
|
||||
error: aborting due to 28 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue