Skip to content

Allow consts to be initialized by non-nullary enum constructors #4459

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

Merged
merged 6 commits into from
Jan 13, 2013

Conversation

jld
Copy link
Contributor

@jld jld commented Jan 12, 2013

No description provided.

jld added 6 commits January 11, 2013 23:42
Loosening the connection between the LLVM type and the Rust type
is necessary to use non-nullary enum constructors as const initializers,
because the const needs to be initialized with data of the actual type of
the variant in question, which is (generally) not the same as the u8
array in the `type_of` type.

Thus, referring to a const now requires casting the LLVM global to the
expected pointer type instead of using it as-is.
The tests have consts defined both before and after their uses in order
to prevent bugs that depend on the order in which they are translated.
If the PointerCast in trans_def_lvalue is removed, these cases cause
LLVM assertion failures.
catamorphism added a commit that referenced this pull request Jan 13, 2013
Allow consts to be initialized by non-nullary enum constructors
@catamorphism catamorphism merged commit fbc33e0 into rust-lang:incoming Jan 13, 2013
@catamorphism
Copy link
Contributor

Good work, thanks!

bors pushed a commit to rust-lang-ci/rust that referenced this pull request May 15, 2021
* Added test cases

* Fixed if condition comment issue

* Fixed extern C issue

* Removed previous test case

* Removed tmp file

* honor the authors intent

* Changed the file name to its original name

* Removed extra whitespace
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.

2 participants