Skip to content

Commit

Permalink
cleanup PR
Browse files Browse the repository at this point in the history
  • Loading branch information
roxelo committed Sep 28, 2020
1 parent d4f1eaf commit fd4c7e3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
/// Zed<i32> where enum Zed { A(T), B(u32) } -> [i32, u32]
/// ```
fn constituent_types_for_ty(&self, t: Ty<'tcx>) -> Vec<Ty<'tcx>> {
debug!("near the bug!");
match *t.kind() {
ty::Uint(_)
| ty::Int(_)
Expand Down Expand Up @@ -1751,11 +1750,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
ty::Generator(_, ref substs, _) => {
let upvar_tys_resolved =
self.infcx.shallow_resolve(substs.as_generator().tupled_upvars_ty());
let witness_resolved = self.infcx.shallow_resolve(substs.as_generator().witness());

if let ty::Infer(ty::TyVar(_)) = upvar_tys_resolved.kind() {
// The inference variable will be replaced by a tuple once capture analysis
// completes, if the tuple meets a bound, so do all the elements within it.
let witness_resolved =
self.infcx.shallow_resolve(substs.as_generator().witness());
vec![upvar_tys_resolved, witness_resolved]
} else {
let witness = substs.as_generator().witness();
Expand Down
19 changes: 1 addition & 18 deletions compiler/rustc_typeck/src/check/upvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,24 +206,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Build a tuple (U0..Un) of the final upvar types U0..Un
// and unify the upvar tupe type in the closure with it:
let final_tupled_upvars_type = self.tcx.mk_tup(final_upvar_tys.iter());
// self.demand_suptype(span, substs.tupled_upvars_ty(), final_tupled_upvars_type);

match *ty.kind() {
ty::Closure(_, ref substs) => self.demand_suptype(
span,
substs.as_closure().tupled_upvars_ty(),
final_tupled_upvars_type,
),
ty::Generator(_, ref substs, _) => self.demand_suptype(
span,
substs.as_generator().tupled_upvars_ty(),
final_tupled_upvars_type,
),
_ => bug!("Type not handled!"),
}

debug!("Capture analysis done");
debug!("{}", substs.tupled_upvars_ty());
self.demand_suptype(span, substs.tupled_upvars_ty(), final_tupled_upvars_type);

// If we are also inferred the closure kind here,
// process any deferred resolutions.
Expand Down

0 comments on commit fd4c7e3

Please sign in to comment.