Apply formatting fixes

This commit is contained in:
Andrew Cann 2022-03-21 12:57:06 +08:00 committed by Charles Lew
parent 8aa30dd3cb
commit 22f4bbb20f
3 changed files with 27 additions and 34 deletions

View File

@ -4,7 +4,7 @@
use rustc_middle::mir::*;
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::subst::{InternalSubsts, Subst};
use rustc_middle::ty::{self, EarlyBinder, Ty, TyCtxt, GeneratorSubsts};
use rustc_middle::ty::{self, EarlyBinder, GeneratorSubsts, Ty, TyCtxt};
use rustc_target::abi::VariantIdx;
use rustc_index::vec::{Idx, IndexVec};
@ -486,20 +486,12 @@ fn clone_fields<I>(
self.make_clone_call(dest_field, src_field, ity, next_block, unwind);
self.block(
vec![],
TerminatorKind::Drop {
place: dest_field,
target: unwind,
unwind: None,
},
TerminatorKind::Drop { place: dest_field, target: unwind, unwind: None },
true,
);
unwind = next_unwind;
}
self.block(
vec![],
TerminatorKind::Goto { target },
false,
);
self.block(vec![], TerminatorKind::Goto { target }, false);
unwind
}
@ -507,11 +499,7 @@ fn tuple_like_shim<I>(&mut self, dest: Place<'tcx>, src: Place<'tcx>, tys: I)
where
I: IntoIterator<Item = Ty<'tcx>>,
{
self.block(
vec![],
TerminatorKind::Goto { target: self.block_index_offset(3) },
false,
);
self.block(vec![], TerminatorKind::Goto { target: self.block_index_offset(3) }, false);
let unwind = self.block(vec![], TerminatorKind::Resume, true);
let target = self.block(vec![], TerminatorKind::Return, false);
@ -525,11 +513,7 @@ fn generator_shim(
gen_def_id: DefId,
substs: GeneratorSubsts<'tcx>,
) {
self.block(
vec![],
TerminatorKind::Goto { target: self.block_index_offset(3) },
false,
);
self.block(vec![], TerminatorKind::Goto { target: self.block_index_offset(3) }, false);
let unwind = self.block(vec![], TerminatorKind::Resume, true);
// This will get overwritten with a switch once we know the target blocks
let switch = self.block(vec![], TerminatorKind::Unreachable, false);
@ -566,7 +550,7 @@ fn generator_shim(
switch_ty: discr_ty,
targets: SwitchTargets::new(cases.into_iter(), unreachable),
};
},
}
BasicBlockData { terminator: None, .. } => unreachable!(),
}
}

View File

@ -1939,11 +1939,13 @@ fn copy_clone_conditions(
ty::Generator(_, substs, hir::Movability::Movable) => {
if self.tcx().features().generator_clone {
let resolved_upvars = self.infcx.shallow_resolve(substs.as_generator().tupled_upvars_ty());
let resolved_witness = self.infcx.shallow_resolve(substs.as_generator().witness());
let resolved_upvars =
self.infcx.shallow_resolve(substs.as_generator().tupled_upvars_ty());
let resolved_witness =
self.infcx.shallow_resolve(substs.as_generator().witness());
if {
matches!(resolved_upvars.kind(), ty::Infer(ty::TyVar(_))) ||
matches!(resolved_witness.kind(), ty::Infer(ty::TyVar(_)))
matches!(resolved_upvars.kind(), ty::Infer(ty::TyVar(_)))
|| matches!(resolved_witness.kind(), ty::Infer(ty::TyVar(_)))
} {
// Not yet resolved.
Ambiguous
@ -1967,14 +1969,21 @@ fn copy_clone_conditions(
if matches!(resolved.kind(), ty::Infer(ty::TyVar(_))) {
break Ambiguous;
}
},
}
Option::None => {
// (*) binder moved here
let all_vars = self.tcx().mk_bound_variable_kinds(
obligation.predicate.bound_vars().iter().chain(binder.bound_vars().iter())
obligation
.predicate
.bound_vars()
.iter()
.chain(binder.bound_vars().iter()),
);
break Where(ty::Binder::bind_with_vars(witness_tys.to_vec(), all_vars));
},
break Where(ty::Binder::bind_with_vars(
witness_tys.to_vec(),
all_vars,
));
}
}
}
}

View File

@ -263,10 +263,10 @@ fn resolve_associated_item<'tcx>(
let is_copy = self_ty.is_copy_modulo_regions(tcx.at(DUMMY_SP), param_env);
match self_ty.kind() {
_ if is_copy => (),
ty::Generator(..) |
ty::GeneratorWitness(..) |
ty::Closure(..) |
ty::Tuple(..) => {},
ty::Generator(..)
| ty::GeneratorWitness(..)
| ty::Closure(..)
| ty::Tuple(..) => {}
_ => return Ok(None),
};