Skip to content

Use verbose suggestion for type literal with wrong syntax - #163053

Merged
rust-bors[bot] merged 5 commits into
rust-lang:mainfrom
estebank:wrong-struct-literal
Nov 2, 2026
Merged

rust-bors[bot] merged 5 commits into
rust-lang:mainfrom
estebank:wrong-struct-literal

Conversation

@estebank

@estebank estebank commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor
error[E0423]: cannot find value `StructWithFields` in crate `xcrate_unit_struct`
  --> $DIR/unit-struct.rs:9:33
   |
LL |     let _ = xcrate_unit_struct::StructWithFields;
   |                                 ^^^^^^^^^^^^^^^^
   |
  ::: $DIR/auxiliary/xcrate_unit_struct.rs:20:1
   |
LL | pub struct StructWithFields {
   | --------------------------- `xcrate_unit_struct::StructWithFields` defined here
   |
   = note: a struct named `xcrate_unit_struct::StructWithFields` exists in another namespace
help: use struct literal syntax instead
   |
LL |     let _ = xcrate_unit_struct::StructWithFields { foo: val };
   |                                                  ++++++++++++
error[E0532]: expected tuple struct or tuple variant, found unit variant `Color::NoColor`
  --> $DIR/match-pattern-field-mismatch-2.rs:12:11
   |
LL | enum Color {
LL |         NoColor,
   |         ------- `Color::NoColor` defined here
...
LL |           Color::NoColor(_) => { }
   |           ^^^^^^^^^^^^^^^^^
   |
help: use the unit struct syntax instead
   |
LL -           Color::NoColor(_) => { }
LL +           Color::NoColor => { }
   |

```
error[E0425]: cannot find function `bar` in this scope
  --> $DIR/suggest-self-2.rs:9:9
   |
LL |         bar(&&self, 102);
   |         ^^^
   |
help: try calling `bar` as a method
   |
LL -         bar(&&self, 102);
LL +         self.bar(102);
   |
```
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 20, 2026
@rustbot

rustbot commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

r? @jackh726

rustbot has assigned @jackh726.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 77 candidates
  • Random selection from 17 candidates

@fmease fmease left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rust-bors

rust-bors Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

📌 Commit ba8670c has been approved by fmease

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 2, 2026
@fmease fmease assigned fmease and unassigned jackh726 Nov 2, 2026
@fmease

fmease commented Nov 2, 2026

Copy link
Copy Markdown
Member

Ah, since it's been more than a month since the last push, I'll close&reopen to retrigger CI & then only tentatively put it into the queue...

@fmease fmease closed this Nov 2, 2026
@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 2, 2026
@rust-bors

rust-bors Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved due to being closed.

@fmease fmease reopened this Nov 2, 2026
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 2, 2026
@rustbot

rustbot commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Warning ⚠️

@fmease

fmease commented Nov 2, 2026

Copy link
Copy Markdown
Member

@bors r+

@rust-bors

rust-bors Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

📌 Commit ba8670c has been tentatively approved by fmease

It will be put into the queue for this repository once PR CI succeeds.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 2, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Nov 2, 2026
…mease

Use verbose suggestion for type literal with wrong syntax

```
error[E0423]: cannot find value `StructWithFields` in crate `xcrate_unit_struct`
  --> $DIR/unit-struct.rs:9:33
   |
LL |     let _ = xcrate_unit_struct::StructWithFields;
   |                                 ^^^^^^^^^^^^^^^^
   |
  ::: $DIR/auxiliary/xcrate_unit_struct.rs:20:1
   |
LL | pub struct StructWithFields {
   | --------------------------- `xcrate_unit_struct::StructWithFields` defined here
   |
   = note: a struct named `xcrate_unit_struct::StructWithFields` exists in another namespace
help: use struct literal syntax instead
   |
LL |     let _ = xcrate_unit_struct::StructWithFields { foo: val };
   |                                                  ++++++++++++
```
```
error[E0532]: expected tuple struct or tuple variant, found unit variant `Color::NoColor`
  --> $DIR/match-pattern-field-mismatch-2.rs:12:11
   |
LL | enum Color {
LL |         NoColor,
   |         ------- `Color::NoColor` defined here
...
LL |           Color::NoColor(_) => { }
   |           ^^^^^^^^^^^^^^^^^
   |
help: use the unit struct syntax instead
   |
LL -           Color::NoColor(_) => { }
LL +           Color::NoColor => { }
   |
```
rust-bors Bot pushed a commit that referenced this pull request Nov 2, 2026
Rollup of 9 pull requests

Successful merges:

 - #162018 (Recover inner attributes in algebraic data types)
 - #162819 (Make the suggestion message of `unused_must_use` scarier.)
 - #163053 (Use verbose suggestion for type literal with wrong syntax)
 - #163245 (Fix multiple pattern comma suggestions in diagnostics)
 - #163369 (Don't lint unused_qualifications when the unqualified path is ambiguous)
 - #165282 (Improve span for unused_mut lint)
 - #165285 (Forward `AbiAlign` `Debug` impl to `Align`)
 - #165294 (unstable.rs: add missing `]` in description of `cfg_ub_checks`)
 - #165310 (Clarify AGENTS.md around pushing to a fork)
@rust-bors
rust-bors Bot merged commit fb6bf5a into rust-lang:main Nov 2, 2026
27 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Nov 2, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 2, 2026
Rollup merge of #163053 - estebank:wrong-struct-literal, r=fmease

Use verbose suggestion for type literal with wrong syntax

```
error[E0423]: cannot find value `StructWithFields` in crate `xcrate_unit_struct`
  --> $DIR/unit-struct.rs:9:33
   |
LL |     let _ = xcrate_unit_struct::StructWithFields;
   |                                 ^^^^^^^^^^^^^^^^
   |
  ::: $DIR/auxiliary/xcrate_unit_struct.rs:20:1
   |
LL | pub struct StructWithFields {
   | --------------------------- `xcrate_unit_struct::StructWithFields` defined here
   |
   = note: a struct named `xcrate_unit_struct::StructWithFields` exists in another namespace
help: use struct literal syntax instead
   |
LL |     let _ = xcrate_unit_struct::StructWithFields { foo: val };
   |                                                  ++++++++++++
```
```
error[E0532]: expected tuple struct or tuple variant, found unit variant `Color::NoColor`
  --> $DIR/match-pattern-field-mismatch-2.rs:12:11
   |
LL | enum Color {
LL |         NoColor,
   |         ------- `Color::NoColor` defined here
...
LL |           Color::NoColor(_) => { }
   |           ^^^^^^^^^^^^^^^^^
   |
help: use the unit struct syntax instead
   |
LL -           Color::NoColor(_) => { }
LL +           Color::NoColor => { }
   |
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants