Skip to content

Commit

Permalink
Unrolled build for rust-lang#116358
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#116358 - compiler-errors:match, r=lcnr

Rename both of the `Match` relations

Both of these names kinda were ambiguous.

r? lcnr
  • Loading branch information
rust-timer authored Oct 3, 2023
2 parents eb0f3ed + 2ffaeb5 commit 6d122dc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
24 changes: 16 additions & 8 deletions compiler/rustc_infer/src/infer/outlives/test_type_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn extract_verify_if_eq<'tcx>(
test_ty: Ty<'tcx>,
) -> Option<ty::Region<'tcx>> {
assert!(!verify_if_eq_b.has_escaping_bound_vars());
let mut m = Match::new(tcx, param_env);
let mut m = MatchAgainstHigherRankedOutlives::new(tcx, param_env);
let verify_if_eq = verify_if_eq_b.skip_binder();
m.relate(verify_if_eq.ty, test_ty).ok()?;

Expand Down Expand Up @@ -87,24 +87,32 @@ pub(super) fn can_match_erased_ty<'tcx>(
// pointless micro-optimization
true
} else {
Match::new(tcx, param_env).relate(outlives_ty, erased_ty).is_ok()
MatchAgainstHigherRankedOutlives::new(tcx, param_env).relate(outlives_ty, erased_ty).is_ok()
}
}

struct Match<'tcx> {
struct MatchAgainstHigherRankedOutlives<'tcx> {
tcx: TyCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
pattern_depth: ty::DebruijnIndex,
map: FxHashMap<ty::BoundRegion, ty::Region<'tcx>>,
}

impl<'tcx> Match<'tcx> {
fn new(tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> Match<'tcx> {
Match { tcx, param_env, pattern_depth: ty::INNERMOST, map: FxHashMap::default() }
impl<'tcx> MatchAgainstHigherRankedOutlives<'tcx> {
fn new(
tcx: TyCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
) -> MatchAgainstHigherRankedOutlives<'tcx> {
MatchAgainstHigherRankedOutlives {
tcx,
param_env,
pattern_depth: ty::INNERMOST,
map: FxHashMap::default(),
}
}
}

impl<'tcx> Match<'tcx> {
impl<'tcx> MatchAgainstHigherRankedOutlives<'tcx> {
/// Creates the "Error" variant that signals "no match".
fn no_match<T>(&self) -> RelateResult<'tcx, T> {
Err(TypeError::Mismatch)
Expand Down Expand Up @@ -134,7 +142,7 @@ impl<'tcx> Match<'tcx> {
}
}

impl<'tcx> TypeRelation<'tcx> for Match<'tcx> {
impl<'tcx> TypeRelation<'tcx> for MatchAgainstHigherRankedOutlives<'tcx> {
fn tag(&self) -> &'static str {
"Match"
}
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_middle/src/ty/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ use crate::ty::{self, InferConst, Ty, TyCtxt};
/// Like subtyping, matching is really a binary relation, so the only
/// important thing about the result is Ok/Err. Also, matching never
/// affects any type variables or unification state.
pub struct Match<'tcx> {
pub struct MatchAgainstFreshVars<'tcx> {
tcx: TyCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
}

impl<'tcx> Match<'tcx> {
pub fn new(tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> Match<'tcx> {
Match { tcx, param_env }
impl<'tcx> MatchAgainstFreshVars<'tcx> {
pub fn new(tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> MatchAgainstFreshVars<'tcx> {
MatchAgainstFreshVars { tcx, param_env }
}
}

impl<'tcx> TypeRelation<'tcx> for Match<'tcx> {
impl<'tcx> TypeRelation<'tcx> for MatchAgainstFreshVars<'tcx> {
fn tag(&self) -> &'static str {
"Match"
"MatchAgainstFreshVars"
}
fn tcx(&self) -> TyCtxt<'tcx> {
self.tcx
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use rustc_middle::dep_graph::dep_kinds;
use rustc_middle::dep_graph::DepNodeIndex;
use rustc_middle::mir::interpret::ErrorHandled;
use rustc_middle::traits::DefiningAnchor;
use rustc_middle::ty::_match::MatchAgainstFreshVars;
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
use rustc_middle::ty::fold::BottomUpFolder;
use rustc_middle::ty::relate::TypeRelation;
Expand Down Expand Up @@ -2642,7 +2643,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
current: ty::PolyTraitPredicate<'tcx>,
param_env: ty::ParamEnv<'tcx>,
) -> bool {
let mut matcher = ty::_match::Match::new(self.tcx(), param_env);
let mut matcher = MatchAgainstFreshVars::new(self.tcx(), param_env);
matcher.relate(previous, current).is_ok()
}

Expand Down

0 comments on commit 6d122dc

Please sign in to comment.