Skip to content
Permalink
Browse files

Rename `PatternContext` to `PatCtxt`

  • Loading branch information...
varkor committed Sep 26, 2019
1 parent 5fbc211 commit d5561936467fbb57d3eb432bcca9100338bab724
@@ -476,7 +476,7 @@ pub enum WitnessPreference {
}

#[derive(Copy, Clone, Debug)]
struct PatternContext<'tcx> {
struct PatCtxt<'tcx> {
ty: Ty<'tcx>,
max_slice_length: u64,
}
@@ -636,7 +636,7 @@ impl<'tcx> Witness<'tcx> {
/// `Option<!>`, we do not include `Some(_)` in the returned list of constructors.
fn all_constructors<'a, 'tcx>(
cx: &mut MatchCheckCtxt<'a, 'tcx>,
pcx: PatternContext<'tcx>,
pcx: PatCtxt<'tcx>,
) -> Vec<Constructor<'tcx>> {
debug!("all_constructors({:?})", pcx.ty);
let ctors = match pcx.ty.kind {
@@ -1094,7 +1094,7 @@ pub fn is_useful<'p, 'a, 'tcx>(

assert!(rows.iter().all(|r| r.len() == v.len()));

let pcx = PatternContext {
let pcx = PatCtxt {
// TyErr is used to represent the type of wildcard patterns matching
// against inaccessible (private) fields of structs, so that we won't
// be able to observe whether the types of the struct's fields are
@@ -1326,7 +1326,7 @@ fn is_useful_specialized<'p, 'a, 'tcx>(
/// Returns `None` in case of a catch-all, which can't be specialized.
fn pat_constructors<'tcx>(cx: &mut MatchCheckCtxt<'_, 'tcx>,
pat: &Pattern<'tcx>,
pcx: PatternContext<'tcx>)
pcx: PatCtxt<'tcx>)
-> Option<Vec<Constructor<'tcx>>>
{
match *pat.kind {
@@ -2,7 +2,7 @@ use super::_match::{MatchCheckCtxt, Matrix, expand_pattern, is_useful};
use super::_match::Usefulness::*;
use super::_match::WitnessPreference::*;

use super::{Pattern, PatternContext, PatternError, PatKind};
use super::{Pattern, PatCtxt, PatternError, PatKind};

use rustc::middle::borrowck::SignalledError;
use rustc::session::Session;
@@ -88,7 +88,7 @@ impl<'tcx> Visitor<'tcx> for MatchVisitor<'_, 'tcx> {
}
}

impl PatternContext<'_, '_> {
impl PatCtxt<'_, '_> {
fn report_inlining_errors(&self, pat_span: Span) {
for error in &self.errors {
match *error {
@@ -152,7 +152,7 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {

let inlined_arms : Vec<(Vec<_>, _)> = arms.iter().map(|arm| (
arm.top_pats_hack().iter().map(|pat| {
let mut patcx = PatternContext::new(self.tcx,
let mut patcx = PatCtxt::new(self.tcx,
self.param_env.and(self.identity_substs),
self.tables);
patcx.include_lint_checks();
@@ -249,7 +249,7 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
fn check_irrefutable(&self, pat: &'tcx Pat, origin: &str) {
let module = self.tcx.hir().get_module_parent(pat.hir_id);
MatchCheckCtxt::create_and_enter(self.tcx, self.param_env, module, |ref mut cx| {
let mut patcx = PatternContext::new(self.tcx,
let mut patcx = PatCtxt::new(self.tcx,
self.param_env.and(self.identity_substs),
self.tables);
patcx.include_lint_checks();
@@ -347,7 +347,7 @@ impl<'tcx> fmt::Display for Pattern<'tcx> {
}
}

pub struct PatternContext<'a, 'tcx> {
pub struct PatCtxt<'a, 'tcx> {
pub tcx: TyCtxt<'tcx>,
pub param_env: ty::ParamEnv<'tcx>,
pub tables: &'a ty::TypeckTables<'tcx>,
@@ -363,7 +363,7 @@ impl<'a, 'tcx> Pattern<'tcx> {
tables: &'a ty::TypeckTables<'tcx>,
pat: &'tcx hir::Pat,
) -> Self {
let mut pcx = PatternContext::new(tcx, param_env_and_substs, tables);
let mut pcx = PatCtxt::new(tcx, param_env_and_substs, tables);
let result = pcx.lower_pattern(pat);
if !pcx.errors.is_empty() {
let msg = format!("encountered errors lowering pattern: {:?}", pcx.errors);
@@ -374,13 +374,13 @@ impl<'a, 'tcx> Pattern<'tcx> {
}
}

impl<'a, 'tcx> PatternContext<'a, 'tcx> {
impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
pub fn new(
tcx: TyCtxt<'tcx>,
param_env_and_substs: ty::ParamEnvAnd<'tcx, SubstsRef<'tcx>>,
tables: &'a ty::TypeckTables<'tcx>,
) -> Self {
PatternContext {
PatCtxt {
tcx,
param_env: param_env_and_substs.param_env,
tables,
@@ -1293,7 +1293,7 @@ fn search_for_adt_without_structural_match<'tcx>(tcx: TyCtxt<'tcx>,
}
}

impl UserAnnotatedTyHelpers<'tcx> for PatternContext<'_, 'tcx> {
impl UserAnnotatedTyHelpers<'tcx> for PatCtxt<'_, 'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> {
self.tcx
}

0 comments on commit d556193

Please sign in to comment.
You can’t perform that action at this time.