Remove movability from TyKind::Coroutine
This commit is contained in:
parent
f4d794ea0b
commit
fcb42b42d6
84 changed files with 212 additions and 220 deletions
|
@ -128,7 +128,7 @@ impl<'tcx> Visitor<'tcx> for UnsafetyChecker<'_, 'tcx> {
|
|||
),
|
||||
}
|
||||
}
|
||||
&AggregateKind::Closure(def_id, _) | &AggregateKind::Coroutine(def_id, _, _) => {
|
||||
&AggregateKind::Closure(def_id, _) | &AggregateKind::Coroutine(def_id, _) => {
|
||||
let def_id = def_id.expect_local();
|
||||
let UnsafetyCheckResult { violations, used_unsafe_blocks, .. } =
|
||||
self.tcx.unsafety_check_result(def_id);
|
||||
|
|
|
@ -1565,7 +1565,7 @@ pub(crate) fn mir_coroutine_witnesses<'tcx>(
|
|||
let coroutine_ty = body.local_decls[ty::CAPTURE_STRUCT_LOCAL].ty;
|
||||
|
||||
let movable = match *coroutine_ty.kind() {
|
||||
ty::Coroutine(_, _, movability) => movability == hir::Movability::Movable,
|
||||
ty::Coroutine(def_id, _) => tcx.movability(def_id) == hir::Movability::Movable,
|
||||
ty::Error(_) => return None,
|
||||
_ => span_bug!(body.span, "unexpected coroutine type {}", coroutine_ty),
|
||||
};
|
||||
|
@ -1600,9 +1600,9 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
|
|||
|
||||
// Get the discriminant type and args which typeck computed
|
||||
let (discr_ty, movable) = match *coroutine_ty.kind() {
|
||||
ty::Coroutine(_, args, movability) => {
|
||||
ty::Coroutine(def_id, args) => {
|
||||
let args = args.as_coroutine();
|
||||
(args.discr_ty(tcx), movability == hir::Movability::Movable)
|
||||
(args.discr_ty(tcx), tcx.movability(def_id) == hir::Movability::Movable)
|
||||
}
|
||||
_ => {
|
||||
tcx.dcx().span_delayed_bug(
|
||||
|
|
|
@ -91,7 +91,7 @@ fn bcb_to_initial_coverage_spans<'a, 'tcx>(
|
|||
fn is_closure(statement: &Statement<'_>) -> bool {
|
||||
match statement.kind {
|
||||
StatementKind::Assign(box (_, Rvalue::Aggregate(box ref agg_kind, _))) => match agg_kind {
|
||||
AggregateKind::Closure(_, _) | AggregateKind::Coroutine(_, _, _) => true,
|
||||
AggregateKind::Closure(_, _) | AggregateKind::Coroutine(_, _) => true,
|
||||
_ => false,
|
||||
},
|
||||
_ => false,
|
||||
|
|
|
@ -850,7 +850,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
|
|||
assert!(!fields.is_empty());
|
||||
(AggregateTy::Tuple, FIRST_VARIANT)
|
||||
}
|
||||
AggregateKind::Closure(did, substs) | AggregateKind::Coroutine(did, substs, _) => {
|
||||
AggregateKind::Closure(did, substs) | AggregateKind::Coroutine(did, substs) => {
|
||||
(AggregateTy::Def(did, substs), FIRST_VARIANT)
|
||||
}
|
||||
AggregateKind::Adt(did, variant_index, substs, _, None) => {
|
||||
|
|
|
@ -69,7 +69,7 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<'
|
|||
ty::InstanceDef::DropGlue(def_id, ty) => {
|
||||
// FIXME(#91576): Drop shims for coroutines aren't subject to the MIR passes at the end
|
||||
// of this function. Is this intentional?
|
||||
if let Some(ty::Coroutine(coroutine_def_id, args, _)) = ty.map(Ty::kind) {
|
||||
if let Some(ty::Coroutine(coroutine_def_id, args)) = ty.map(Ty::kind) {
|
||||
let body = tcx.optimized_mir(*coroutine_def_id).coroutine_drop().unwrap();
|
||||
let mut body = EarlyBinder::bind(body.clone()).instantiate(tcx, args);
|
||||
debug!("make_shim({:?}) = {:?}", instance, body);
|
||||
|
@ -394,7 +394,8 @@ fn build_clone_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, self_ty: Ty<'tcx>) -
|
|||
_ if is_copy => builder.copy_shim(),
|
||||
ty::Closure(_, args) => builder.tuple_like_shim(dest, src, args.as_closure().upvar_tys()),
|
||||
ty::Tuple(..) => builder.tuple_like_shim(dest, src, self_ty.tuple_fields()),
|
||||
ty::Coroutine(coroutine_def_id, args, hir::Movability::Movable) => {
|
||||
ty::Coroutine(coroutine_def_id, args) => {
|
||||
assert_eq!(tcx.movability(coroutine_def_id), hir::Movability::Movable);
|
||||
builder.coroutine_shim(dest, src, *coroutine_def_id, args.as_coroutine())
|
||||
}
|
||||
_ => bug!("clone shim for `{:?}` which is not `Copy` and is not an aggregate", self_ty),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue