Skip to content

Fix ICE related to enum struct variants #19568

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

Closed
wants to merge 2 commits into from

Conversation

barosl
Copy link
Contributor

@barosl barosl commented Dec 5, 2014

This pull request tries to fix #19340, which states two ICE cases related to enum struct variants.

It is my first attempt to fix the compiler. I found this solution by trial and error, so the method used to fix the issue looks very hacky. Please review it, and direct me to find a better solution.

I'm also to add test cases. Where should I put them? Maybe src/test/run-pass/issue-19340.rs?

@barosl barosl force-pushed the enum-struct-variants-ice branch from 0c5a072 to 75c43cd Compare December 5, 2014 15:18
@huonw
Copy link
Member

huonw commented Dec 6, 2014

I'm also to add test cases. Where should I put them? Maybe src/test/run-pass/issue-19340.rs?

That seems good. To do the cross-crate things you can use the aux building functionality. The implementation seems reasonable, but I'm no expert.

@barosl barosl force-pushed the enum-struct-variants-ice branch from 75c43cd to 651007d Compare December 8, 2014 14:08
@barosl
Copy link
Contributor Author

barosl commented Dec 8, 2014

@alexcrichton Oops! Sorry, I was still thinking of a better method to handle this. Could you r- for now? After I get some confidence, I will remove the [WIP] tag and ask you to merge.

If r- doesn't work due to the bot bug, (I heard from somewhere that there was a bug in the bot) please close this PR and I will open another PR again.

@barosl barosl closed this Dec 9, 2014
@alexcrichton
Copy link
Member

Oh oops, sorry for jumping the gun @barosl! Feel free to r? @alexcrichton on the next PR to make sure it gets assigned to me.

@barosl barosl reopened this Dec 10, 2014
@barosl barosl force-pushed the enum-struct-variants-ice branch from 651007d to 3ec80ad Compare December 10, 2014 18:00
@barosl
Copy link
Contributor Author

barosl commented Dec 10, 2014

I tried to introduce a cleaner code, but I'm not sure if it worked...

By the way, I found a regression that was caused by this PR. Some compiler error messages are somewhat incorrectly displayed.

  • Before: error: non-exhaustive patterns: (None, None) not covered [E0004]
  • After: error: non-exhaustive patterns: (None { }, None { }) not covered [E0004]

I'm investigating this issue.

})
.collect();

(None, arg_tys, Some(arg_names))
Copy link

Choose a reason for hiding this comment

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

@barosl if arg_names is length 0 should you return None instead of Some(arg_names) -- maybe that will fix your issue w/ the empty brackets printing in diagnostic message E0004 for nullary enums?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's what I've done in the local repository. It seems to pass the tests, but I'm still a bit concerned if there are more edge cases, such as one or more unnamed fields. Maybe that cannot happen?

@barosl barosl force-pushed the enum-struct-variants-ice branch from 3ec80ad to 086c949 Compare December 11, 2014 18:39
@barosl barosl changed the title [WIP] Fix ICE related to enum struct variants Fix ICE related to enum struct variants Dec 11, 2014
bors added a commit that referenced this pull request Dec 12, 2014
…ichton

This pull request tries to fix #19340, which states two ICE cases related to enum struct variants.

It is my first attempt to fix the compiler. I found this solution by trial and error, so the method used to fix the issue looks very hacky. Please review it, and direct me to find a better solution.

I'm also to add test cases. Where should I put them? Maybe `src/test/run-pass/issue-19340.rs`?
@bors bors closed this Dec 12, 2014
lnicola pushed a commit to lnicola/rust that referenced this pull request Apr 28, 2025
…editor

refactor: editor for `destructure_struct_binding`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE: task 'rustc' panicked at 'called Option::unwrap() on a None value'
5 participants