Skip to content

Commit b58f1e9

Browse files
committed
Split SpannedTypeVisitor into its own crate, rustc_ty_walk
`rustc_privacy` pulls in all of `rustc_ty_utils`, but only wants `SpannedTypeVisitor` and `walk_types`. Move those to a small `rustc_ty_walk` crate. This allows `rustc_privacy` to start building much sooner.
1 parent 73dc916 commit b58f1e9

8 files changed

Lines changed: 37 additions & 11 deletions

File tree

Cargo.lock

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4619,7 +4619,7 @@ dependencies = [
46194619
"rustc_middle",
46204620
"rustc_session",
46214621
"rustc_span",
4622-
"rustc_ty_utils",
4622+
"rustc_ty_walk",
46234623
"tracing",
46244624
]
46254625

@@ -4906,6 +4906,17 @@ dependencies = [
49064906
"rustc_span",
49074907
"rustc_target",
49084908
"rustc_trait_selection",
4909+
"rustc_ty_walk",
4910+
"tracing",
4911+
]
4912+
4913+
[[package]]
4914+
name = "rustc_ty_walk"
4915+
version = "0.0.0"
4916+
dependencies = [
4917+
"rustc_hir",
4918+
"rustc_middle",
4919+
"rustc_span",
49094920
"tracing",
49104921
]
49114922

compiler/rustc_privacy/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ rustc_macros = { path = "../rustc_macros" }
1313
rustc_middle = { path = "../rustc_middle" }
1414
rustc_session = { path = "../rustc_session" }
1515
rustc_span = { path = "../rustc_span" }
16-
rustc_ty_utils = { path = "../rustc_ty_utils" }
16+
rustc_ty_walk = { path = "../rustc_ty_walk" }
1717
tracing = "0.1"
1818
# tidy-alphabetical-end

compiler/rustc_privacy/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ impl<'tcx> TypePrivacyVisitor<'tcx> {
11611161
}
11621162
}
11631163

1164-
impl<'tcx> rustc_ty_utils::sig_types::SpannedTypeVisitor<'tcx> for TypePrivacyVisitor<'tcx> {
1164+
impl<'tcx> rustc_ty_walk::SpannedTypeVisitor<'tcx> for TypePrivacyVisitor<'tcx> {
11651165
type Result = ControlFlow<()>;
11661166
fn visit(&mut self, span: Span, value: impl TypeVisitable<TyCtxt<'tcx>>) -> Self::Result {
11671167
self.span = span;
@@ -1754,7 +1754,7 @@ fn check_mod_privacy(tcx: TyCtxt<'_>, mod_id: LocalModId) {
17541754

17551755
let module = tcx.hir_module_items(mod_id);
17561756
for def_id in module.definitions() {
1757-
let _ = rustc_ty_utils::sig_types::walk_types(tcx, def_id, &mut visitor);
1757+
let _ = rustc_ty_walk::walk_types(tcx, def_id, &mut visitor);
17581758

17591759
if let Some(body_id) = tcx.hir_maybe_body_owned_by(def_id) {
17601760
visitor.visit_nested_body(body_id.id());

compiler/rustc_ty_utils/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ rustc_session = { path = "../rustc_session" }
1919
rustc_span = { path = "../rustc_span" }
2020
rustc_target = { path = "../rustc_target" }
2121
rustc_trait_selection = { path = "../rustc_trait_selection" }
22+
rustc_ty_walk = { path = "../rustc_ty_walk" }
2223
tracing = "0.1"
2324
# tidy-alphabetical-end

compiler/rustc_ty_utils/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
//! This API is completely unstable and subject to change.
66
77
// tidy-alphabetical-start
8-
#![feature(associated_type_defaults)]
98
#![feature(deref_patterns)]
109
#![feature(iterator_try_collect)]
1110
#![feature(never_type)]
@@ -26,7 +25,6 @@ mod needs_drop;
2625
mod nested_bodies;
2726
mod opaque_types;
2827
mod representability;
29-
pub mod sig_types;
3028
mod structural_match;
3129
mod ty;
3230

compiler/rustc_ty_utils/src/opaque_types.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
186186
trace!(?define);
187187
let mode = std::mem::replace(&mut self.mode, CollectionMode::Taits);
188188
let n = self.opaques.len();
189-
super::sig_types::walk_types(self.tcx, define, self);
189+
rustc_ty_walk::walk_types(self.tcx, define, self);
190190
if n == self.opaques.len() {
191191
self.tcx.dcx().span_err(span, "item does not contain any opaque types");
192192
}
@@ -198,7 +198,7 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
198198
}
199199
}
200200

201-
impl<'tcx> super::sig_types::SpannedTypeVisitor<'tcx> for OpaqueTypeCollector<'tcx> {
201+
impl<'tcx> rustc_ty_walk::SpannedTypeVisitor<'tcx> for OpaqueTypeCollector<'tcx> {
202202
#[instrument(skip(self), ret, level = "trace")]
203203
fn visit(&mut self, span: Span, value: impl TypeVisitable<TyCtxt<'tcx>>) {
204204
self.visit_spanned(span, value);
@@ -328,7 +328,7 @@ fn opaque_types_defined_by<'tcx>(
328328
trace!(?kind);
329329
let mut collector = OpaqueTypeCollector::new(tcx, item);
330330
collector.collect_taits_from_defines_attr();
331-
super::sig_types::walk_types(tcx, item, &mut collector);
331+
rustc_ty_walk::walk_types(tcx, item, &mut collector);
332332

333333
match kind {
334334
DefKind::AssocFn

compiler/rustc_ty_walk/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "rustc_ty_walk"
3+
version = "0.0.0"
4+
edition = "2024"
5+
6+
[dependencies]
7+
# tidy-alphabetical-start
8+
rustc_hir = { path = "../rustc_hir" }
9+
rustc_middle = { path = "../rustc_middle" }
10+
rustc_span = { path = "../rustc_span" }
11+
tracing = "0.1"
12+
# tidy-alphabetical-end
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
//! This module contains helpers for walking all types of
2-
//! a signature, while preserving spans as much as possible
1+
//! This crate contains a helper for walking all types of a signature, while preserving spans as
2+
//! much as possible
3+
4+
// tidy-alphabetical-start
5+
#![feature(associated_type_defaults)]
6+
// tidy-alphabetical-end
37

48
use rustc_hir::def::DefKind;
59
use rustc_hir::def_id::LocalDefId;

0 commit comments

Comments
 (0)