diff options
| author | Jules Bertholet <julesbertholet@quoi.xyz> | 2024-05-13 13:32:31 -0400 |
|---|---|---|
| committer | Jules Bertholet <julesbertholet@quoi.xyz> | 2024-05-13 18:36:49 -0400 |
| commit | fe8f66e4bcbe36e7e4b21943661ff23b5369c64b (patch) | |
| tree | 3ebd8226076b2c84df9fd27a44f94244ce3b66f0 /tests/ui/pattern | |
| parent | 421f7ca3a9c7ad574536666f6f0df6c7fe5e6780 (diff) | |
| download | rust-fe8f66e4bcbe36e7e4b21943661ff23b5369c64b.tar.gz rust-fe8f66e4bcbe36e7e4b21943661ff23b5369c64b.zip | |
`rustc_hir_typeck`: Account for `skipped_ref_pats` in `expr_use_visitor`
Fixes #125058
Diffstat (limited to 'tests/ui/pattern')
| -rw-r--r-- | tests/ui/pattern/skipped-ref-pats-issue-125058.rs | 18 | ||||
| -rw-r--r-- | tests/ui/pattern/skipped-ref-pats-issue-125058.stderr | 24 |
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/ui/pattern/skipped-ref-pats-issue-125058.rs b/tests/ui/pattern/skipped-ref-pats-issue-125058.rs new file mode 100644 index 00000000000..b733e5fda0a --- /dev/null +++ b/tests/ui/pattern/skipped-ref-pats-issue-125058.rs @@ -0,0 +1,18 @@ +//@ run-pass +//@ edition: 2024 +//@ compile-flags: -Zunstable-options + +#![allow(incomplete_features)] +#![feature(ref_pat_eat_one_layer_2024)] + +struct Foo; +//~^ WARN struct `Foo` is never constructed + +fn main() { + || { + //~^ WARN unused closure that must be used + if let Some(Some(&mut x)) = &mut Some(&mut Some(0)) { + let _: u32 = x; + } + }; +} diff --git a/tests/ui/pattern/skipped-ref-pats-issue-125058.stderr b/tests/ui/pattern/skipped-ref-pats-issue-125058.stderr new file mode 100644 index 00000000000..cee1cc673c7 --- /dev/null +++ b/tests/ui/pattern/skipped-ref-pats-issue-125058.stderr @@ -0,0 +1,24 @@ +warning: struct `Foo` is never constructed + --> $DIR/skipped-ref-pats-issue-125058.rs:8:8 + | +LL | struct Foo; + | ^^^ + | + = note: `#[warn(dead_code)]` on by default + +warning: unused closure that must be used + --> $DIR/skipped-ref-pats-issue-125058.rs:12:5 + | +LL | / || { +LL | | +LL | | if let Some(Some(&mut x)) = &mut Some(&mut Some(0)) { +LL | | let _: u32 = x; +LL | | } +LL | | }; + | |_____^ + | + = note: closures are lazy and do nothing unless called + = note: `#[warn(unused_must_use)]` on by default + +warning: 2 warnings emitted + |
