Skip to content

Commit 349f23e

Browse files
committed
address comments and rebase on master
1 parent de57093 commit 349f23e

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

src/librustc_middle/ty/sty.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,10 +644,10 @@ impl<'tcx> UpvarSubsts<'tcx> {
644644
#[inline]
645645
pub fn upvar_tuple_ty(self) -> Ty<'tcx> {
646646
let tupled_upvars_ty = match self {
647-
UpvarSubsts::Closure(substs) => substs.as_closure().split().tupled_upvars_ty,
648-
UpvarSubsts::Generator(substs) => substs.as_generator().split().tupled_upvars_ty,
647+
UpvarSubsts::Closure(substs) => substs.as_closure().upvar_tuple_ty(),
648+
UpvarSubsts::Generator(substs) => substs.as_generator().upvar_tuple_ty(),
649649
};
650-
tupled_upvars_ty.expect_ty()
650+
tupled_upvars_ty
651651
}
652652
}
653653

src/librustc_trait_selection/opaque_types.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
441441
for required_region in required_region_bounds {
442442
concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor {
443443
op: |r| self.sub_regions(infer::CallReturn(span), required_region, r),
444+
infcx: self,
444445
});
445446
}
446447
if let GenerateMemberConstraints::IfNoStaticBound = mode {
@@ -509,6 +510,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
509510
}
510511
concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor {
511512
op: |r| self.sub_regions(infer::CallReturn(span), least_region, r),
513+
infcx: self,
512514
});
513515
}
514516

@@ -551,6 +553,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
551553
&choice_regions,
552554
)
553555
},
556+
infcx: self,
554557
});
555558
}
556559

@@ -682,11 +685,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
682685
//
683686
// We ignore any type parameters because impl trait values are assumed to
684687
// capture all the in-scope type parameters.
685-
struct ConstrainOpaqueTypeRegionVisitor<OP> {
688+
struct ConstrainOpaqueTypeRegionVisitor<'cx, 'tcx, OP> {
686689
op: OP,
690+
infcx: &'cx InferCtxt<'cx, 'tcx>,
687691
}
688692

689-
impl<'tcx, OP> TypeVisitor<'tcx> for ConstrainOpaqueTypeRegionVisitor<OP>
693+
impl<'cx, 'tcx, OP> TypeVisitor<'tcx> for ConstrainOpaqueTypeRegionVisitor<'cx, 'tcx, OP>
690694
where
691695
OP: FnMut(ty::Region<'tcx>),
692696
{
@@ -716,7 +720,8 @@ where
716720
ty::Closure(_, ref substs) => {
717721
// Skip lifetime parameters of the enclosing item(s)
718722

719-
if !substs.as_closure().is_valid() {
723+
let ty = self.infcx.shallow_resolve(substs.as_closure().upvar_tuple_ty());
724+
if let ty::Infer(ty::TyVar(_)) = ty.kind {
720725
// Not yet resolved.
721726
ty.super_visit_with(self);
722727
} else {
@@ -732,7 +737,8 @@ where
732737
// Skip lifetime parameters of the enclosing item(s)
733738
// Also skip the witness type, because that has no free regions.
734739

735-
if !substs.as_generator().is_valid() {
740+
let ty = self.infcx.shallow_resolve(substs.as_generator().upvar_tuple_ty());
741+
if let ty::Infer(ty::TyVar(_)) = ty.kind {
736742
// Not yet resolved.
737743
ty.super_visit_with(self);
738744
} else {

src/librustc_trait_selection/traits/wf.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,13 +521,12 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
521521
// are not directly inspecting closure types
522522
// anyway, except via auto trait matching (which
523523
// only inspects the upvar types).
524+
walker.skip_current_subtree(); // subtree handled below
524525
let ty = self.infcx.shallow_resolve(substs.as_closure().upvar_tuple_ty());
525526
if let ty::Infer(ty::TyVar(_)) = ty.kind {
526527
// Not yet resolved.
527-
walker.skip_current_subtree();
528528
self.compute(ty.into());
529529
} else {
530-
walker.skip_current_subtree(); // subtree handled below
531530
for upvar_ty in substs.as_closure().upvar_tys() {
532531
// FIXME(eddyb) add the type to `walker` instead of recursing.
533532
self.compute(upvar_ty.into());

src/librustc_typeck/check/coercion.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -916,13 +916,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
916916
// Function items or non-capturing closures of differing IDs or InternalSubsts.
917917
let (a_sig, b_sig) = {
918918
let is_capturing_closure = |ty| {
919-
if let &ty::Closure(_, substs) = ty {
920-
let ty = self.infcx.shallow_resolve(substs.as_closure().upvar_tuple_ty());
921-
if let ty::Infer(ty::TyVar(_)) = ty.kind {
922-
substs.as_closure().upvar_tys().next().is_some()
923-
} else {
924-
false
925-
}
919+
if let &ty::Closure(closure_def_id_a, _substs) = ty {
920+
self.tcx.upvars_mentioned(closure_def_id_a.expect_local()).is_some()
926921
} else {
927922
false
928923
}

0 commit comments

Comments
 (0)