Get rid of redundant NonStructuralMatchTyKind
This commit is contained in:
parent
1152e70363
commit
c1f54c30bb
4 changed files with 28 additions and 73 deletions
|
@ -122,37 +122,31 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
|
|||
fn search_for_structural_match_violation(&self, ty: Ty<'tcx>) -> Option<String> {
|
||||
traits::search_for_structural_match_violation(self.span, self.tcx(), ty, false).map(
|
||||
|non_sm_ty| {
|
||||
with_no_trimmed_paths!(match non_sm_ty.kind {
|
||||
traits::NonStructuralMatchTyKind::Adt(adt) => self.adt_derive_msg(adt),
|
||||
traits::NonStructuralMatchTyKind::Dynamic => {
|
||||
with_no_trimmed_paths!(match non_sm_ty.kind() {
|
||||
ty::Adt(adt, _) => self.adt_derive_msg(*adt),
|
||||
ty::Dynamic(..) => {
|
||||
"trait objects cannot be used in patterns".to_string()
|
||||
}
|
||||
traits::NonStructuralMatchTyKind::Opaque => {
|
||||
ty::Opaque(..) => {
|
||||
"opaque types cannot be used in patterns".to_string()
|
||||
}
|
||||
traits::NonStructuralMatchTyKind::Closure => {
|
||||
ty::Closure(..) => {
|
||||
"closures cannot be used in patterns".to_string()
|
||||
}
|
||||
traits::NonStructuralMatchTyKind::Generator => {
|
||||
ty::Generator(..) | ty::GeneratorWitness(..) => {
|
||||
"generators cannot be used in patterns".to_string()
|
||||
}
|
||||
traits::NonStructuralMatchTyKind::Float => {
|
||||
ty::Float(..) => {
|
||||
"floating-point numbers cannot be used in patterns".to_string()
|
||||
}
|
||||
traits::NonStructuralMatchTyKind::FnPtr => {
|
||||
ty::FnPtr(..) => {
|
||||
"function pointers cannot be used in patterns".to_string()
|
||||
}
|
||||
traits::NonStructuralMatchTyKind::RawPtr => {
|
||||
ty::RawPtr(..) => {
|
||||
"raw pointers cannot be used in patterns".to_string()
|
||||
}
|
||||
traits::NonStructuralMatchTyKind::Param => {
|
||||
bug!("use of a constant whose type is a parameter inside a pattern")
|
||||
}
|
||||
traits::NonStructuralMatchTyKind::Projection => {
|
||||
bug!("use of a constant whose type is a projection inside a pattern")
|
||||
}
|
||||
traits::NonStructuralMatchTyKind::Foreign => {
|
||||
bug!("use of a value of a foreign type inside a pattern")
|
||||
_ => {
|
||||
bug!("use of a value of `{non_sm_ty}` inside a pattern")
|
||||
}
|
||||
})
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue