Don't check sad pattern equality by text

This commit is contained in:
Lukas Wirth 2021-07-02 21:10:38 +02:00
parent 251f0c6090
commit eb3f90b301

View File

@ -265,10 +265,11 @@ fn binds_name(pat: &ast::Pat) -> bool {
_ => false,
}
}
fn is_sad_pat(sema: &hir::Semantics<RootDatabase>, pat: &ast::Pat) -> bool {
sema.type_of_pat(pat)
.and_then(|ty| TryEnum::from_ty(sema, &ty))
.map_or(false, |it| it.sad_pattern().syntax().text() == pat.syntax().text())
.map_or(false, |it| does_pat_match_variant(pat, &it.sad_pattern()))
}
#[cfg(test)]