Skip to content

Commit b6913d1

Browse files
committed
Convert TypeVisitor and DefIdVisitor to use VisitorResult
1 parent 1b44611 commit b6913d1

File tree

58 files changed

+390
-457
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+390
-457
lines changed

Cargo.lock

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3481,6 +3481,7 @@ dependencies = [
34813481
"rustc_session",
34823482
"rustc_span",
34833483
"rustc_target",
3484+
"rustc_type_ir",
34843485
"thin-vec",
34853486
]
34863487

@@ -3571,6 +3572,7 @@ dependencies = [
35713572
"rustc_session",
35723573
"rustc_span",
35733574
"rustc_target",
3575+
"rustc_type_ir",
35743576
"smallvec",
35753577
"thin-vec",
35763578
"tracing",
@@ -3842,6 +3844,7 @@ dependencies = [
38423844
"rustc_serialize",
38433845
"rustc_session",
38443846
"rustc_span",
3847+
"rustc_type_ir",
38453848
"smallvec",
38463849
"termcolor",
38473850
"thin-vec",
@@ -3890,6 +3893,7 @@ dependencies = [
38903893
"rustc_serialize",
38913894
"rustc_span",
38923895
"rustc_target",
3896+
"rustc_type_ir",
38933897
"smallvec",
38943898
"tracing",
38953899
]
@@ -4016,6 +4020,7 @@ dependencies = [
40164020
"rustc_middle",
40174021
"rustc_span",
40184022
"rustc_target",
4023+
"rustc_type_ir",
40194024
"smallvec",
40204025
"tracing",
40214026
]
@@ -4405,6 +4410,7 @@ dependencies = [
44054410
"rustc_session",
44064411
"rustc_span",
44074412
"rustc_ty_utils",
4413+
"rustc_type_ir",
44084414
"tracing",
44094415
]
44104416

@@ -4475,6 +4481,7 @@ dependencies = [
44754481
"rustc_query_system",
44764482
"rustc_session",
44774483
"rustc_span",
4484+
"rustc_type_ir",
44784485
"smallvec",
44794486
"thin-vec",
44804487
"tracing",
@@ -4615,6 +4622,7 @@ dependencies = [
46154622
"rustc_span",
46164623
"rustc_target",
46174624
"rustc_transmute",
4625+
"rustc_type_ir",
46184626
"smallvec",
46194627
"tracing",
46204628
]
@@ -4644,6 +4652,7 @@ dependencies = [
46444652
"rustc_middle",
46454653
"rustc_span",
46464654
"rustc_target",
4655+
"rustc_type_ir",
46474656
"tracing",
46484657
]
46494658

compiler/rustc_ast_passes/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ rustc_parse = { path = "../rustc_parse" }
1818
rustc_session = { path = "../rustc_session" }
1919
rustc_span = { path = "../rustc_span" }
2020
rustc_target = { path = "../rustc_target" }
21+
rustc_type_ir = { path = "../rustc_type_ir" }
2122
thin-vec = "0.2.12"
2223
# tidy-alphabetical-end

compiler/rustc_builtin_macros/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ rustc_parse_format = { path = "../rustc_parse_format" }
2525
rustc_session = { path = "../rustc_session" }
2626
rustc_span = { path = "../rustc_span" }
2727
rustc_target = { path = "../rustc_target" }
28+
rustc_type_ir = { path = "../rustc_type_ir" }
2829
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
2930
thin-vec = "0.2.12"
3031
tracing = "0.1"

compiler/rustc_const_eval/src/interpret/util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ where
3030
}
3131

3232
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for UsedParamsNeedInstantiationVisitor<'tcx> {
33-
type BreakTy = FoundParam;
33+
type Result = ControlFlow<FoundParam>;
3434

35-
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
35+
fn visit_ty(&mut self, ty: Ty<'tcx>) -> Self::Result {
3636
if !ty.has_param() {
3737
return ControlFlow::Continue(());
3838
}
@@ -64,7 +64,7 @@ where
6464
}
6565
}
6666

67-
fn visit_const(&mut self, c: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
67+
fn visit_const(&mut self, c: ty::Const<'tcx>) -> Self::Result {
6868
match c.kind() {
6969
ty::ConstKind::Param(..) => ControlFlow::Break(FoundParam),
7070
_ => c.super_visit_with(self),

compiler/rustc_const_eval/src/transform/check_consts/check.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_trait_selection::traits::{self, ObligationCauseCode, ObligationCtxt};
1717
use rustc_type_ir::visit::{TypeSuperVisitable, TypeVisitor};
1818

1919
use std::mem;
20-
use std::ops::{ControlFlow, Deref};
20+
use std::ops::Deref;
2121

2222
use super::ops::{self, NonConstOp, Status};
2323
use super::qualifs::{self, HasMutInterior, NeedsDrop, NeedsNonConstDrop};
@@ -164,9 +164,9 @@ struct LocalReturnTyVisitor<'ck, 'mir, 'tcx> {
164164
}
165165

166166
impl<'ck, 'mir, 'tcx> TypeVisitor<TyCtxt<'tcx>> for LocalReturnTyVisitor<'ck, 'mir, 'tcx> {
167-
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
167+
fn visit_ty(&mut self, t: Ty<'tcx>) {
168168
match t.kind() {
169-
ty::FnPtr(_) => ControlFlow::Continue(()),
169+
ty::FnPtr(_) => {}
170170
ty::Ref(_, _, hir::Mutability::Mut) => {
171171
self.checker.check_op(ops::ty::MutRef(self.kind));
172172
t.super_visit_with(self)

compiler/rustc_expand/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ rustc_parse = { path = "../rustc_parse" }
2424
rustc_serialize = { path = "../rustc_serialize" }
2525
rustc_session = { path = "../rustc_session" }
2626
rustc_span = { path = "../rustc_span" }
27+
rustc_type_ir = { path = "../rustc_type_ir" }
2728
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
2829
termcolor = "1.2"
2930
thin-vec = "0.2.12"

compiler/rustc_hir/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ rustc_macros = { path = "../rustc_macros" }
1414
rustc_serialize = { path = "../rustc_serialize" }
1515
rustc_span = { path = "../rustc_span" }
1616
rustc_target = { path = "../rustc_target" }
17+
rustc_type_ir = { path = "../rustc_type_ir" }
1718
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
1819
tracing = "0.1"
1920
# tidy-alphabetical-end

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,15 +1486,14 @@ fn opaque_type_cycle_error(
14861486
closures: Vec<DefId>,
14871487
}
14881488
impl<'tcx> ty::visit::TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector {
1489-
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
1489+
fn visit_ty(&mut self, t: Ty<'tcx>) {
14901490
match *t.kind() {
14911491
ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => {
14921492
self.opaques.push(def);
1493-
ControlFlow::Continue(())
14941493
}
14951494
ty::Closure(def_id, ..) | ty::Coroutine(def_id, ..) => {
14961495
self.closures.push(def_id);
1497-
t.super_visit_with(self)
1496+
t.super_visit_with(self);
14981497
}
14991498
_ => t.super_visit_with(self),
15001499
}

compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use rustc_trait_selection::regions::InferCtxtRegionExt;
1212
use rustc_trait_selection::traits::{
1313
elaborate, normalize_param_env_or_error, outlives_bounds::InferCtxtExt, ObligationCtxt,
1414
};
15-
use std::ops::ControlFlow;
1615

1716
/// Check that an implementation does not refine an RPITIT from a trait method signature.
1817
pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
@@ -207,9 +206,7 @@ struct ImplTraitInTraitCollector<'tcx> {
207206
}
208207

209208
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'tcx> {
210-
type BreakTy = !;
211-
212-
fn visit_ty(&mut self, ty: Ty<'tcx>) -> std::ops::ControlFlow<Self::BreakTy> {
209+
fn visit_ty(&mut self, ty: Ty<'tcx>) {
213210
if let ty::Alias(ty::Projection, proj) = *ty.kind()
214211
&& self.tcx.is_impl_trait_in_trait(proj.def_id)
215212
{
@@ -219,12 +216,11 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'tcx> {
219216
.explicit_item_bounds(proj.def_id)
220217
.iter_instantiated_copied(self.tcx, proj.args)
221218
{
222-
pred.visit_with(self)?;
219+
pred.visit_with(self);
223220
}
224221
}
225-
ControlFlow::Continue(())
226222
} else {
227-
ty.super_visit_with(self)
223+
ty.super_visit_with(self);
228224
}
229225
}
230226
}

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -809,9 +809,7 @@ impl<'tcx> GATArgsCollector<'tcx> {
809809
}
810810

811811
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for GATArgsCollector<'tcx> {
812-
type BreakTy = !;
813-
814-
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
812+
fn visit_ty(&mut self, t: Ty<'tcx>) {
815813
match t.kind() {
816814
ty::Alias(ty::Projection, p) if p.def_id == self.gat => {
817815
for (idx, arg) in p.args.iter().enumerate() {
@@ -1456,20 +1454,19 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
14561454
params: FxHashSet<u32>,
14571455
}
14581456
impl<'tcx> ty::visit::TypeVisitor<TyCtxt<'tcx>> for CountParams {
1459-
type BreakTy = ();
1460-
1461-
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
1457+
type Result = ControlFlow<()>;
1458+
fn visit_ty(&mut self, t: Ty<'tcx>) -> Self::Result {
14621459
if let ty::Param(param) = t.kind() {
14631460
self.params.insert(param.index);
14641461
}
14651462
t.super_visit_with(self)
14661463
}
14671464

1468-
fn visit_region(&mut self, _: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
1465+
fn visit_region(&mut self, _: ty::Region<'tcx>) -> Self::Result {
14691466
ControlFlow::Break(())
14701467
}
14711468

1472-
fn visit_const(&mut self, c: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
1469+
fn visit_const(&mut self, c: ty::Const<'tcx>) -> Self::Result {
14731470
if let ty::ConstKind::Param(param) = c.kind() {
14741471
self.params.insert(param.index);
14751472
}

0 commit comments

Comments
 (0)