Skip to content
Permalink
Browse files

Rename `hair::Pattern` to `hair::Pat`

  • Loading branch information...
varkor committed Sep 26, 2019
1 parent 79ff448 commit ff4ed8c2de5fb9f01d8d1c6394758fee99f95807
@@ -298,7 +298,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
pub(super) fn expr_into_pattern(
&mut self,
mut block: BasicBlock,
irrefutable_pat: Pattern<'tcx>,
irrefutable_pat: Pat<'tcx>,
initializer: ExprRef<'tcx>,
) -> BlockAnd<()> {
match *irrefutable_pat.kind {
@@ -337,7 +337,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// dubious way, so it may be that the test is kind of
// broken.
PatKind::AscribeUserType {
subpattern: Pattern {
subpattern: Pat {
kind: box PatKind::Binding {
mode: BindingMode::ByValue,
var,
@@ -414,7 +414,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
pub fn place_into_pattern(
&mut self,
block: BasicBlock,
irrefutable_pat: Pattern<'tcx>,
irrefutable_pat: Pat<'tcx>,
initializer: &Place<'tcx>,
set_match_place: bool,
) -> BlockAnd<()> {
@@ -486,7 +486,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
&mut self,
mut visibility_scope: Option<SourceScope>,
scope_span: Span,
pattern: &Pattern<'tcx>,
pattern: &Pat<'tcx>,
has_guard: ArmHasGuard,
opt_match_place: Option<(Option<&Place<'tcx>>, Span)>,
) -> Option<SourceScope> {
@@ -556,7 +556,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {

pub(super) fn visit_bindings(
&mut self,
pattern: &Pattern<'tcx>,
pattern: &Pat<'tcx>,
pattern_user_ty: UserTypeProjections,
f: &mut impl FnMut(
&mut Self,
@@ -718,7 +718,7 @@ pub struct MatchPair<'pat, 'tcx> {
place: Place<'tcx>,

// ... must match this pattern.
pattern: &'pat Pattern<'tcx>,
pattern: &'pat Pat<'tcx>,
}

#[derive(Clone, Debug, PartialEq)]
@@ -1339,7 +1339,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}

///////////////////////////////////////////////////////////////////////////
// Pattern binding - used for `let` and function parameters as well.
// Pat binding - used for `let` and function parameters as well.

impl<'a, 'tcx> Builder<'a, 'tcx> {
/// Initializes each of the bindings from the candidate by
@@ -722,9 +722,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
fn candidate_after_slice_test<'pat>(&mut self,
match_pair_index: usize,
candidate: &mut Candidate<'pat, 'tcx>,
prefix: &'pat [Pattern<'tcx>],
opt_slice: Option<&'pat Pattern<'tcx>>,
suffix: &'pat [Pattern<'tcx>]) {
prefix: &'pat [Pat<'tcx>],
opt_slice: Option<&'pat Pat<'tcx>>,
suffix: &'pat [Pat<'tcx>]) {
let removed_place = candidate.match_pairs.remove(match_pair_index).place;
self.prefix_slice_suffix(
&mut candidate.match_pairs,
@@ -22,9 +22,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
pub fn prefix_slice_suffix<'pat>(&mut self,
match_pairs: &mut Vec<MatchPair<'pat, 'tcx>>,
place: &Place<'tcx>,
prefix: &'pat [Pattern<'tcx>],
opt_slice: Option<&'pat Pattern<'tcx>>,
suffix: &'pat [Pattern<'tcx>]) {
prefix: &'pat [Pat<'tcx>],
opt_slice: Option<&'pat Pat<'tcx>>,
suffix: &'pat [Pat<'tcx>]) {
let min_length = prefix.len() + suffix.len();
let min_length = min_length.try_into().unwrap();

@@ -101,7 +101,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}

impl<'pat, 'tcx> MatchPair<'pat, 'tcx> {
pub fn new(place: Place<'tcx>, pattern: &'pat Pattern<'tcx>) -> MatchPair<'pat, 'tcx> {
pub fn new(place: Place<'tcx>, pattern: &'pat Pat<'tcx>) -> MatchPair<'pat, 'tcx> {
MatchPair {
place,
pattern,
@@ -78,7 +78,7 @@ fn mirror_stmts<'a, 'tcx>(
if let Some(ty) = &local.ty {
if let Some(&user_ty) = cx.tables.user_provided_types().get(ty.hir_id) {
debug!("mirror_stmts: user_ty={:?}", user_ty);
pattern = Pattern {
pattern = Pat {
ty: pattern.ty,
span: pattern.span,
kind: Box::new(PatKind::AscribeUserType {
@@ -153,16 +153,13 @@ impl<'a, 'tcx> Cx<'a, 'tcx> {
}
}

pub fn pattern_from_hir(&mut self, p: &hir::Pat) -> Pattern<'tcx> {
pub fn pattern_from_hir(&mut self, p: &hir::Pat) -> Pat<'tcx> {
let tcx = self.tcx.global_tcx();
let p = match tcx.hir().get(p.hir_id) {
Node::Pat(p) | Node::Binding(p) => p,
node => bug!("pattern became {:?}", node)
};
Pattern::from_hir(tcx,
self.param_env.and(self.identity_substs),
self.tables(),
p)
Pat::from_hir(tcx, self.param_env.and(self.identity_substs), self.tables(), p)
}

pub fn trait_method(&mut self,
@@ -20,7 +20,7 @@ pub mod cx;
mod constant;

pub mod pattern;
pub use self::pattern::{BindingMode, Pattern, PatKind, PatRange, FieldPat};
pub use self::pattern::{BindingMode, Pat, PatKind, PatRange, FieldPat};
pub(crate) use self::pattern::PatTyProj;

mod util;
@@ -83,7 +83,7 @@ pub enum StmtKind<'tcx> {
/// `let <PAT> = ...`
///
/// if a type is included, it is added as an ascription pattern
pattern: Pattern<'tcx>,
pattern: Pat<'tcx>,

/// let pat: ty = <INIT> ...
initializer: Option<ExprRef<'tcx>>,
@@ -293,7 +293,7 @@ pub struct FruInfo<'tcx> {

#[derive(Clone, Debug)]
pub struct Arm<'tcx> {
pub pattern: Pattern<'tcx>,
pub pattern: Pat<'tcx>,
pub guard: Option<Guard<'tcx>>,
pub body: ExprRef<'tcx>,
pub lint_level: LintLevel,
@@ -304,7 +304,7 @@ pub struct Arm<'tcx> {
impl Arm<'tcx> {
// HACK(or_patterns; Centril | dlrobertson): Remove this and
// correctly handle each case in which this method is used.
pub fn top_pats_hack(&self) -> &[Pattern<'tcx>] {
pub fn top_pats_hack(&self) -> &[Pat<'tcx>] {
match &*self.pattern.kind {
PatKind::Or { pats } => pats,
_ => std::slice::from_ref(&self.pattern),

0 comments on commit ff4ed8c

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