Skip to content

Commit

Permalink
Remove MatchCheckCtxt::create_and_enter.
Browse files Browse the repository at this point in the history
It has a single call site.
  • Loading branch information
nnethercote committed May 7, 2020
1 parent cbc577f commit 95f600d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
12 changes: 1 addition & 11 deletions src/librustc_mir_build/hair/pattern/_match.rs
Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions src/librustc_mir_build/hair/pattern/check_match.rs
Expand Up @@ -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(
Expand Down

0 comments on commit 95f600d

Please sign in to comment.