Skip to content

Commit 63c7491

Browse files
committed
Auto merge of rust-lang#86426 - hi-rustin:rustin-patch-lint-warn, r=Aaron1011
Lint for unused borrows as part of UNUSED_MUST_USE close rust-lang#76264 base on rust-lang#76894 r? `@RalfJung`
2 parents 951637c + 9a1bdc0 commit 63c7491

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

alloc/tests/str.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ mod slice_index {
534534
#[test]
535535
#[should_panic]
536536
fn test_slice_fail() {
537-
&"中华Việt Nam"[0..2];
537+
let _ = &"中华Việt Nam"[0..2];
538538
}
539539

540540
panic_cases! {
@@ -714,13 +714,13 @@ mod slice_index {
714714
#[test]
715715
#[should_panic(expected = "byte index 1024 is out of bounds of `Lorem ipsum dolor sit amet")]
716716
fn test_slice_fail_truncated_1() {
717-
&LOREM_PARAGRAPH[..1024];
717+
let _ = &LOREM_PARAGRAPH[..1024];
718718
}
719719
// check the truncation in the panic message
720720
#[test]
721721
#[should_panic(expected = "luctus, im`[...]")]
722722
fn test_slice_fail_truncated_2() {
723-
&LOREM_PARAGRAPH[..1024];
723+
let _ = &LOREM_PARAGRAPH[..1024];
724724
}
725725
}
726726

@@ -735,7 +735,7 @@ fn test_str_slice_rangetoinclusive_ok() {
735735
#[should_panic]
736736
fn test_str_slice_rangetoinclusive_notok() {
737737
let s = "abcαβγ";
738-
&s[..=3];
738+
let _ = &s[..=3];
739739
}
740740

741741
#[test]
@@ -751,7 +751,7 @@ fn test_str_slicemut_rangetoinclusive_ok() {
751751
fn test_str_slicemut_rangetoinclusive_notok() {
752752
let mut s = "abcαβγ".to_owned();
753753
let s: &mut str = &mut s;
754-
&mut s[..=3];
754+
let _ = &mut s[..=3];
755755
}
756756

757757
#[test]

alloc/tests/vec.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -542,35 +542,35 @@ fn test_index_out_of_bounds() {
542542
#[should_panic]
543543
fn test_slice_out_of_bounds_1() {
544544
let x = vec![1, 2, 3, 4, 5];
545-
&x[!0..];
545+
let _ = &x[!0..];
546546
}
547547

548548
#[test]
549549
#[should_panic]
550550
fn test_slice_out_of_bounds_2() {
551551
let x = vec![1, 2, 3, 4, 5];
552-
&x[..6];
552+
let _ = &x[..6];
553553
}
554554

555555
#[test]
556556
#[should_panic]
557557
fn test_slice_out_of_bounds_3() {
558558
let x = vec![1, 2, 3, 4, 5];
559-
&x[!0..4];
559+
let _ = &x[!0..4];
560560
}
561561

562562
#[test]
563563
#[should_panic]
564564
fn test_slice_out_of_bounds_4() {
565565
let x = vec![1, 2, 3, 4, 5];
566-
&x[1..6];
566+
let _ = &x[1..6];
567567
}
568568

569569
#[test]
570570
#[should_panic]
571571
fn test_slice_out_of_bounds_5() {
572572
let x = vec![1, 2, 3, 4, 5];
573-
&x[3..2];
573+
let _ = &x[3..2];
574574
}
575575

576576
#[test]

std/src/sys_common/wtf8/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ fn wtf8_slice() {
301301
#[test]
302302
#[should_panic]
303303
fn wtf8_slice_not_code_point_boundary() {
304-
&Wtf8::from_str("aé 💩")[2..4];
304+
let _ = &Wtf8::from_str("aé 💩")[2..4];
305305
}
306306

307307
#[test]
@@ -312,7 +312,7 @@ fn wtf8_slice_from() {
312312
#[test]
313313
#[should_panic]
314314
fn wtf8_slice_from_not_code_point_boundary() {
315-
&Wtf8::from_str("aé 💩")[2..];
315+
let _ = &Wtf8::from_str("aé 💩")[2..];
316316
}
317317

318318
#[test]
@@ -323,7 +323,7 @@ fn wtf8_slice_to() {
323323
#[test]
324324
#[should_panic]
325325
fn wtf8_slice_to_not_code_point_boundary() {
326-
&Wtf8::from_str("aé 💩")[5..];
326+
let _ = &Wtf8::from_str("aé 💩")[5..];
327327
}
328328

329329
#[test]

0 commit comments

Comments
 (0)