Skip to content

Commit 0edc8f4

Browse files
committed
Store generator movability outside GeneratorInterior
1 parent 697a989 commit 0edc8f4

File tree

38 files changed

+108
-80
lines changed

38 files changed

+108
-80
lines changed

src/librustc/ich/impls_mir.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,11 @@ for mir::AggregateKind<'gcx> {
483483
def_id.hash_stable(hcx, hasher);
484484
substs.hash_stable(hcx, hasher);
485485
}
486-
mir::AggregateKind::Generator(def_id, ref substs, ref interior) => {
486+
mir::AggregateKind::Generator(def_id, ref substs, ref interior, movability) => {
487487
def_id.hash_stable(hcx, hasher);
488488
substs.hash_stable(hcx, hasher);
489489
interior.hash_stable(hcx, hasher);
490+
movability.hash_stable(hcx, hasher);
490491
}
491492
}
492493
}

src/librustc/ich/impls_ty.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ for ::middle::const_val::ErrKind<'gcx> {
518518

519519
impl_stable_hash_for!(struct ty::ClosureSubsts<'tcx> { substs });
520520

521-
impl_stable_hash_for!(struct ty::GeneratorInterior<'tcx> { witness, movable });
521+
impl_stable_hash_for!(struct ty::GeneratorInterior<'tcx> { witness });
522522

523523
impl_stable_hash_for!(struct ty::GenericPredicates<'tcx> {
524524
parent,
@@ -908,10 +908,11 @@ for ty::TypeVariants<'gcx>
908908
def_id.hash_stable(hcx, hasher);
909909
closure_substs.hash_stable(hcx, hasher);
910910
}
911-
TyGenerator(def_id, closure_substs, interior) => {
911+
TyGenerator(def_id, closure_substs, interior, movability) => {
912912
def_id.hash_stable(hcx, hasher);
913913
closure_substs.hash_stable(hcx, hasher);
914914
interior.hash_stable(hcx, hasher);
915+
movability.hash_stable(hcx, hasher);
915916
}
916917
TyGeneratorWitness(types) => {
917918
types.hash_stable(hcx, hasher)

src/librustc/mir/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,7 @@ pub enum AggregateKind<'tcx> {
16411641
Adt(&'tcx AdtDef, usize, &'tcx Substs<'tcx>, Option<usize>),
16421642

16431643
Closure(DefId, ClosureSubsts<'tcx>),
1644-
Generator(DefId, ClosureSubsts<'tcx>, GeneratorInterior<'tcx>),
1644+
Generator(DefId, ClosureSubsts<'tcx>, GeneratorInterior<'tcx>, hir::GeneratorMovability),
16451645
}
16461646

16471647
#[derive(Copy, Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)]
@@ -1804,7 +1804,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
18041804
}
18051805
}),
18061806

1807-
AggregateKind::Generator(def_id, _, _) => ty::tls::with(|tcx| {
1807+
AggregateKind::Generator(def_id, _, _, _) => ty::tls::with(|tcx| {
18081808
if let Some(node_id) = tcx.hir.as_local_node_id(def_id) {
18091809
let name = format!("[generator@{:?}]", tcx.hir.span(node_id));
18101810
let mut struct_fmt = fmt.debug_struct(&name);
@@ -2375,10 +2375,11 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
23752375
AggregateKind::Adt(def, v, substs.fold_with(folder), n),
23762376
AggregateKind::Closure(id, substs) =>
23772377
AggregateKind::Closure(id, substs.fold_with(folder)),
2378-
AggregateKind::Generator(id, substs, interior) =>
2378+
AggregateKind::Generator(id, substs, interior, movablity) =>
23792379
AggregateKind::Generator(id,
23802380
substs.fold_with(folder),
2381-
interior.fold_with(folder)),
2381+
interior.fold_with(folder),
2382+
movablity),
23822383
};
23832384
Aggregate(kind, fields.fold_with(folder))
23842385
}
@@ -2405,7 +2406,7 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
24052406
AggregateKind::Tuple => false,
24062407
AggregateKind::Adt(_, _, substs, _) => substs.visit_with(visitor),
24072408
AggregateKind::Closure(_, substs) => substs.visit_with(visitor),
2408-
AggregateKind::Generator(_, substs, interior) => substs.visit_with(visitor) ||
2409+
AggregateKind::Generator(_, substs, interior, _) => substs.visit_with(visitor) ||
24092410
interior.visit_with(visitor),
24102411
}) || fields.visit_with(visitor)
24112412
}

src/librustc/mir/tcx.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ impl<'tcx> Rvalue<'tcx> {
186186
AggregateKind::Closure(did, substs) => {
187187
tcx.mk_closure_from_closure_substs(did, substs)
188188
}
189-
AggregateKind::Generator(did, substs, interior) => {
190-
tcx.mk_generator(did, substs, interior)
189+
AggregateKind::Generator(did, substs, interior, movability) => {
190+
tcx.mk_generator(did, substs, interior, movability)
191191
}
192192
}
193193
}

src/librustc/mir/visit.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,9 @@ macro_rules! make_mir_visitor {
595595
self.visit_closure_substs(closure_substs, location);
596596
}
597597
AggregateKind::Generator(ref $($mutability)* def_id,
598-
ref $($mutability)* closure_substs,
599-
ref $($mutability)* interior) => {
598+
ref $($mutability)* closure_substs,
599+
ref $($mutability)* interior,
600+
_movability) => {
600601
self.visit_def_id(def_id, location);
601602
self.visit_closure_substs(closure_substs, location);
602603
self.visit_generator_interior(interior, location);

src/librustc/traits/select.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,7 +2280,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
22802280
substs.upvar_tys(def_id, self.tcx()).collect()
22812281
}
22822282

2283-
ty::TyGenerator(def_id, ref substs, interior) => {
2283+
ty::TyGenerator(def_id, ref substs, interior, _) => {
22842284
substs.upvar_tys(def_id, self.tcx()).chain(iter::once(interior.witness)).collect()
22852285
}
22862286

@@ -2756,7 +2756,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
27562756
// type/region parameters
27572757
let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder());
27582758
let (closure_def_id, substs) = match self_ty.sty {
2759-
ty::TyGenerator(id, substs, _) => (id, substs),
2759+
ty::TyGenerator(id, substs, _, _) => (id, substs),
27602760
_ => bug!("closure candidate for non-closure {:?}", obligation)
27612761
};
27622762

src/librustc/ty/context.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2453,9 +2453,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
24532453
pub fn mk_generator(self,
24542454
id: DefId,
24552455
closure_substs: ClosureSubsts<'tcx>,
2456-
interior: GeneratorInterior<'tcx>)
2456+
interior: GeneratorInterior<'tcx>,
2457+
movability: hir::GeneratorMovability)
24572458
-> Ty<'tcx> {
2458-
self.mk_ty(TyGenerator(id, closure_substs, interior))
2459+
self.mk_ty(TyGenerator(id, closure_substs, interior, movability))
24592460
}
24602461

24612462
pub fn mk_generator_witness(self, types: ty::Binder<&'tcx Slice<Ty<'tcx>>>) -> Ty<'tcx> {

src/librustc/ty/fast_reject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub fn simplify_type<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
9090
ty::TyClosure(def_id, _) => {
9191
Some(ClosureSimplifiedType(def_id))
9292
}
93-
ty::TyGenerator(def_id, _, _) => {
93+
ty::TyGenerator(def_id, _, _, _) => {
9494
Some(GeneratorSimplifiedType(def_id))
9595
}
9696
ty::TyGeneratorWitness(ref tys) => {

src/librustc/ty/flags.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl FlagComputation {
8787
}
8888
}
8989

90-
&ty::TyGenerator(_, ref substs, ref interior) => {
90+
&ty::TyGenerator(_, ref substs, ref interior, _) => {
9191
self.add_flags(TypeFlags::HAS_TY_CLOSURE);
9292
self.add_flags(TypeFlags::HAS_LOCAL_NAMES);
9393
self.add_substs(&substs.substs);

src/librustc/ty/item_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ pub fn characteristic_def_id_of_type(ty: Ty) -> Option<DefId> {
369369

370370
ty::TyFnDef(def_id, _) |
371371
ty::TyClosure(def_id, _) |
372-
ty::TyGenerator(def_id, _, _) |
372+
ty::TyGenerator(def_id, _, _, _) |
373373
ty::TyForeign(def_id) => Some(def_id),
374374

375375
ty::TyBool |

0 commit comments

Comments
 (0)