Rollup merge of #114668 - compiler-errors:match-fn-def, r=petrochenkov
Deny `FnDef` in patterns We can only see these via `const { .. }` patterns, which are unstable. cc #76001 (tracking issue for inline const pats) Fixes #114658 Fixes #114659
This commit is contained in:
commit
5baf2a110f
3 changed files with 36 additions and 1 deletions
|
@ -325,6 +325,11 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||
// `PartialEq::eq` on it.
|
||||
return Err(FallbackToConstRef);
|
||||
}
|
||||
ty::FnDef(..) => {
|
||||
self.saw_const_match_error.set(true);
|
||||
tcx.sess.emit_err(InvalidPattern { span, non_sm_ty: ty });
|
||||
PatKind::Wild
|
||||
}
|
||||
ty::Adt(adt_def, _) if !self.type_marked_structural(ty) => {
|
||||
debug!("adt_def {:?} has !type_marked_structural for cv.ty: {:?}", adt_def, ty,);
|
||||
self.saw_const_match_error.set(true);
|
||||
|
@ -440,7 +445,7 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||
}
|
||||
}
|
||||
},
|
||||
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::FnDef(..) => PatKind::Constant {
|
||||
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) => PatKind::Constant {
|
||||
value: mir::ConstantKind::Ty(ty::Const::new_value(tcx, cv, ty)),
|
||||
},
|
||||
ty::FnPtr(..) | ty::RawPtr(..) => unreachable!(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue