pub(crate) use self::check_match::check_match;
-use crate::const_eval::{const_field, const_variant_index};
+use crate::const_eval::const_variant_index;
use crate::hair::util::UserAnnotatedTyHelpers;
use crate::hair::constant::*;
}
pub struct PatternContext<'a, 'tcx: 'a> {
- pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
+ pub tcx: TyCtxt<'tcx, 'tcx>,
pub param_env: ty::ParamEnv<'tcx>,
pub tables: &'a ty::TypeckTables<'tcx>,
pub substs: SubstsRef<'tcx>,
}
impl<'a, 'tcx> Pattern<'tcx> {
- pub fn from_hir(tcx: TyCtxt<'a, 'tcx, 'tcx>,
- param_env_and_substs: ty::ParamEnvAnd<'tcx, SubstsRef<'tcx>>,
- tables: &'a ty::TypeckTables<'tcx>,
- pat: &'tcx hir::Pat) -> Self {
+ pub fn from_hir(
+ tcx: TyCtxt<'tcx, 'tcx>,
+ param_env_and_substs: ty::ParamEnvAnd<'tcx, SubstsRef<'tcx>>,
+ tables: &'a ty::TypeckTables<'tcx>,
+ pat: &'tcx hir::Pat,
+ ) -> Self {
let mut pcx = PatternContext::new(tcx, param_env_and_substs, tables);
let result = pcx.lower_pattern(pat);
if !pcx.errors.is_empty() {
}
impl<'a, 'tcx> PatternContext<'a, 'tcx> {
- pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>,
- param_env_and_substs: ty::ParamEnvAnd<'tcx, SubstsRef<'tcx>>,
- tables: &'a ty::TypeckTables<'tcx>) -> Self {
+ pub fn new(
+ tcx: TyCtxt<'tcx, 'tcx>,
+ param_env_and_substs: ty::ParamEnvAnd<'tcx, SubstsRef<'tcx>>,
+ tables: &'a ty::TypeckTables<'tcx>,
+ ) -> Self {
PatternContext {
tcx,
param_env: param_env_and_substs.param_env,
debug!("const_to_pat: cv={:#?} id={:?}", cv, id);
let adt_subpattern = |i, variant_opt| {
let field = Field::new(i);
- let val = const_field(self.tcx, self.param_env, variant_opt, field, cv);
+ let val = crate::const_eval::const_field(
+ self.tcx, self.param_env, variant_opt, field, cv
+ );
self.const_to_pat(instance, val, id, span)
};
let adt_subpatterns = |n, variant_opt| {
}
impl UserAnnotatedTyHelpers<'tcx, 'tcx> for PatternContext<'_, 'tcx> {
- fn tcx(&self) -> TyCtxt<'_, 'tcx, 'tcx> {
+ fn tcx(&self) -> TyCtxt<'tcx, 'tcx> {
self.tcx
}
}
}
-pub fn compare_const_vals<'a, 'gcx, 'tcx>(
- tcx: TyCtxt<'a, 'gcx, 'tcx>,
+pub fn compare_const_vals<'gcx, 'tcx>(
+ tcx: TyCtxt<'gcx, 'tcx>,
a: &'tcx ty::Const<'tcx>,
b: &'tcx ty::Const<'tcx>,
ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,