cx.pattern_arena.alloc(LiteralExpander { tcx: cx.tcx }.fold_pattern(&pat))
}
-struct LiteralExpander<'a, 'tcx> {
- tcx: TyCtxt<'a, 'tcx, 'tcx>
+struct LiteralExpander<'tcx> {
+ tcx: TyCtxt<'tcx>,
}
-impl<'a, 'tcx> LiteralExpander<'a, 'tcx> {
+impl LiteralExpander<'tcx> {
/// Derefs `val` and potentially unsizes the value if `crty` is an array and `rty` a slice.
///
/// `crty` and `rty` can differ because you can use array constants in the presence of slice
}
}
-impl<'a, 'tcx> PatternFolder<'tcx> for LiteralExpander<'a, 'tcx> {
+impl PatternFolder<'tcx> for LiteralExpander<'tcx> {
fn fold_pattern(&mut self, pat: &Pattern<'tcx>) -> Pattern<'tcx> {
debug!("fold_pattern {:?} {:?} {:?}", pat, pat.ty.sty, pat.kind);
match (&pat.ty.sty, &*pat.kind) {
}
pub struct MatchCheckCtxt<'a, 'tcx: 'a> {
- pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
+ pub tcx: TyCtxt<'tcx>,
/// The module in which the match occurs. This is necessary for
/// checking inhabited-ness of types because whether a type is (visibly)
/// inhabited can depend on whether it was defined in the current module or
impl<'a, 'tcx> MatchCheckCtxt<'a, 'tcx> {
pub fn create_and_enter<F, R>(
- tcx: TyCtxt<'a, 'tcx, 'tcx>,
+ tcx: TyCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
module: DefId,
- f: F) -> R
- where F: for<'b> FnOnce(MatchCheckCtxt<'b, 'tcx>) -> R
+ f: F,
+ ) -> R
+ where
+ F: for<'b> FnOnce(MatchCheckCtxt<'b, 'tcx>) -> R,
{
let pattern_arena = TypedArena::default();
}
impl<'tcx> IntRange<'tcx> {
- fn from_ctor(tcx: TyCtxt<'_, 'tcx, 'tcx>,
- ctor: &Constructor<'tcx>)
- -> Option<IntRange<'tcx>> {
+ fn from_ctor(tcx: TyCtxt<'tcx>, ctor: &Constructor<'tcx>) -> Option<IntRange<'tcx>> {
// Floating-point ranges are permitted and we don't want
// to consider them when constructing integer ranges.
fn is_integral<'tcx>(ty: Ty<'tcx>) -> bool {
}
}
- fn from_pat(tcx: TyCtxt<'_, 'tcx, 'tcx>,
- mut pat: &Pattern<'tcx>)
- -> Option<IntRange<'tcx>> {
+ fn from_pat(tcx: TyCtxt<'tcx>, mut pat: &Pattern<'tcx>) -> Option<IntRange<'tcx>> {
let range = loop {
match pat.kind {
box PatternKind::Constant { value } => break ConstantValue(value),
}
// The return value of `signed_bias` should be XORed with an endpoint to encode/decode it.
- fn signed_bias(tcx: TyCtxt<'_, 'tcx, 'tcx>, ty: Ty<'tcx>) -> u128 {
+ fn signed_bias(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> u128 {
match ty.sty {
ty::Int(ity) => {
let bits = Integer::from_attr(&tcx, SignedInt(ity)).size().bits() as u128;
/// Converts a `RangeInclusive` to a `ConstantValue` or inclusive `ConstantRange`.
fn range_to_ctor(
- tcx: TyCtxt<'_, 'tcx, 'tcx>,
+ tcx: TyCtxt<'tcx>,
ty: Ty<'tcx>,
r: RangeInclusive<u128>,
) -> Constructor<'tcx> {
/// Returns a collection of ranges that spans the values covered by `ranges`, subtracted
/// by the values covered by `self`: i.e., `ranges \ self` (in set notation).
- fn subtract_from(self,
- tcx: TyCtxt<'_, 'tcx, 'tcx>,
- ranges: Vec<Constructor<'tcx>>)
- -> Vec<Constructor<'tcx>> {
+ fn subtract_from(
+ self,
+ tcx: TyCtxt<'tcx>,
+ ranges: Vec<Constructor<'tcx>>,
+ ) -> Vec<Constructor<'tcx>> {
let ranges = ranges.into_iter().filter_map(|r| {
IntRange::from_ctor(tcx, &r).map(|i| i.range)
});
// to compute the full set.)
fn compute_missing_ctors<'a, 'tcx: 'a>(
info: MissingCtorsInfo,
- tcx: TyCtxt<'a, 'tcx, 'tcx>,
+ tcx: TyCtxt<'tcx>,
all_ctors: &Vec<Constructor<'tcx>>,
used_ctors: &Vec<Constructor<'tcx>>,
) -> MissingCtors<'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<'_>)
+ pcx: PatternContext<'tcx>)
-> Option<Vec<Constructor<'tcx>>>
{
match *pat.kind {
// meaning all other types will compare unequal and thus equal patterns often do not cause the
// second pattern to lint about unreachable match arms.
fn slice_pat_covered_by_const<'tcx>(
- tcx: TyCtxt<'_, 'tcx, '_>,
+ tcx: TyCtxt<'tcx>,
_span: Span,
const_val: &'tcx ty::Const<'tcx>,
prefix: &[Pattern<'tcx>],
slice: &Option<Pattern<'tcx>>,
- suffix: &[Pattern<'tcx>]
+ suffix: &[Pattern<'tcx>],
) -> Result<bool, ErrorReported> {
let data: &[u8] = match (const_val.val, &const_val.ty.sty) {
(ConstValue::ByRef(ptr, alloc), ty::Array(t, n)) => {
// Whether to evaluate a constructor using exhaustive integer matching. This is true if the
// constructor is a range or constant with an integer type.
-fn should_treat_range_exhaustively(tcx: TyCtxt<'_, 'tcx, 'tcx>, ctor: &Constructor<'tcx>) -> bool {
+fn should_treat_range_exhaustively(tcx: TyCtxt<'tcx>, ctor: &Constructor<'tcx>) -> bool {
let ty = match ctor {
ConstantValue(value) => value.ty,
ConstantRange(_, _, ty, _) => ty,
/// between every pair of boundary points. (This essentially sums up to performing the intuitive
/// merging operation depicted above.)
fn split_grouped_constructors<'p, 'a: 'p, 'tcx: 'a>(
- tcx: TyCtxt<'a, 'tcx, 'tcx>,
+ tcx: TyCtxt<'tcx>,
ctors: Vec<Constructor<'tcx>>,
&Matrix(ref m): &Matrix<'p, 'tcx>,
ty: Ty<'tcx>,
/// Checks whether there exists any shared value in either `ctor` or `pat` by intersecting them.
fn constructor_intersects_pattern<'p, 'a: 'p, 'tcx: 'a>(
- tcx: TyCtxt<'a, 'tcx, 'tcx>,
+ tcx: TyCtxt<'tcx>,
ctor: &Constructor<'tcx>,
pat: &'p Pattern<'tcx>,
) -> Option<SmallVec<[&'p Pattern<'tcx>; 2]>> {
}
}
-fn constructor_covered_by_range<'a, 'tcx>(
- tcx: TyCtxt<'a, 'tcx, 'tcx>,
+fn constructor_covered_by_range<'tcx>(
+ tcx: TyCtxt<'tcx>,
ctor: &Constructor<'tcx>,
pat: &Pattern<'tcx>,
) -> Result<bool, ErrorReported> {