Repository: rust
Issue: Suggest the correct name if `_` is used in a struct literal
Labels: A-diagnostics,A-parser,T-compiler,A-inference,A-suggestion-diagnostics

<!--
Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
along with any information you feel relevant to replicating the bug.

If you cannot produce a minimal reproduction case (something that would work in
isolation), please provide the steps or even link to a repository that causes
the problematic output to occur.
-->

Given the following code: [<!-- Please provide a link to play.rust-lang.org -->](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=b05d8f5c39f83f8965a869b9549648cc)

```rust
mod blah {
    pub struct Stuff { x: i32 }
    pub fn do_stuff(_: Stuff) {}
}

fn main() {
    blah::do_stuff(_ { x: 10 });
}
```

The current output is:

```
error: struct literal body without path
 --> src/main.rs:7:22
  |
7 |     blah::do_stuff(_ { x: 10 });
  |                      ^^^^^^^^^
  |
help: you might have forgotten to add the struct literal inside the block
  |
7 |     blah::do_stuff(_ { SomeStruct { x: 10 } });
  |                      ++++++++++++           +

error: expected one of `)`, `,`, `.`, `?`, or an operator, found `{`
 --> src/main.rs:7:22
  |
7 |     blah::do_stuff(_ { x: 10 });
  |                     -^ expected one of `)`, `,`, `.`, `?`, or an operator
  |                     |
  |                     help: missing `,`

warning: unnecessary braces around function argument
 --> src/main.rs:7:22
  |
7 |     blah::do_stuff(_ { x: 10 });
  |                      ^        ^
  |
  = note: `#[warn(unused_braces)]` on by default
help: remove these braces
  |
7 -     blah::do_stuff(_ { x: 10 });
7 +     blah::do_stuff(_ { x: 10 });
  |

error: in expressions, `_` can only be used on the left-hand side of an assignment
 --> src/main.rs:7:20
  |
7 |     blah::do_stuff(_ { x: 10 });
  |                    ^ `_` not allowed here

error[[E0061]](https://doc.rust-lang.org/nightly/error-index.html#E0061): this function takes 1 argument but 2 arguments were supplied
 --> src/main.rs:7:5
  |
7 |     blah::do_stuff(_ { x: 10 });
  |     ^^^^^^^^^^^^^^   --------- argument unexpected
  |
note: function defined here
 --> src/main.rs:3:12
  |
3 |     pub fn do_stuff(_: Stuff) {}
  |            ^^^^^^^^ --------
help: remove the extra argument
  |
7 |     blah::do_stuff(_);
  |     ~~~~~~~~~~~~~~~~~
```

<!-- The following is not always necessary. -->
Ideally the output should look like:

```
error[E0121]: the placeholder `_` is not allowed in struct literals
 --> src/main.rs:5:22
  |
9 |     blah::do_stuff(_ { x: 10 });
  |                    ^
  |                    |
  |                    not allowed in struct literals
  |                    help: replace with the correct struct type: `blah::Stuff`
```

Like how rustc will suggest the correct type if you use `-> _` in a function definition.

<!--
If the problem is not self-explanatory, please provide a rationale for the
change.
-->

<!--
If dramatically different output is caused by small changes, consider also
adding them here.

If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions. The output might also be
different depending on the Edition.
-->

(Opened after this thread: https://internals.rust-lang.org/t/enum-path-inference-with-variant-syntax/16851/4?u=scottmcm )

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_ASSIGN_START -->

<!-- TRIAGEBOT_ASSIGN_DATA_START$${"user":"abs0luty"}$$TRIAGEBOT_ASSIGN_DATA_END -->

<!-- TRIAGEBOT_ASSIGN_END -->
<!-- TRIAGEBOT_END -->