Skip to content
Permalink
Browse files

Rename `hair::PatternRange` to `hair::PatRange`

  • Loading branch information...
varkor committed Sep 26, 2019
1 parent ff59620 commit 5fbc211fbda14d3e929921789ae3b518308204d5
@@ -760,7 +760,7 @@ enum TestKind<'tcx> {
},

/// Test whether the value falls within an inclusive or exclusive range
Range(PatternRange<'tcx>),
Range(PatRange<'tcx>),

/// Test length of the slice is equal to len
Len {
@@ -108,7 +108,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
Err(match_pair)
}

PatKind::Range(PatternRange { lo, hi, end }) => {
PatKind::Range(PatRange { lo, hi, end }) => {
let (range, bias) = match lo.ty.kind {
ty::Char => {
(Some(('\u{0000}' as u128, '\u{10FFFF}' as u128, Size::from_bits(32))), 0)
@@ -283,7 +283,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
}

TestKind::Range(PatternRange { ref lo, ref hi, ref end }) => {
TestKind::Range(PatRange { ref lo, ref hi, ref end }) => {
let lower_bound_success = self.cfg.start_new_block();
let target_blocks = make_target_blocks(self);

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

fn const_range_contains(
&self,
range: PatternRange<'tcx>,
range: PatRange<'tcx>,
value: &'tcx ty::Const<'tcx>,
) -> Option<bool> {
use std::cmp::Ordering::*;
@@ -790,7 +790,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {

fn values_not_contained_in_range(
&self,
range: PatternRange<'tcx>,
range: PatRange<'tcx>,
indices: &FxHashMap<&'tcx ty::Const<'tcx>, usize>,
) -> Option<bool> {
for &val in indices.keys() {
@@ -20,7 +20,7 @@ pub mod cx;
mod constant;

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

mod util;
@@ -163,7 +163,7 @@ use self::WitnessPreference::*;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::indexed_vec::Idx;

use super::{FieldPat, Pattern, PatKind, PatternRange};
use super::{FieldPat, Pattern, PatKind, PatRange};
use super::{PatternFoldable, PatternFolder, compare_const_vals};

use rustc::hir::def_id::DefId;
@@ -606,7 +606,7 @@ impl<'tcx> Witness<'tcx> {
_ => {
match *ctor {
ConstantValue(value) => PatKind::Constant { value },
ConstantRange(lo, hi, ty, end) => PatKind::Range(PatternRange {
ConstantRange(lo, hi, ty, end) => PatKind::Range(PatRange {
lo: ty::Const::from_bits(cx.tcx, lo, ty::ParamEnv::empty().and(ty)),
hi: ty::Const::from_bits(cx.tcx, hi, ty::ParamEnv::empty().and(ty)),
end,
@@ -879,7 +879,7 @@ impl<'tcx> IntRange<'tcx> {
let range = loop {
match pat.kind {
box PatKind::Constant { value } => break ConstantValue(value),
box PatKind::Range(PatternRange { lo, hi, end }) => break ConstantRange(
box PatKind::Range(PatRange { lo, hi, end }) => break ConstantRange(
lo.eval_bits(tcx, param_env, lo.ty),
hi.eval_bits(tcx, param_env, hi.ty),
lo.ty,
@@ -1338,7 +1338,7 @@ fn pat_constructors<'tcx>(cx: &mut MatchCheckCtxt<'_, 'tcx>,
Some(vec![Variant(adt_def.variants[variant_index].def_id)])
}
PatKind::Constant { value } => Some(vec![ConstantValue(value)]),
PatKind::Range(PatternRange { lo, hi, end }) =>
PatKind::Range(PatRange { lo, hi, end }) =>
Some(vec![ConstantRange(
lo.eval_bits(cx.tcx, cx.param_env, lo.ty),
hi.eval_bits(cx.tcx, cx.param_env, hi.ty),
@@ -1658,7 +1658,7 @@ fn constructor_covered_by_range<'tcx>(
) -> Result<bool, ErrorReported> {
let (from, to, end, ty) = match pat.kind {
box PatKind::Constant { value } => (value, value, RangeEnd::Included, value.ty),
box PatKind::Range(PatternRange { lo, hi, end }) => (lo, hi, end, lo.ty),
box PatKind::Range(PatRange { lo, hi, end }) => (lo, hi, end, lo.ty),
_ => bug!("`constructor_covered_by_range` called with {:?}", pat),
};
trace!("constructor_covered_by_range {:#?}, {:#?}, {:#?}, {}", ctor, from, to, ty);
@@ -158,7 +158,7 @@ pub enum PatKind<'tcx> {
value: &'tcx ty::Const<'tcx>,
},

Range(PatternRange<'tcx>),
Range(PatRange<'tcx>),

/// Matches against a slice, checking the length and extracting elements.
/// irrefutable when there is a slice pattern and both `prefix` and `suffix` are empty.
@@ -184,7 +184,7 @@ pub enum PatKind<'tcx> {
}

#[derive(Copy, Clone, Debug, PartialEq)]
pub struct PatternRange<'tcx> {
pub struct PatRange<'tcx> {
pub lo: &'tcx ty::Const<'tcx>,
pub hi: &'tcx ty::Const<'tcx>,
pub end: RangeEnd,
@@ -310,7 +310,7 @@ impl<'tcx> fmt::Display for Pattern<'tcx> {
PatKind::Constant { value } => {
write!(f, "{}", value)
}
PatKind::Range(PatternRange { lo, hi, end }) => {
PatKind::Range(PatRange { lo, hi, end }) => {
write!(f, "{}", lo)?;
match end {
RangeEnd::Included => write!(f, "..=")?,
@@ -471,7 +471,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
);
match (end, cmp) {
(RangeEnd::Excluded, Some(Ordering::Less)) =>
PatKind::Range(PatternRange { lo, hi, end }),
PatKind::Range(PatRange { lo, hi, end }),
(RangeEnd::Excluded, _) => {
span_err!(
self.tcx.sess,
@@ -485,7 +485,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
PatKind::Constant { value: lo }
}
(RangeEnd::Included, Some(Ordering::Less)) => {
PatKind::Range(PatternRange { lo, hi, end })
PatKind::Range(PatRange { lo, hi, end })
}
(RangeEnd::Included, _) => {
let mut err = struct_span_err!(

0 comments on commit 5fbc211

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