Skip to content

Commit 3e8280d

Browse files
committed
intern region outlives predicate
1 parent f3aedd5 commit 3e8280d

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

src/librustc_infer/infer/region_constraints/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_hir::def_id::DefId;
1313
use rustc_index::vec::IndexVec;
1414
use rustc_middle::ty::ReStatic;
1515
use rustc_middle::ty::{self, Ty, TyCtxt};
16-
use rustc_middle::ty::{OutlivesPredicate, ReLateBound, ReVar, RegionKind};
16+
use rustc_middle::ty::{OutlivesPredicate, ReLateBound, ReVar, RegionKind, RegionOutlivesPredicate};
1717
use rustc_middle::ty::{Region, RegionVid};
1818
use rustc_span::Span;
1919

@@ -146,10 +146,7 @@ impl<'tcx> Constraint<'tcx> {
146146
}
147147
}
148148

149-
pub fn to_region_outlives_predicate(
150-
&self,
151-
tcx: &TyCtxt<'tcx>,
152-
) -> RegionOutlivesPredicate<Region<'tcx>, Region<'tcx>> {
149+
pub fn to_region_outlives_predicate(&self, tcx: TyCtxt<'tcx>) -> RegionOutlivesPredicate<'tcx> {
153150
match self {
154151
Self::VarSubVar(a, b) => OutlivesPredicate(
155152
tcx.mk_region(RegionKind::ReVar(*a)),

src/librustc_middle/ty/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2332,7 +2332,7 @@ impl<'tcx> TyCtxt<'tcx> {
23322332
pub fn mk_generator_witness(
23332333
self,
23342334
types: ty::Binder<&'tcx List<Ty<'tcx>>>,
2335-
region_outlives: &'tcx List<ty::RegionOutlivesPredicate<'tcx>>,
2335+
region_outlives: ty::Binder<&'tcx List<Predicate<'tcx>>>,
23362336
) -> Ty<'tcx> {
23372337
self.mk_ty(GeneratorWitness(types, region_outlives))
23382338
}

src/librustc_middle/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ pub type PolySubtypePredicate<'tcx> = ty::Binder<SubtypePredicate<'tcx>>;
13721372
/// equality between arbitrary types. Processing an instance of
13731373
/// Form #2 eventually yields one of these `ProjectionPredicate`
13741374
/// instances to normalize the LHS.
1375-
#[derive(Copy, Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
1375+
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
13761376
#[derive(HashStable, TypeFoldable)]
13771377
pub struct ProjectionPredicate<'tcx> {
13781378
pub projection_ty: ProjectionTy<'tcx>,

src/librustc_middle/ty/relate.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::mir::interpret::{get_slice_bytes, ConstValue};
88
use crate::traits;
99
use crate::ty::error::{ExpectedFound, TypeError};
1010
use crate::ty::subst::{GenericArg, GenericArgKind, SubstsRef};
11-
use crate::ty::{self, List, Ty, TyCtxt, TypeFoldable};
11+
use crate::ty::{self, Ty, TyCtxt, TypeFoldable};
1212
use rustc_hir as ast;
1313
use rustc_hir::def_id::DefId;
1414
use rustc_target::spec::abi;
@@ -403,7 +403,7 @@ pub fn super_relate_tys<R: TypeRelation<'tcx>>(
403403
let b_types = b_types.map_bound(GeneratorWitness);
404404
// Then remove the GeneratorWitness for the result
405405
let types = relation.relate(&a_types, &b_types)?.map_bound(|witness| witness.0);
406-
Ok(tcx.mk_generator_witness(types, List::empty()))
406+
Ok(tcx.mk_generator_witness(types, ty::Binder::dummy()))
407407
}
408408

409409
(&ty::Closure(a_id, a_substs), &ty::Closure(b_id, b_substs)) if a_id == b_id => {

src/librustc_middle/ty/sty.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ use crate::mir::interpret::{LitToConstInput, Scalar};
1212
use crate::mir::Promoted;
1313
use crate::ty::subst::{GenericArg, InternalSubsts, Subst, SubstsRef};
1414
use crate::ty::{
15-
self, AdtDef, DefIdTree, Discr, RegionOutlivesPredicate, Ty, TyCtxt, TypeFlags, TypeFoldable,
16-
WithConstness,
15+
self, AdtDef, DefIdTree, Discr, Ty, TyCtxt, TypeFlags, TypeFoldable, WithConstness,
1716
};
1817
use crate::ty::{List, ParamEnv, ParamEnvAnd, TyS};
1918
use polonius_engine::Atom;
@@ -169,7 +168,7 @@ pub enum TyKind<'tcx> {
169168

170169
/// A type representin the types stored inside a generator.
171170
/// This should only appear in GeneratorInteriors.
172-
GeneratorWitness(Binder<&'tcx List<Ty<'tcx>>>, &'tcx List<RegionOutlivesPredicate<'tcx>>),
171+
GeneratorWitness(Binder<&'tcx List<Ty<'tcx>>>, Binder<&'tcx List<ty::Predicate<'tcx>>>),
173172

174173
/// The never type `!`
175174
Never,

src/librustc_typeck/check/generator_interior.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_hir::def_id::DefId;
1111
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
1212
use rustc_hir::{Expr, ExprKind, Pat, PatKind};
1313
use rustc_middle::middle::region::{self, YieldData};
14-
use rustc_middle::ty::{self, Ty};
14+
use rustc_middle::ty::{self, ToPredicate, Ty};
1515
use rustc_span::Span;
1616

1717
struct InteriorVisitor<'a, 'tcx> {
@@ -192,14 +192,18 @@ pub fn resolve_interior<'a, 'tcx>(
192192
constraints_data
193193
.constraints
194194
.keys()
195-
.map(|constraints| constraints.to_region_outlives_predicate())
195+
.map(|constraints| {
196+
ty::Binder::bind(constraints.to_region_outlives_predicate(fcx.tcx)).to_predicate()
197+
})
196198
.collect::<Vec<_>>()
197199
});
198200
debug!("region outlives inside generator: {:?}", region_constraints);
199201

200202
let region_outlives_list = fcx.tcx.mk_predicates(region_constraints.iter());
201203

202-
let witness = fcx.tcx.mk_generator_witness(ty::Binder::bind(type_list), region_outlives_list);
204+
let witness = fcx
205+
.tcx
206+
.mk_generator_witness(ty::Binder::bind(type_list), ty::Binder::bind(region_outlives_list));
203207

204208
// Store the generator types and spans into the tables for this generator.
205209
visitor.fcx.inh.tables.borrow_mut().generator_interior_types = type_causes;

0 commit comments

Comments
 (0)