Skip to content

Commit

Permalink
Rename hair::Pattern to hair::Pat
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Sep 26, 2019
1 parent 79ff448 commit ff4ed8c
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 113 deletions.
14 changes: 7 additions & 7 deletions src/librustc_mir/build/matches/mod.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<()> {
Expand Down Expand Up @@ -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> {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/build/matches/test.rs
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_mir/build/matches/util.rs
Expand Up @@ -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();

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/hair/cx/block.rs
Expand Up @@ -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 {
Expand Down
7 changes: 2 additions & 5 deletions src/librustc_mir/hair/cx/mod.rs
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_mir/hair/mod.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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>>,
Expand Down Expand Up @@ -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,
Expand All @@ -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),
Expand Down

0 comments on commit ff4ed8c

Please sign in to comment.