-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Transmuting a fieldless enum to it's integer type causes the optimizer to lose track of it's possible values. Note that as
casts are optimized correctly.
Example:
#[repr(u32)]
enum E { X = 0 }
fn f(x: E) {
assert_eq!(unsafe { core::mem::transmute::<E, i32>(x) }, 0); // Not optimized out
assert_eq!(x as i32, 0); // optimized out
}
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.