1
Fork 0

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

View file

@ -1939,11 +1939,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
ty::Generator(_, substs, hir::Movability::Movable) => { ty::Generator(_, substs, hir::Movability::Movable) => {
if self.tcx().features().generator_clone { if self.tcx().features().generator_clone {
let resolved_upvars = self.infcx.shallow_resolve(substs.as_generator().tupled_upvars_ty()); let resolved_upvars =
let resolved_witness = self.infcx.shallow_resolve(substs.as_generator().witness()); self.infcx.shallow_resolve(substs.as_generator().tupled_upvars_ty());
let resolved_witness =
self.infcx.shallow_resolve(substs.as_generator().witness());
if { if {
matches!(resolved_upvars.kind(), ty::Infer(ty::TyVar(_))) || matches!(resolved_upvars.kind(), ty::Infer(ty::TyVar(_)))
matches!(resolved_witness.kind(), ty::Infer(ty::TyVar(_))) || matches!(resolved_witness.kind(), ty::Infer(ty::TyVar(_)))
} { } {
// Not yet resolved. // Not yet resolved.
Ambiguous Ambiguous
@ -1967,14 +1969,21 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
if matches!(resolved.kind(), ty::Infer(ty::TyVar(_))) { if matches!(resolved.kind(), ty::Infer(ty::TyVar(_))) {
break Ambiguous; break Ambiguous;
} }
}, }
Option::None => { Option::None => {
// (*) binder moved here // (*) binder moved here
let all_vars = self.tcx().mk_bound_variable_kinds( 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); let is_copy = self_ty.is_copy_modulo_regions(tcx.at(DUMMY_SP), param_env);
match self_ty.kind() { match self_ty.kind() {
_ if is_copy => (), _ if is_copy => (),
ty::Generator(..) | ty::Generator(..)
ty::GeneratorWitness(..) | | ty::GeneratorWitness(..)
ty::Closure(..) | | ty::Closure(..)
ty::Tuple(..) => {}, | ty::Tuple(..) => {}
_ => return Ok(None), _ => return Ok(None),
}; };