Skip to content

Commit 8e8dd82

Browse files
committed
Restrict sysroot crate imports to those defined in this repo.
It's common to import dependencies from the sysroot via `extern crate` rather than use an explicit cargo dependency, when it's necessary to use the same dependency version as used by rustc itself. However, this is dangerous for crates.io crates, since rustc may not pull in the dependency on some targets, or may pull in multiple versions. In both cases, the `extern crate` fails to resolve. To address this, re-export all such dependencies from the appropriate `rustc_*` crates, and use this alias from crates which would otherwise need to use `extern crate`. Also use workspace dependencies for such crates so that only one version can exist within the sysroot (since otherwise it is meaningless to try to match the rustc version).
1 parent de031bb commit 8e8dd82

File tree

108 files changed

+216
-258
lines changed

Some content is hidden

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

108 files changed

+216
-258
lines changed

Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ exclude = [
6060
"obj",
6161
]
6262

63+
[workspace.dependencies]
64+
# These dependencies are either explicitly part of rustc's public interface, or
65+
# are "singleton" crates that we want to only appear once in the dependency graph.
66+
either = "1.5"
67+
smallvec = { version = "1.8.1", features = ["const_generics", "union", "may_dangle"] }
68+
indexmap = "2.4"
69+
tracing = "0.1.28"
70+
tracing-subscriber = { version = "0.3.3", default-features = false, features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"] }
71+
pulldown-cmark = { version = "0.11", features = ["html"], default-features = false }
72+
thin-vec = "0.2.12"
73+
6374
[profile.release.package.rustc_thread_pool]
6475
# The rustc fork of Rayon has deadlock detection code which intermittently
6576
# causes overflows in the CI (see https://github.com/rust-lang/rust/issues/90227)

compiler/rustc_abi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ rustc_index = { path = "../rustc_index", default-features = false }
1414
rustc_macros = { path = "../rustc_macros", optional = true }
1515
rustc_serialize = { path = "../rustc_serialize", optional = true }
1616
rustc_span = { path = "../rustc_span", optional = true }
17-
tracing = "0.1"
17+
tracing = { workspace = true }
1818
# tidy-alphabetical-end
1919

2020
[features]

compiler/rustc_arena/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ edition = "2024"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
8+
smallvec = { workspace = true }
99
# tidy-alphabetical-end

compiler/rustc_ast/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ rustc_index = { path = "../rustc_index" }
1414
rustc_macros = { path = "../rustc_macros" }
1515
rustc_serialize = { path = "../rustc_serialize" }
1616
rustc_span = { path = "../rustc_span" }
17-
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
18-
thin-vec = "0.2.12"
19-
tracing = "0.1"
17+
smallvec = { workspace = true }
18+
thin-vec = { workspace = true }
19+
tracing = { workspace = true }
2020
# tidy-alphabetical-end

compiler/rustc_ast_lowering/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ rustc_middle = { path = "../rustc_middle" }
2424
rustc_session = { path = "../rustc_session" }
2525
rustc_span = { path = "../rustc_span" }
2626
rustc_target = { path = "../rustc_target" }
27-
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
28-
thin-vec = "0.2.12"
29-
tracing = "0.1"
27+
smallvec = { workspace = true }
28+
thin-vec = { workspace = true }
29+
tracing = { workspace = true }
3030
# tidy-alphabetical-end

compiler/rustc_ast_passes/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ rustc_parse = { path = "../rustc_parse" }
1919
rustc_session = { path = "../rustc_session" }
2020
rustc_span = { path = "../rustc_span" }
2121
rustc_target = { path = "../rustc_target" }
22-
thin-vec = "0.2.12"
22+
thin-vec = { workspace = true }
2323
# tidy-alphabetical-end

compiler/rustc_ast_pretty/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ rustc_span = { path = "../rustc_span" }
1313

1414
[dev-dependencies]
1515
# tidy-alphabetical-start
16-
thin-vec = "0.2.12"
16+
thin-vec = { workspace = true }
1717
# tidy-alphabetical-end

compiler/rustc_attr_data_structures/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ rustc_data_structures = {path = "../rustc_data_structures"}
1212
rustc_macros = {path = "../rustc_macros"}
1313
rustc_serialize = {path = "../rustc_serialize"}
1414
rustc_span = {path = "../rustc_span"}
15-
thin-vec = "0.2.12"
15+
thin-vec = { workspace = true }
1616
# tidy-alphabetical-end

compiler/rustc_attr_parsing/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ rustc_lexer = { path = "../rustc_lexer" }
1717
rustc_macros = { path = "../rustc_macros" }
1818
rustc_session = { path = "../rustc_session" }
1919
rustc_span = { path = "../rustc_span" }
20-
thin-vec = "0.2.12"
20+
thin-vec = { workspace = true }
2121
# tidy-alphabetical-end

compiler/rustc_borrowck/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2024"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
either = "1.5.0"
8+
either = { workspace = true }
99
itertools = "0.12"
1010
polonius-engine = "0.13.0"
1111
rustc_abi = { path = "../rustc_abi" }
@@ -24,6 +24,6 @@ rustc_session = { path = "../rustc_session" }
2424
rustc_span = { path = "../rustc_span" }
2525
rustc_trait_selection = { path = "../rustc_trait_selection" }
2626
rustc_traits = { path = "../rustc_traits" }
27-
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
28-
tracing = "0.1"
27+
smallvec = { workspace = true }
28+
tracing = { workspace = true }
2929
# tidy-alphabetical-end

0 commit comments

Comments
 (0)