Skip to content

Commit f02fdd5

Browse files
committed
extend param_env with predicates from generator_witness
1 parent 461a949 commit f02fdd5

File tree

5 files changed

+23
-142
lines changed

5 files changed

+23
-142
lines changed

src/librustc/ty/walk.rs

-138
This file was deleted.

src/librustc_infer/infer/region_constraints/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ 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, RegionOutlivesPredicate};
16+
use rustc_middle::ty::{
17+
OutlivesPredicate, ReLateBound, ReVar, RegionKind, RegionOutlivesPredicate,
18+
};
1719
use rustc_middle::ty::{Region, RegionVid};
1820
use rustc_span::Span;
1921

src/librustc_trait_selection/traits/select.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -2335,7 +2335,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
23352335

23362336
fn collect_predicates_for_types(
23372337
&mut self,
2338-
param_env: ty::ParamEnv<'tcx>,
2338+
mut param_env: ty::ParamEnv<'tcx>,
23392339
cause: ObligationCause<'tcx>,
23402340
recursion_depth: usize,
23412341
trait_def_id: DefId,
@@ -2359,6 +2359,23 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
23592359
.skip_binder()
23602360
.iter()
23612361
.flat_map(|ty| {
2362+
let param_env = if let ty::GeneratorWitness(_, predicates) = ty.kind {
2363+
let predicates: Vec<_> = param_env
2364+
.caller_bounds
2365+
.to_vec()
2366+
.into_iter()
2367+
.chain(
2368+
predicates
2369+
.skip_binder()
2370+
.into_iter()
2371+
.map(|&p| ty::Binder::bind(p).to_predicate()),
2372+
)
2373+
.collect();
2374+
param_env.caller_bounds = self.infcx.tcx.mk_predicates(predicates.iter());
2375+
param_env
2376+
} else {
2377+
param_env
2378+
};
23622379
// binder moved -\
23632380
let ty: ty::Binder<Ty<'tcx>> = ty::Binder::bind(ty); // <----/
23642381

src/librustc_ty/needs_drop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ where
107107

108108
let witness = substs.witness();
109109
let interior_tys = match &witness.kind {
110-
ty::GeneratorWitness(tys) => tcx.erase_late_bound_regions(tys),
110+
ty::GeneratorWitness(tys, _) => tcx.erase_late_bound_regions(tys),
111111
_ => bug!(),
112112
};
113113

src/librustc_typeck/check/generator_interior.rs

+1-1
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, ToPredicate, Ty};
14+
use rustc_middle::ty::{self, Ty};
1515
use rustc_span::Span;
1616

1717
struct InteriorVisitor<'a, 'tcx> {

0 commit comments

Comments
 (0)