- Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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
Hello,
I found a bug while developing a project who produce an internal error.
I create this code to reproduce the error:
struct TypeA { attr: String, attr2: usize, } struct TypeB { attr: usize, attr2: Vec<String>, } enum En { Value(TypeA), OtherValue(TypeB), None } fn main() { let a = En::Value(TypeA{attr: "Hello".to_owned(), attr2: 12}); if a == En::Value { println!("Value !"); } }
If you do the same using an Option, for example:
let a = Some(12); if a == Some // Produce an error, but not a compiler crash { /// }
But if you do this:
struct TypeA { attr: String, attr2: usize, } fn main() { let a = Some(TypeA{attr: "Hello".to_owned(), attr2: 12}); if a == Some { println!("Value !"); } }
You got another internal compiler error:
And to know: There is a correct way to do this without a match?
I try this, but it wasn't accepted:
if myVar == MyEnum::MyValue(_) {...}
Thank you
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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.