summaryrefslogtreecommitdiffstats
path: root/src/test/ui/suggestions/ignore-nested-field-binding.rs
blob: 6dc0263ec9f2bac02a308585c9c444618ebbe21b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
}