Skip to content

Commit ac48e62

Browse files
committed
Auto merge of #73265 - mark-i-m:mv-std, r=Mark-Simulacrum,mark-i-m
mv std libs to library/ This is the first step in refactoring the directory layout of this repository, with further followup steps planned (but not done yet). Background: currently, all crates are under src/, without nested src directories and with the unconventional `lib*` prefixes (e.g., `src/libcore/lib.rs`). This directory structures is not idiomatic and makes the `src/` directory rather overwhelming. To improve contributor experience and make things a bit more approachable, we are reorganizing the repo a bit. In this PR, we move the standard libs (basically anything that is "runtime", as opposed to part of the compiler, build system, or one of the tools, etc). The new layout moves these libraries to a new `library/` directory in the root of the repo. Additionally, we remove the `lib*` prefixes and add nested `src/` directories. The other crates/tools in this repo are not touched. So in summary: ``` library/<crate>/src/*.rs src/<all the rest> // unchanged ``` where `<crate>` is: - core - alloc - std - test - proc_macro - panic_abort - panic_unwind - profiler_builtins - term - unwind - rtstartup - backtrace - rustc-std-workspace-* There was a lot of discussion about this and a few rounds of compiler team approvals, FCPs, MCPs, and nominations. The original MCP is rust-lang/compiler-team#298. The final approval of the compiler team was given here: #73265 (comment). The name `library` was chosen to complement a later move of the compiler crates to a `compiler/` directory. There was a lot of discussion around adding the nested `src/` directories. Note that this does increase the nesting depth (plausibly important for manual traversal of the tree, e.g., through GitHub's UI or `cd`), but this is deemed to be better as it fits the standard layout of Rust crates throughout most of the ecosystem, though there is some debate about how much this should apply to multi-crate projects. Overall, there seem to be more people in favor of nested `src/` than against. After this PR, there are no dependencies out of the `library/` directory except on the `build_helper` (or crates.io crates).
2 parents 9be8ffc + 2c31b45 commit ac48e62

File tree

875 files changed

+1254
-1222
lines changed

Some content is hidden

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

875 files changed

+1254
-1222
lines changed

.gitmodules

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
[submodule "src/doc/rust-by-example"]
2626
path = src/doc/rust-by-example
2727
url = https://github.com/rust-lang/rust-by-example.git
28-
[submodule "src/stdarch"]
29-
path = src/stdarch
28+
[submodule "library/stdarch"]
29+
path = library/stdarch
3030
url = https://github.com/rust-lang/stdarch.git
3131
[submodule "src/doc/rustc-dev-guide"]
3232
path = src/doc/rustc-dev-guide

Cargo.toml

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
members = [
33
"src/bootstrap",
44
"src/rustc",
5-
"src/libstd",
6-
"src/libtest",
75
"src/librustc_codegen_llvm",
6+
"library/std",
7+
"library/test",
88
"src/tools/cargotest",
99
"src/tools/clippy",
1010
"src/tools/compiletest",
@@ -74,11 +74,11 @@ rustfmt-nightly = { path = "src/tools/rustfmt" }
7474
# here
7575
rustc-workspace-hack = { path = 'src/tools/rustc-workspace-hack' }
7676

77-
# See comments in `tools/rustc-std-workspace-core/README.md` for what's going on
77+
# See comments in `library/rustc-std-workspace-core/README.md` for what's going on
7878
# here
79-
rustc-std-workspace-core = { path = 'src/tools/rustc-std-workspace-core' }
80-
rustc-std-workspace-alloc = { path = 'src/tools/rustc-std-workspace-alloc' }
81-
rustc-std-workspace-std = { path = 'src/tools/rustc-std-workspace-std' }
79+
rustc-std-workspace-core = { path = 'library/rustc-std-workspace-core' }
80+
rustc-std-workspace-alloc = { path = 'library/rustc-std-workspace-alloc' }
81+
rustc-std-workspace-std = { path = 'library/rustc-std-workspace-std' }
8282

8383
[patch."https://github.com/rust-lang/rust-clippy"]
8484
clippy_lints = { path = "src/tools/clippy/clippy_lints" }

src/liballoc/Cargo.toml library/alloc/Cargo.toml

+4-8
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ autotests = false
66
autobenches = false
77
edition = "2018"
88

9-
[lib]
10-
name = "alloc"
11-
path = "lib.rs"
12-
139
[dependencies]
14-
core = { path = "../libcore" }
10+
core = { path = "../core" }
1511
compiler_builtins = { version = "0.1.10", features = ['rustc-dep-of-std'] }
1612

1713
[dev-dependencies]
@@ -20,16 +16,16 @@ rand_xorshift = "0.2"
2016

2117
[[test]]
2218
name = "collectionstests"
23-
path = "../liballoc/tests/lib.rs"
19+
path = "tests/lib.rs"
2420

2521
[[bench]]
2622
name = "collectionsbenches"
27-
path = "../liballoc/benches/lib.rs"
23+
path = "benches/lib.rs"
2824
test = true
2925

3026
[[bench]]
3127
name = "vec_deque_append_bench"
32-
path = "../liballoc/benches/vec_deque_append.rs"
28+
path = "benches/vec_deque_append.rs"
3329
harness = false
3430

3531
[features]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/libcore/Cargo.toml library/core/Cargo.toml

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,16 @@ autobenches = false
77
edition = "2018"
88

99
[lib]
10-
name = "core"
11-
path = "lib.rs"
1210
test = false
1311
bench = false
1412

1513
[[test]]
1614
name = "coretests"
17-
path = "../libcore/tests/lib.rs"
15+
path = "tests/lib.rs"
1816

1917
[[bench]]
2018
name = "corebenches"
21-
path = "../libcore/benches/lib.rs"
19+
path = "benches/lib.rs"
2220
test = true
2321

2422
[dev-dependencies]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/libcore/lib.rs library/core/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ pub mod primitive;
283283
// `core_arch` depends on libcore, but the contents of this module are
284284
// set up in such a way that directly pulling it here works such that the
285285
// crate uses the this crate as its libcore.
286-
#[path = "../stdarch/crates/core_arch/src/mod.rs"]
286+
#[path = "../../stdarch/crates/core_arch/src/mod.rs"]
287287
#[allow(
288288
missing_docs,
289289
missing_debug_implementations,
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/libpanic_abort/Cargo.toml library/panic_abort/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ version = "0.0.0"
55
edition = "2018"
66

77
[lib]
8-
path = "lib.rs"
98
test = false
109
bench = false
1110
doc = false
1211

1312
[dependencies]
1413
cfg-if = { version = "0.1.8", features = ['rustc-dep-of-std'] }
15-
core = { path = "../libcore" }
14+
core = { path = "../core" }
1615
libc = { version = "0.2", default-features = false }
1716
compiler_builtins = "0.1.0"
File renamed without changes.

src/libpanic_unwind/Cargo.toml library/panic_unwind/Cargo.toml

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ version = "0.0.0"
55
edition = "2018"
66

77
[lib]
8-
path = "lib.rs"
98
test = false
109
bench = false
1110
doc = false
1211

1312
[dependencies]
14-
alloc = { path = "../liballoc" }
15-
core = { path = "../libcore" }
13+
alloc = { path = "../alloc" }
14+
core = { path = "../core" }
1615
libc = { version = "0.2", default-features = false }
17-
unwind = { path = "../libunwind" }
16+
unwind = { path = "../unwind" }
1817
compiler_builtins = "0.1.0"
1918
cfg-if = "0.1.8"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/libproc_macro/Cargo.toml library/proc_macro/Cargo.toml

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,5 @@ name = "proc_macro"
44
version = "0.0.0"
55
edition = "2018"
66

7-
[lib]
8-
path = "lib.rs"
9-
107
[dependencies]
11-
std = { path = "../libstd" }
8+
std = { path = "../std" }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/libprofiler_builtins/Cargo.toml library/profiler_builtins/Cargo.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ version = "0.0.0"
55
edition = "2018"
66

77
[lib]
8-
name = "profiler_builtins"
9-
path = "lib.rs"
108
test = false
119
bench = false
1210
doc = false
1311

1412
[dependencies]
15-
core = { path = "../libcore" }
13+
core = { path = "../core" }
1614
compiler_builtins = { version = "0.1.0", features = ['rustc-dep-of-std'] }
1715

1816
[build-dependencies]

src/libprofiler_builtins/build.rs library/profiler_builtins/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn main() {
7373

7474
// Note that this should exist if we're going to run (otherwise we just
7575
// don't build profiler builtins at all).
76-
let root = Path::new("../llvm-project/compiler-rt");
76+
let root = Path::new("../../src/llvm-project/compiler-rt");
7777

7878
let src_root = root.join("lib").join("profile");
7979
for src in profile_sources {

0 commit comments

Comments
 (0)