Skip to content

Fix an ICE when trying to resolve a struct variant #19690

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

Conversation

barosl
Copy link
Contributor

@barosl barosl commented Dec 10, 2014

Unlike a tuple variant constructor which can be called as a function, a struct variant constructor is not a function, so cannot be called.

If the user tries to assign the constructor to a variable, an ICE occurs, because there is no way to use it later. So we should stop the constructor from being used like that.

A similar mechanism already exists for a normal struct, as it prohibits a struct from being resolved. This commit does the same for a struct variant.

This commit also includes some changes to the existing tests.

Fixes #19452.

@barosl barosl force-pushed the struct-variant-as-a-function-ice branch 2 times, most recently from dc6233d to e7d1fd2 Compare December 10, 2014 07:57
@ghost ghost changed the title [WIP] Fix an ICE when trying to resolve a struct variant Fix an ICE when trying to resolve a struct variant Dec 10, 2014
@barosl barosl force-pushed the struct-variant-as-a-function-ice branch 2 times, most recently from fdcde0e to a04e16f Compare December 10, 2014 12:41
Unlike a tuple variant constructor which can be called as a function, a
struct variant constructor is not a function, so cannot be called.

If the user tries to assign the constructor to a variable, an ICE
occurs, because there is no way to use it later. So we should stop the
constructor from being used like that.

A similar mechanism already exists for a normal struct, as it prohibits
a struct from being resolved. This commit does the same for a struct
variant.

This commit also includes some changes to the existing tests.

Fixes rust-lang#19452.
@barosl barosl force-pushed the struct-variant-as-a-function-ice branch from a04e16f to cfee5b7 Compare December 10, 2014 13:45
brson added a commit to brson/rust that referenced this pull request Dec 12, 2014
Unlike a tuple variant constructor which can be called as a function, a struct variant constructor is not a function, so cannot be called.

If the user tries to assign the constructor to a variable, an ICE occurs, because there is no way to use it later. So we should stop the constructor from being used like that.

A similar mechanism already exists for a normal struct, as it prohibits a struct from being resolved. This commit does the same for a struct variant.

This commit also includes some changes to the existing tests.

Fixes rust-lang#19452.
bors added a commit that referenced this pull request Dec 14, 2014
…r=alexcrichton

Unlike a tuple variant constructor which can be called as a function, a struct variant constructor is not a function, so cannot be called.

If the user tries to assign the constructor to a variable, an ICE occurs, because there is no way to use it later. So we should stop the constructor from being used like that.

A similar mechanism already exists for a normal struct, as it prohibits a struct from being resolved. This commit does the same for a struct variant.

This commit also includes some changes to the existing tests.

Fixes #19452.
@bors bors closed this Dec 14, 2014
lnicola pushed a commit to lnicola/rust that referenced this pull request Apr 28, 2025
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 'struct variant kind unexpected in get_item_val'
3 participants