diff options
| author | hi-rustin <rustin.liu@gmail.com> | 2021-06-18 15:09:40 +0800 |
|---|---|---|
| committer | hi-rustin <rustin.liu@gmail.com> | 2021-06-18 15:09:40 +0800 |
| commit | 88abd7d81d585ba31cab1ca404a5ed6b44511f98 (patch) | |
| tree | 55606dc550df3ae61e23c55d6d8ca8a74ba1e461 /library/alloc | |
| parent | 1a462831ad4c6966f3baabe5cbf21cb9f330ffc4 (diff) | |
| download | rust-88abd7d81d585ba31cab1ca404a5ed6b44511f98.tar.gz rust-88abd7d81d585ba31cab1ca404a5ed6b44511f98.zip | |
Lint for unused borrows as part of UNUSED_MUST_USE
Diffstat (limited to 'library/alloc')
| -rw-r--r-- | library/alloc/tests/str.rs | 10 | ||||
| -rw-r--r-- | library/alloc/tests/vec.rs | 10 |
2 files changed, 10 insertions, 10 deletions
diff --git a/library/alloc/tests/str.rs b/library/alloc/tests/str.rs index 6df8d8c2f35..a1e819cf8f9 100644 --- a/library/alloc/tests/str.rs +++ b/library/alloc/tests/str.rs @@ -534,7 +534,7 @@ mod slice_index { #[test] #[should_panic] fn test_slice_fail() { - &"中华Việt Nam"[0..2]; + let _ = &"中华Việt Nam"[0..2]; } panic_cases! { @@ -714,13 +714,13 @@ mod slice_index { #[test] #[should_panic(expected = "byte index 1024 is out of bounds of `Lorem ipsum dolor sit amet")] fn test_slice_fail_truncated_1() { - &LOREM_PARAGRAPH[..1024]; + let _ = &LOREM_PARAGRAPH[..1024]; } // check the truncation in the panic message #[test] #[should_panic(expected = "luctus, im`[...]")] fn test_slice_fail_truncated_2() { - &LOREM_PARAGRAPH[..1024]; + let _ = &LOREM_PARAGRAPH[..1024]; } } @@ -735,7 +735,7 @@ fn test_str_slice_rangetoinclusive_ok() { #[should_panic] fn test_str_slice_rangetoinclusive_notok() { let s = "abcαβγ"; - &s[..=3]; + let _ = &s[..=3]; } #[test] @@ -751,7 +751,7 @@ fn test_str_slicemut_rangetoinclusive_ok() { fn test_str_slicemut_rangetoinclusive_notok() { let mut s = "abcαβγ".to_owned(); let s: &mut str = &mut s; - &mut s[..=3]; + let _ = &mut s[..=3]; } #[test] diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs index c203cdafecb..3b723701680 100644 --- a/library/alloc/tests/vec.rs +++ b/library/alloc/tests/vec.rs @@ -542,35 +542,35 @@ fn test_index_out_of_bounds() { #[should_panic] fn test_slice_out_of_bounds_1() { let x = vec![1, 2, 3, 4, 5]; - &x[!0..]; + let _ = &x[!0..]; } #[test] #[should_panic] fn test_slice_out_of_bounds_2() { let x = vec![1, 2, 3, 4, 5]; - &x[..6]; + let _ = &x[..6]; } #[test] #[should_panic] fn test_slice_out_of_bounds_3() { let x = vec![1, 2, 3, 4, 5]; - &x[!0..4]; + let _ = &x[!0..4]; } #[test] #[should_panic] fn test_slice_out_of_bounds_4() { let x = vec![1, 2, 3, 4, 5]; - &x[1..6]; + let _ = &x[1..6]; } #[test] #[should_panic] fn test_slice_out_of_bounds_5() { let x = vec![1, 2, 3, 4, 5]; - &x[3..2]; + let _ = &x[3..2]; } #[test] |
