Closed
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