remove VerifyBound::IfEq variant
This commit is contained in:
parent
b39ba21fcb
commit
893b919e64
3 changed files with 32 additions and 60 deletions
|
@ -19,7 +19,6 @@ use rustc_middle::mir::{
|
||||||
};
|
};
|
||||||
use rustc_middle::traits::ObligationCause;
|
use rustc_middle::traits::ObligationCause;
|
||||||
use rustc_middle::traits::ObligationCauseCode;
|
use rustc_middle::traits::ObligationCauseCode;
|
||||||
use rustc_middle::ty::Region;
|
|
||||||
use rustc_middle::ty::{self, subst::SubstsRef, RegionVid, Ty, TyCtxt, TypeFoldable};
|
use rustc_middle::ty::{self, subst::SubstsRef, RegionVid, Ty, TyCtxt, TypeFoldable};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
|
@ -1192,10 +1191,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||||
debug!("eval_verify_bound(lower_bound={:?}, verify_bound={:?})", lower_bound, verify_bound);
|
debug!("eval_verify_bound(lower_bound={:?}, verify_bound={:?})", lower_bound, verify_bound);
|
||||||
|
|
||||||
match verify_bound {
|
match verify_bound {
|
||||||
VerifyBound::IfEq(test_ty, verify_bound1) => {
|
|
||||||
self.eval_if_eq(infcx, generic_ty, lower_bound, *test_ty, *verify_bound1)
|
|
||||||
}
|
|
||||||
|
|
||||||
VerifyBound::IfEqBound(verify_if_eq_b) => {
|
VerifyBound::IfEqBound(verify_if_eq_b) => {
|
||||||
self.eval_if_eq_bound(infcx, param_env, generic_ty, lower_bound, *verify_if_eq_b)
|
self.eval_if_eq_bound(infcx, param_env, generic_ty, lower_bound, *verify_if_eq_b)
|
||||||
}
|
}
|
||||||
|
@ -1234,24 +1229,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn eval_if_eq(
|
|
||||||
&self,
|
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
|
||||||
generic_ty: Ty<'tcx>,
|
|
||||||
lower_bound: RegionVid,
|
|
||||||
test_ty: Ty<'tcx>,
|
|
||||||
verify_bound: Region<'tcx>,
|
|
||||||
) -> bool {
|
|
||||||
let generic_ty_normalized = self.normalize_to_scc_representatives(infcx.tcx, generic_ty);
|
|
||||||
let test_ty_normalized = self.normalize_to_scc_representatives(infcx.tcx, test_ty);
|
|
||||||
if generic_ty_normalized == test_ty_normalized {
|
|
||||||
let verify_bound_vid = self.to_region_vid(verify_bound);
|
|
||||||
self.eval_outlives(verify_bound_vid, lower_bound)
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn eval_if_eq_bound(
|
fn eval_if_eq_bound(
|
||||||
&self,
|
&self,
|
||||||
infcx: &InferCtxt<'_, 'tcx>,
|
infcx: &InferCtxt<'_, 'tcx>,
|
||||||
|
|
|
@ -822,11 +822,6 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
|
||||||
min: ty::Region<'tcx>,
|
min: ty::Region<'tcx>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
match bound {
|
match bound {
|
||||||
VerifyBound::IfEq(k, r) => {
|
|
||||||
(var_values.normalize(self.region_rels.tcx, *k) == generic_ty)
|
|
||||||
&& self.bound_is_met(&VerifyBound::OutlivedBy(*r), var_values, generic_ty, min)
|
|
||||||
}
|
|
||||||
|
|
||||||
VerifyBound::IfEqBound(verify_if_eq_b) => {
|
VerifyBound::IfEqBound(verify_if_eq_b) => {
|
||||||
match test_type_match::extract_verify_if_eq_bound(
|
match test_type_match::extract_verify_if_eq_bound(
|
||||||
self.tcx(),
|
self.tcx(),
|
||||||
|
|
|
@ -190,42 +190,44 @@ pub enum GenericKind<'tcx> {
|
||||||
/// This is described with an `AnyRegion('a, 'b)` node.
|
/// This is described with an `AnyRegion('a, 'b)` node.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum VerifyBound<'tcx> {
|
pub enum VerifyBound<'tcx> {
|
||||||
/// Given a kind K and a bound B, expands to a function like the
|
/// This is a "conditional bound" that checks the result of inference
|
||||||
/// following, where `G` is the generic for which this verify
|
/// and supplies a bound if it ended up being relevant. It's used in situations
|
||||||
/// bound was created:
|
/// like this:
|
||||||
|
///
|
||||||
|
/// ```rust
|
||||||
|
/// fn foo<'a, 'b, T: SomeTrait<'a>>
|
||||||
|
/// where
|
||||||
|
/// <T as SomeTrait<'a>>::Item: 'b
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// If we have an obligation like `<T as SomeTrait<'?x>>::Item: 'c`, then
|
||||||
|
/// we don't know yet whether it suffices to show that `'b: 'c`. If `'?x` winds
|
||||||
|
/// up being equal to `'a`, then the where-clauses on function applies, and
|
||||||
|
/// in that case we can show `'b: 'c`. But if `'?x` winds up being something
|
||||||
|
/// else, the bound isn't relevant.
|
||||||
|
///
|
||||||
|
/// More abstractly, this function takes a `Binder<VerifyIfEq>`. The binder
|
||||||
|
/// represents an existential binder -- i.e., if you have something like
|
||||||
|
///
|
||||||
|
/// ```rust
|
||||||
|
/// where for<'a> <T as SomeTrait<'a>::Item: 'a
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// then the `for<'a>` corresponds to the binder. The idea is that we have
|
||||||
|
/// to find some instantiation of `'a` that can make `<T as SomeTrait<'a>>::Item`
|
||||||
|
/// equal to the final value of `G`, the generic we are checking.
|
||||||
///
|
///
|
||||||
/// ```ignore (pseudo-rust)
|
/// ```ignore (pseudo-rust)
|
||||||
/// fn(min) -> bool {
|
/// fn(min) -> bool {
|
||||||
|
/// exists<'a> {
|
||||||
/// if G == K {
|
/// if G == K {
|
||||||
/// B(min)
|
/// B(min)
|
||||||
/// } else {
|
/// } else {
|
||||||
/// false
|
/// false
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
|
||||||
/// In other words, if the generic `G` that we are checking is
|
|
||||||
/// equal to `K`, then check the associated verify bound
|
|
||||||
/// (otherwise, false).
|
|
||||||
///
|
|
||||||
/// This is used when we have something in the environment that
|
|
||||||
/// may or may not be relevant, depending on the region inference
|
|
||||||
/// results. For example, we may have `where <T as
|
|
||||||
/// Trait<'a>>::Item: 'b` in our where-clauses. If we are
|
|
||||||
/// generating the verify-bound for `<T as Trait<'0>>::Item`, then
|
|
||||||
/// this where-clause is only relevant if `'0` winds up inferred
|
|
||||||
/// to `'a`.
|
|
||||||
///
|
|
||||||
/// So we would compile to a verify-bound like
|
|
||||||
///
|
|
||||||
/// ```ignore (illustrative)
|
|
||||||
/// IfEq(<T as Trait<'a>>::Item, AnyRegion('a))
|
|
||||||
/// ```
|
|
||||||
///
|
|
||||||
/// meaning, if the subject G is equal to `<T as Trait<'a>>::Item`
|
|
||||||
/// (after inference), and `'a: min`, then `G: min`.
|
|
||||||
IfEq(Ty<'tcx>, Region<'tcx>),
|
|
||||||
|
|
||||||
IfEqBound(ty::Binder<'tcx, VerifyIfEq<'tcx>>),
|
IfEqBound(ty::Binder<'tcx, VerifyIfEq<'tcx>>),
|
||||||
|
|
||||||
/// Given a region `R`, expands to the function:
|
/// Given a region `R`, expands to the function:
|
||||||
|
@ -805,7 +807,6 @@ impl<'tcx> GenericKind<'tcx> {
|
||||||
impl<'tcx> VerifyBound<'tcx> {
|
impl<'tcx> VerifyBound<'tcx> {
|
||||||
pub fn must_hold(&self) -> bool {
|
pub fn must_hold(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
VerifyBound::IfEq(..) => false,
|
|
||||||
VerifyBound::IfEqBound(..) => false,
|
VerifyBound::IfEqBound(..) => false,
|
||||||
VerifyBound::OutlivedBy(re) => re.is_static(),
|
VerifyBound::OutlivedBy(re) => re.is_static(),
|
||||||
VerifyBound::IsEmpty => false,
|
VerifyBound::IsEmpty => false,
|
||||||
|
@ -816,7 +817,6 @@ impl<'tcx> VerifyBound<'tcx> {
|
||||||
|
|
||||||
pub fn cannot_hold(&self) -> bool {
|
pub fn cannot_hold(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
VerifyBound::IfEq(_, _) => false,
|
|
||||||
VerifyBound::IfEqBound(..) => false,
|
VerifyBound::IfEqBound(..) => false,
|
||||||
VerifyBound::IsEmpty => false,
|
VerifyBound::IsEmpty => false,
|
||||||
VerifyBound::OutlivedBy(_) => false,
|
VerifyBound::OutlivedBy(_) => false,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue