summaryrefslogtreecommitdiffstats
path: root/tests/ui/suggestions/ignore-nested-field-binding.fixed
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/suggestions/ignore-nested-field-binding.fixed
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/suggestions/ignore-nested-field-binding.fixed')
-rw-r--r--tests/ui/suggestions/ignore-nested-field-binding.fixed20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/ui/suggestions/ignore-nested-field-binding.fixed b/tests/ui/suggestions/ignore-nested-field-binding.fixed
new file mode 100644
index 000000000..1dc44838e
--- /dev/null
+++ b/tests/ui/suggestions/ignore-nested-field-binding.fixed
@@ -0,0 +1,20 @@
+// Regression test for #88403, where prefixing with an underscore was
+// erroneously suggested for a nested shorthand struct field binding.
+
+// run-rustfix
+#![allow(unused)]
+#![forbid(unused_variables)]
+
+struct Inner { i: i32 }
+struct Outer { o: Inner }
+
+fn foo(Outer { o: Inner { i: _ } }: Outer) {}
+//~^ ERROR: unused variable: `i`
+//~| HELP: try ignoring the field
+
+fn main() {
+ let s = Outer { o: Inner { i: 42 } };
+ let Outer { o: Inner { i: _ } } = s;
+ //~^ ERROR: unused variable: `i`
+ //~| HELP: try ignoring the field
+}