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

visit enum init when the enum variable doesn't have any parameters #103506

Closed
wants to merge 1 commit into from

Conversation

lyming2007
Copy link

this fix #101208

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 25, 2022
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @petrochenkov (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 25, 2022
@rust-log-analyzer

This comment has been minimized.

@petrochenkov
Copy link
Contributor

This diagnostic is already reported in a very similar case

struct S(u8, u8);

fn main() {
    let _: S = S;
}
error[[E0308]](https://doc.rust-lang.org/nightly/error-index.html#E0308): mismatched types
 --> src/main.rs:4:16
  |
1 | struct S(u8, u8);
  | -------- fn(u8, u8) -> S {S} defined here
...
4 |     let _: S = S;
  |            -   ^ expected struct `S`, found fn item
  |            |
  |            expected due to this
  |
  = note: expected struct `S`
            found fn item `fn(u8, u8) -> S {S}`
help: use parentheses to construct this tuple struct
  |
4 |     let _: S = S(/* u8 */, /* u8 */);
  |                 ++++++++++++++++++++

, and it's not specific to tuple structs, it works for any function calls returning the expected type.

But for some reason it's not reported in cases like this

struct S(u8, u8);

fn main() {
    let S(_, _) = S;
}
error[[E0308]](https://doc.rust-lang.org/nightly/error-index.html#E0308): mismatched types
 --> src/main.rs:4:9
  |
4 |     let S(_, _) = S;
  |         ^^^^^^^   - this expression has type `fn(u8, u8) -> S {S}`
  |         |
  |         expected fn item, found struct `S`
  |
  = note: expected fn item `fn(u8, u8) -> S {S}`
              found struct `S`

I think we need to figure out why this S(_, _) doesn't correctly propagate the expected type in the old diagnostic instead of introducing a new diagnostic.
@rustbot author

@rustbot rustbot 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-review Status: Awaiting review from the assignee but also interested parties. labels Oct 25, 2022
@bors
Copy link
Contributor

bors commented Nov 10, 2022

☔ The latest upstream changes (presumably #103636) made this pull request unmergeable. Please resolve the merge conflicts.

@JohnCSimon
Copy link
Member

@lyming2007
ping from triage - can you post your status on this PR? There hasn't been an update in a few months. Thanks!

FYI: when a PR is ready for review, send a message containing
@rustbot ready to switch to S-waiting-on-review so the PR is in the reviewer's backlog.

@lyming2007
Copy link
Author

@lyming2007 ping from triage - can you post your status on this PR? There hasn't been an update in a few months. Thanks!

FYI: when a PR is ready for review, send a message containing @rustbot ready to switch to S-waiting-on-review so the PR is in the reviewer's backlog.

petrochenkov was right about his comment. There was a similar case. But they're actually very different in terms of implementation. My fix was straight forward but maybe not a perfect one. So I still need more work on this. I'll update it later

@JohnCSimon JohnCSimon 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 17, 2023
@JohnCSimon
Copy link
Member

@lyming2007

Ping from triage: I'm closing this due to inactivity, Please reopen when you are ready to continue with this.
Note: if you are going to continue please open the PR BEFORE you push to it, else you won't be able to reopen - this is a quirk of github.
Thanks for your contribution.

@rustbot label: +S-inactive

@JohnCSimon JohnCSimon closed this May 28, 2023
@rustbot rustbot added the S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. label May 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

Provide suggestion for error when if let used with enum variant whose values are not initialized
7 participants