Skip to content

Commit a64ad51

Browse files
committed
Address comments
1 parent 3c46fd6 commit a64ad51

File tree

3 files changed

+27
-42
lines changed

3 files changed

+27
-42
lines changed

compiler/rustc_middle/src/ty/outlives.rs

+4-16
Original file line numberDiff line numberDiff line change
@@ -96,26 +96,14 @@ fn compute_components(
9696
}
9797

9898
ty::Closure(_, ref substs) => {
99-
if substs.as_closure().is_valid() {
100-
for upvar_ty in substs.as_closure().upvar_tys() {
101-
compute_components(tcx, upvar_ty, out, visited);
102-
}
103-
} else {
104-
let tupled_ty = substs.as_closure().tupled_upvars_ty();
105-
compute_components(tcx, tupled_ty, out, visited);
106-
}
99+
let tupled_ty = substs.as_closure().tupled_upvars_ty();
100+
compute_components(tcx, tupled_ty, out, visited);
107101
}
108102

109103
ty::Generator(_, ref substs, _) => {
110104
// Same as the closure case
111-
if substs.as_generator().is_valid() {
112-
for upvar_ty in substs.as_generator().upvar_tys() {
113-
compute_components(tcx, upvar_ty, out, visited);
114-
}
115-
} else {
116-
let tupled_ty = substs.as_generator().tupled_upvars_ty();
117-
compute_components(tcx, tupled_ty, out, visited);
118-
}
105+
let tupled_ty = substs.as_generator().tupled_upvars_ty();
106+
compute_components(tcx, tupled_ty, out, visited);
119107

120108
// We ignore regions in the generator interior as we don't
121109
// want these to affect region inference

compiler/rustc_trait_selection/src/opaque_types.rs

+14-26
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
441441

442442
for required_region in required_region_bounds {
443443
concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor {
444-
infcx: self,
445444
op: |r| self.sub_regions(infer::CallReturn(span), required_region, r),
446445
});
447446
}
@@ -510,7 +509,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
510509
}
511510
}
512511
concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor {
513-
infcx: self,
514512
op: |r| self.sub_regions(infer::CallReturn(span), least_region, r),
515513
});
516514
}
@@ -545,7 +543,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
545543
);
546544

547545
concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor {
548-
infcx: self,
549546
op: |r| {
550547
self.member_constraint(
551548
opaque_type_def_id,
@@ -686,12 +683,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
686683
//
687684
// We ignore any type parameters because impl trait values are assumed to
688685
// capture all the in-scope type parameters.
689-
struct ConstrainOpaqueTypeRegionVisitor<'cx, 'tcx, OP> {
690-
infcx: &'cx InferCtxt<'cx, 'tcx>,
686+
struct ConstrainOpaqueTypeRegionVisitor<OP> {
691687
op: OP,
692688
}
693689

694-
impl<'cx, 'tcx, OP> TypeVisitor<'tcx> for ConstrainOpaqueTypeRegionVisitor<'cx, 'tcx, OP>
690+
impl<'tcx, OP> TypeVisitor<'tcx> for ConstrainOpaqueTypeRegionVisitor<OP>
695691
where
696692
OP: FnMut(ty::Region<'tcx>),
697693
{
@@ -721,36 +717,28 @@ where
721717
ty::Closure(_, ref substs) => {
722718
// Skip lifetime parameters of the enclosing item(s)
723719

724-
let ty = self.infcx.shallow_resolve(substs.as_closure().tupled_upvars_ty());
725-
if let ty::Infer(ty::TyVar(_)) = ty.kind() {
726-
// Not yet resolved.
727-
ty.super_visit_with(self);
728-
} else {
729-
for upvar_ty in substs.as_closure().upvar_tys() {
730-
upvar_ty.visit_with(self);
731-
}
720+
substs.as_closure().tupled_upvars_ty().visit_with(self);
732721

733-
substs.as_closure().sig_as_fn_ptr_ty().visit_with(self);
722+
for upvar_ty in substs.as_closure().upvar_tys() {
723+
upvar_ty.visit_with(self);
734724
}
725+
726+
substs.as_closure().sig_as_fn_ptr_ty().visit_with(self);
735727
}
736728

737729
ty::Generator(_, ref substs, _) => {
738730
// Skip lifetime parameters of the enclosing item(s)
739731
// Also skip the witness type, because that has no free regions.
740732

741-
let ty = self.infcx.shallow_resolve(substs.as_generator().tupled_upvars_ty());
742-
if let ty::Infer(ty::TyVar(_)) = ty.kind() {
743-
// Not yet resolved.
744-
ty.super_visit_with(self);
745-
} else {
746-
for upvar_ty in substs.as_generator().upvar_tys() {
747-
upvar_ty.visit_with(self);
748-
}
733+
substs.as_generator().tupled_upvars_ty().visit_with(self);
749734

750-
substs.as_generator().return_ty().visit_with(self);
751-
substs.as_generator().yield_ty().visit_with(self);
752-
substs.as_generator().resume_ty().visit_with(self);
735+
for upvar_ty in substs.as_generator().upvar_tys() {
736+
upvar_ty.visit_with(self);
753737
}
738+
739+
substs.as_generator().return_ty().visit_with(self);
740+
substs.as_generator().yield_ty().visit_with(self);
741+
substs.as_generator().resume_ty().visit_with(self);
754742
}
755743
_ => {
756744
ty.super_visit_with(self);

compiler/rustc_traits/src/dropck_outlives.rs

+9
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ fn dtorck_constraint_for_ty<'tcx>(
214214
if !substs.as_closure().is_valid() {
215215
// By the time this code runs, all type variables ought to
216216
// be fully resolved.
217+
218+
tcx.sess.delay_span_bug(
219+
span,
220+
&format!("upvar_tys for closure not found. Expected capture information for closure {}", ty,),
221+
);
217222
return Err(NoSolution);
218223
}
219224

@@ -252,6 +257,10 @@ fn dtorck_constraint_for_ty<'tcx>(
252257
if !substs.as_generator().is_valid() {
253258
// By the time this code runs, all type variables ought to
254259
// be fully resolved.
260+
tcx.sess.delay_span_bug(
261+
span,
262+
&format!("upvar_tys for generator not found. Expected capture information for generator {}", ty,),
263+
);
255264
return Err(NoSolution);
256265
}
257266

0 commit comments

Comments
 (0)