Remove MatchCheckCtxt::create_and_enter.

It has a single call site.
This commit is contained in:
Nicholas Nethercote 2020-05-08 07:42:49 +10:00
parent cbc577fc71
commit 95f600d6b9
2 changed files with 8 additions and 18 deletions

View File

@ -580,21 +580,11 @@ crate struct MatchCheckCtxt<'a, 'tcx> {
/// outside it's module and should not be matchable with an empty match
/// statement.
crate module: DefId,
param_env: ty::ParamEnv<'tcx>,
crate param_env: ty::ParamEnv<'tcx>,
crate pattern_arena: &'a TypedArena<Pat<'tcx>>,
}
impl<'a, 'tcx> MatchCheckCtxt<'a, 'tcx> {
crate fn create_and_enter<R>(
tcx: TyCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
pattern_arena: &'a TypedArena<Pat<'tcx>>,
module: DefId,
f: impl FnOnce(MatchCheckCtxt<'a, 'tcx>) -> R,
) -> R {
f(MatchCheckCtxt { tcx, param_env, module, pattern_arena })
}
fn is_uninhabited(&self, ty: Ty<'tcx>) -> bool {
if self.tcx.features().exhaustive_patterns {
self.tcx.is_ty_uninhabited_from(self.module, ty, self.param_env)

View File

@ -149,13 +149,13 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
fn check_in_cx(&self, hir_id: HirId, f: impl FnOnce(MatchCheckCtxt<'_, 'tcx>)) {
let module = self.tcx.parent_module(hir_id);
MatchCheckCtxt::create_and_enter(
self.tcx,
self.param_env,
&self.pattern_arena,
module.to_def_id(),
f,
);
let cx = MatchCheckCtxt {
tcx: self.tcx,
param_env: self.param_env,
module: module.to_def_id(),
pattern_arena: &self.pattern_arena,
};
f(cx);
}
fn check_match(