Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak conditions for E0026 and E0769 #75352

Merged
merged 1 commit into from
Aug 11, 2020

Conversation

estebank
Copy link
Contributor

When we have a tuple struct used with struct we don't want to suggest using the (valid) struct syntax with numeric field names. Instead we want to suggest the expected syntax.

Given

fn main() {
    match MyOption::MySome(42) {
        MyOption::MySome { x: 42 } => (),
        _ => (),
    }
}

We now emit E0769 "tuple variant MyOption::MySome written as struct variant" instead of E0026 "variant MyOption::MySome does not have a field named x".

When we have a tuple struct used with struct we don't want to suggest using
the (valid) struct syntax with numeric field names. Instead we want to
suggest the expected syntax.

Given

```rust
fn main() {
    match MyOption::MySome(42) {
        MyOption::MySome { x: 42 } => (),
        _ => (),
    }
}
```

We now emit E0769 "tuple variant `MyOption::MySome` written as struct variant"
instead of E0026 "variant `MyOption::MySome` does not have a field named `x`".
@rust-highfive
Copy link
Collaborator

r? @oli-obk

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 10, 2020
@estebank
Copy link
Contributor Author

Follow up to #74211, split off #74005.

@oli-obk
Copy link
Contributor

oli-obk commented Aug 10, 2020

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 10, 2020

📌 Commit 9149ec7 has been approved by oli-obk

@bors bors 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 Aug 10, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 11, 2020
Rollup of 10 pull requests

Successful merges:

 - rust-lang#74744 (Update RELEASES.md for 1.46.0)
 - rust-lang#75085 (Transmute big endian `s6_addr` and `[u16; 8]`)
 - rust-lang#75226 (Miri: Renamed "undef" to "uninit")
 - rust-lang#75333 (polymorphize: constrain unevaluated const handling)
 - rust-lang#75338 (move stack size check to const_eval machine)
 - rust-lang#75347 (Rustdoc: Fix natural ordering to look at all numbers.)
 - rust-lang#75352 (Tweak conditions for E0026 and E0769)
 - rust-lang#75353 (Tiny cleanup, remove unnecessary `unwrap`)
 - rust-lang#75359 (unused_delims: trim expr)
 - rust-lang#75360 (Add sample fix for E0749)

Failed merges:

r? @ghost
@bors bors merged commit e51a839 into rust-lang:master Aug 11, 2020
@estebank estebank deleted the incorrect-tuple-struct-pat branch November 9, 2023 05:16
@cuviper cuviper added this to the 1.47.0 milestone May 2, 2024
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants