Skip to content

Commit 893b919

Browse files
committed
remove VerifyBound::IfEq variant
1 parent b39ba21 commit 893b919

File tree

3 files changed

+31
-59
lines changed
  • compiler
    • rustc_borrowck/src/region_infer
    • rustc_infer/src/infer

3 files changed

+31
-59
lines changed

compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use rustc_middle::mir::{
1919
};
2020
use rustc_middle::traits::ObligationCause;
2121
use rustc_middle::traits::ObligationCauseCode;
22-
use rustc_middle::ty::Region;
2322
use rustc_middle::ty::{self, subst::SubstsRef, RegionVid, Ty, TyCtxt, TypeFoldable};
2423
use rustc_span::Span;
2524

@@ -1192,10 +1191,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
11921191
debug!("eval_verify_bound(lower_bound={:?}, verify_bound={:?})", lower_bound, verify_bound);
11931192

11941193
match verify_bound {
1195-
VerifyBound::IfEq(test_ty, verify_bound1) => {
1196-
self.eval_if_eq(infcx, generic_ty, lower_bound, *test_ty, *verify_bound1)
1197-
}
1198-
11991194
VerifyBound::IfEqBound(verify_if_eq_b) => {
12001195
self.eval_if_eq_bound(infcx, param_env, generic_ty, lower_bound, *verify_if_eq_b)
12011196
}
@@ -1234,24 +1229,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
12341229
}
12351230
}
12361231

1237-
fn eval_if_eq(
1238-
&self,
1239-
infcx: &InferCtxt<'_, 'tcx>,
1240-
generic_ty: Ty<'tcx>,
1241-
lower_bound: RegionVid,
1242-
test_ty: Ty<'tcx>,
1243-
verify_bound: Region<'tcx>,
1244-
) -> bool {
1245-
let generic_ty_normalized = self.normalize_to_scc_representatives(infcx.tcx, generic_ty);
1246-
let test_ty_normalized = self.normalize_to_scc_representatives(infcx.tcx, test_ty);
1247-
if generic_ty_normalized == test_ty_normalized {
1248-
let verify_bound_vid = self.to_region_vid(verify_bound);
1249-
self.eval_outlives(verify_bound_vid, lower_bound)
1250-
} else {
1251-
false
1252-
}
1253-
}
1254-
12551232
fn eval_if_eq_bound(
12561233
&self,
12571234
infcx: &InferCtxt<'_, 'tcx>,

compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -822,11 +822,6 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
822822
min: ty::Region<'tcx>,
823823
) -> bool {
824824
match bound {
825-
VerifyBound::IfEq(k, r) => {
826-
(var_values.normalize(self.region_rels.tcx, *k) == generic_ty)
827-
&& self.bound_is_met(&VerifyBound::OutlivedBy(*r), var_values, generic_ty, min)
828-
}
829-
830825
VerifyBound::IfEqBound(verify_if_eq_b) => {
831826
match test_type_match::extract_verify_if_eq_bound(
832827
self.tcx(),

compiler/rustc_infer/src/infer/region_constraints/mod.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -190,42 +190,44 @@ pub enum GenericKind<'tcx> {
190190
/// This is described with an `AnyRegion('a, 'b)` node.
191191
#[derive(Debug, Clone)]
192192
pub enum VerifyBound<'tcx> {
193-
/// Given a kind K and a bound B, expands to a function like the
194-
/// following, where `G` is the generic for which this verify
195-
/// bound was created:
193+
/// This is a "conditional bound" that checks the result of inference
194+
/// and supplies a bound if it ended up being relevant. It's used in situations
195+
/// like this:
196196
///
197-
/// ```ignore (pseudo-rust)
198-
/// fn(min) -> bool {
199-
/// if G == K {
200-
/// B(min)
201-
/// } else {
202-
/// false
203-
/// }
204-
/// }
197+
/// ```rust
198+
/// fn foo<'a, 'b, T: SomeTrait<'a>>
199+
/// where
200+
/// <T as SomeTrait<'a>>::Item: 'b
205201
/// ```
206202
///
207-
/// In other words, if the generic `G` that we are checking is
208-
/// equal to `K`, then check the associated verify bound
209-
/// (otherwise, false).
210-
///
211-
/// This is used when we have something in the environment that
212-
/// may or may not be relevant, depending on the region inference
213-
/// results. For example, we may have `where <T as
214-
/// Trait<'a>>::Item: 'b` in our where-clauses. If we are
215-
/// generating the verify-bound for `<T as Trait<'0>>::Item`, then
216-
/// this where-clause is only relevant if `'0` winds up inferred
217-
/// to `'a`.
203+
/// If we have an obligation like `<T as SomeTrait<'?x>>::Item: 'c`, then
204+
/// we don't know yet whether it suffices to show that `'b: 'c`. If `'?x` winds
205+
/// up being equal to `'a`, then the where-clauses on function applies, and
206+
/// in that case we can show `'b: 'c`. But if `'?x` winds up being something
207+
/// else, the bound isn't relevant.
218208
///
219-
/// So we would compile to a verify-bound like
209+
/// More abstractly, this function takes a `Binder<VerifyIfEq>`. The binder
210+
/// represents an existential binder -- i.e., if you have something like
220211
///
221-
/// ```ignore (illustrative)
222-
/// IfEq(<T as Trait<'a>>::Item, AnyRegion('a))
212+
/// ```rust
213+
/// where for<'a> <T as SomeTrait<'a>::Item: 'a
223214
/// ```
224215
///
225-
/// meaning, if the subject G is equal to `<T as Trait<'a>>::Item`
226-
/// (after inference), and `'a: min`, then `G: min`.
227-
IfEq(Ty<'tcx>, Region<'tcx>),
228-
216+
/// then the `for<'a>` corresponds to the binder. The idea is that we have
217+
/// to find some instantiation of `'a` that can make `<T as SomeTrait<'a>>::Item`
218+
/// equal to the final value of `G`, the generic we are checking.
219+
///
220+
/// ```ignore (pseudo-rust)
221+
/// fn(min) -> bool {
222+
/// exists<'a> {
223+
/// if G == K {
224+
/// B(min)
225+
/// } else {
226+
/// false
227+
/// }
228+
/// }
229+
/// }
230+
/// ```
229231
IfEqBound(ty::Binder<'tcx, VerifyIfEq<'tcx>>),
230232

231233
/// Given a region `R`, expands to the function:
@@ -805,7 +807,6 @@ impl<'tcx> GenericKind<'tcx> {
805807
impl<'tcx> VerifyBound<'tcx> {
806808
pub fn must_hold(&self) -> bool {
807809
match self {
808-
VerifyBound::IfEq(..) => false,
809810
VerifyBound::IfEqBound(..) => false,
810811
VerifyBound::OutlivedBy(re) => re.is_static(),
811812
VerifyBound::IsEmpty => false,
@@ -816,7 +817,6 @@ impl<'tcx> VerifyBound<'tcx> {
816817

817818
pub fn cannot_hold(&self) -> bool {
818819
match self {
819-
VerifyBound::IfEq(_, _) => false,
820820
VerifyBound::IfEqBound(..) => false,
821821
VerifyBound::IsEmpty => false,
822822
VerifyBound::OutlivedBy(_) => false,

0 commit comments

Comments
 (0)