Skip to content

Commit e0f3119

Browse files
Introduce TypeVisitor::BreakTy
1 parent 30e49a9 commit e0f3119

File tree

31 files changed

+157
-128
lines changed

31 files changed

+157
-128
lines changed

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
14981498
}
14991499

15001500
impl<'tcx> ty::fold::TypeVisitor<'tcx> for OpaqueTypesVisitor<'tcx> {
1501-
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<()> {
1501+
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
15021502
if let Some((kind, def_id)) = TyCategory::from_ty(t) {
15031503
let span = self.tcx.def_span(def_id);
15041504
// Avoid cluttering the output when the "found" and error span overlap:

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
474474
struct TraitObjectVisitor(Vec<DefId>);
475475

476476
impl TypeVisitor<'_> for TraitObjectVisitor {
477-
fn visit_ty(&mut self, t: Ty<'_>) -> ControlFlow<()> {
477+
fn visit_ty(&mut self, t: Ty<'_>) -> ControlFlow<Self::BreakTy> {
478478
match t.kind() {
479479
ty::Dynamic(preds, RegionKind::ReStatic) => {
480480
if let Some(def_id) = preds.principal_def_id() {

compiler/rustc_infer/src/infer/nll_relate/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,15 +741,18 @@ struct ScopeInstantiator<'me, 'tcx> {
741741
}
742742

743743
impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> {
744-
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ControlFlow<()> {
744+
fn visit_binder<T: TypeFoldable<'tcx>>(
745+
&mut self,
746+
t: &ty::Binder<T>,
747+
) -> ControlFlow<Self::BreakTy> {
745748
self.target_index.shift_in(1);
746749
t.super_visit_with(self);
747750
self.target_index.shift_out(1);
748751

749752
ControlFlow::CONTINUE
750753
}
751754

752-
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<()> {
755+
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
753756
let ScopeInstantiator { bound_region_scope, next_region, .. } = self;
754757

755758
match r {

compiler/rustc_infer/src/infer/resolve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl<'a, 'tcx> UnresolvedTypeFinder<'a, 'tcx> {
123123
}
124124

125125
impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'tcx> {
126-
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<()> {
126+
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
127127
let t = self.infcx.shallow_resolve(t);
128128
if t.has_infer_types() {
129129
if let ty::Infer(infer_ty) = *t.kind() {

compiler/rustc_infer/src/traits/structural_impls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl<'tcx, O: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Obligation<'tcx
6969
}
7070
}
7171

72-
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<()> {
72+
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
7373
self.predicate.visit_with(visitor)
7474
}
7575
}

compiler/rustc_lint/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
11351135
};
11361136

11371137
impl<'a, 'tcx> ty::fold::TypeVisitor<'tcx> for ProhibitOpaqueTypes<'a, 'tcx> {
1138-
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<()> {
1138+
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
11391139
match ty.kind() {
11401140
ty::Opaque(..) => {
11411141
self.ty = Some(ty);

compiler/rustc_macros/src/type_foldable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::
3535
fn super_visit_with<__F: ::rustc_middle::ty::fold::TypeVisitor<'tcx>>(
3636
&self,
3737
__folder: &mut __F
38-
) -> ::std::ops::ControlFlow<()> {
38+
) -> ::std::ops::ControlFlow<__F::BreakTy> {
3939
match *self { #body_visit }
4040
::std::ops::ControlFlow::CONTINUE
4141
}

compiler/rustc_middle/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#![feature(half_open_range_patterns)]
5252
#![feature(exclusive_range_pattern)]
5353
#![feature(control_flow_enum)]
54+
#![feature(associated_type_defaults)]
5455
#![recursion_limit = "512"]
5556

5657
#[macro_use]

compiler/rustc_middle/src/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ macro_rules! CloneTypeFoldableImpls {
6262
fn super_visit_with<F: $crate::ty::fold::TypeVisitor<$tcx>>(
6363
&self,
6464
_: &mut F)
65-
-> ::std::ops::ControlFlow<()>
65+
-> ::std::ops::ControlFlow<F::BreakTy>
6666
{
6767
::std::ops::ControlFlow::CONTINUE
6868
}
@@ -105,7 +105,7 @@ macro_rules! EnumTypeFoldableImpl {
105105
fn super_visit_with<V: $crate::ty::fold::TypeVisitor<$tcx>>(
106106
&self,
107107
visitor: &mut V,
108-
) -> ::std::ops::ControlFlow<()> {
108+
) -> ::std::ops::ControlFlow<V::BreakTy> {
109109
EnumTypeFoldableImpl!(@VisitVariants(self, visitor) input($($variants)*) output())
110110
}
111111
}

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2477,7 +2477,10 @@ impl<'tcx> TypeFoldable<'tcx> for UserTypeProjection {
24772477
UserTypeProjection { base, projs }
24782478
}
24792479

2480-
fn super_visit_with<Vs: TypeVisitor<'tcx>>(&self, visitor: &mut Vs) -> ControlFlow<()> {
2480+
fn super_visit_with<Vs: TypeVisitor<'tcx>>(
2481+
&self,
2482+
visitor: &mut Vs,
2483+
) -> ControlFlow<Vs::BreakTy> {
24812484
self.base.visit_with(visitor)
24822485
// Note: there's nothing in `self.proj` to visit.
24832486
}

0 commit comments

Comments
 (0)