-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
enum variant values must be cast to their own type #13902
Labels
E-needs-test
Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Comments
visiting for triage I updated your code so that it compiles with the latest Rust (enum namespacing): static JSVAL_TAG_CLEAR: u32 = 0xFFFFFF80;
static JSVAL_TYPE_INT32: u8 = 0x01;
static JSVAL_TYPE_UNDEFINED: u8 = 0x02;
#[repr(u32)]
enum ValueTag {
JSVAL_TAG_INT32 = JSVAL_TAG_CLEAR | (JSVAL_TYPE_INT32 as u32),
JSVAL_TAG_UNDEFINED = JSVAL_TAG_CLEAR | (JSVAL_TYPE_UNDEFINED as u32),
}
fn main() {
let _ = ValueTag::JSVAL_TAG_INT32;
} Even with /t/triage $ rustc foo.rs
foo.rs:6:23: 6:74 error: expected constant: bad operands for binary [E0080]
foo.rs:6 JSVAL_TAG_INT32 = JSVAL_TAG_CLEAR as u32 | (JSVAL_TYPE_INT32 as u32),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foo.rs:7:27: 7:82 error: expected constant: bad operands for binary [E0080]
foo.rs:7 JSVAL_TAG_UNDEFINED = JSVAL_TAG_CLEAR as u32 | (JSVAL_TYPE_UNDEFINED as u32),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to 2 previous errors |
This does work in 1.0 |
@arielb1 This doesn't work for me in 1.0 |
@arielb1 What codeblock did you test this with? |
You need to use |
frewsxcv
added a commit
to frewsxcv/rust
that referenced
this issue
Jun 30, 2015
Regression test added in #26670 |
bors
added a commit
that referenced
this issue
Jun 30, 2015
flip1995
pushed a commit
to flip1995/rust
that referenced
this issue
Jan 9, 2025
…ust-lang#13906) Proper parentheses need to be added to some expressions in receiver position. Fix rust-lang#13902 changelog: [`redundant_pattern_matching`]: use proper parentheses when suggesting replacing `matches!(…, None)` by `.is_none()`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
E-needs-test
Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
The following program does not compile:
If you add
as u32
afterJSVAL_TAG_CLEAR
then it compiles fine. I assume this is interacting withrepr
such that it doesn't know the real type.The text was updated successfully, but these errors were encountered: