Skip to content

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

3 participants