Skip to content

Commit 7659434

Browse files
authored
Rollup merge of #161277 - Zalathar:session, r=Kobzol
bootstrap: Move all non-module items out of the crate root - Previously: #161219 --- After several rounds of preparation, this PR moves all non-module items out of bootstrap's crate root. Having non-trivial code in the crate root is generally a bad idea. Anything defined or imported there is unconditionally visible throughout the entire crate, leading to messy imports and unclear abstraction boundaries, and causing friction when code needs to be moved elsewhere. The commits have been structured to preserve as much line history as possible, and to minimize the number of other changes in the commit that performs the actual move, while remaining functional at every intermediate step.
2 parents 649278e + 91374a5 commit 7659434

29 files changed

Lines changed: 1915 additions & 1881 deletions

‎src/bootstrap/src/cli_main.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ use std::{env, process};
1616
use crate::core::builder::StepStack;
1717
use crate::core::config::flags::{Flags, Subcommand};
1818
use crate::core::config::{ChangeId, Config};
19+
use crate::core::session::Build;
20+
use crate::debug;
1921
use crate::utils::change_tracker::{
2022
CONFIG_CHANGE_HISTORY, find_recent_config_change_ids, human_readable_changes,
2123
};
2224
use crate::utils::helpers::t;
23-
use crate::{Build, debug};
2425

2526
fn is_tracing_enabled() -> bool {
2627
cfg!(feature = "tracing")

‎src/bootstrap/src/core/build_steps/check.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use std::fs;
44
use std::path::{Path, PathBuf};
55

6-
use crate::Mode;
76
use crate::core::backend::CodegenBackendKind;
87
use crate::core::build_steps::compile::{
98
ArtifactKeepMode, add_to_sysroot, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo,
@@ -20,6 +19,7 @@ use crate::core::builder::{
2019
};
2120
use crate::core::compiler::Compiler;
2221
use crate::core::config::TargetSelection;
22+
use crate::core::session::Mode;
2323
use crate::utils::build_stamp::{self, BuildStamp};
2424
use crate::utils::helpers::t;
2525

‎src/bootstrap/src/core/build_steps/clean.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ use crate::core::builder::{
1414
};
1515
use crate::core::compiler::Compiler;
1616
use crate::core::config::flags::Subcommand;
17+
use crate::core::session::{Build, Mode};
1718
use crate::utils::build_stamp::BuildStamp;
1819
use crate::utils::helpers::t;
19-
use crate::{Build, Mode};
2020

2121
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2222
pub struct CleanAll {}

‎src/bootstrap/src/core/build_steps/clippy.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
//! (as usual) a massive undertaking/refactoring.
1515
1616
use super::tool::{SourceType, prepare_tool_cargo};
17-
use crate::Mode;
1817
use crate::core::build_steps::check::{CompilerForCheck, prepare_compiler_for_check};
1918
use crate::core::build_steps::compile::{
2019
ArtifactKeepMode, run_cargo, rustc_cargo, std_cargo, std_crates_for_make_run,
@@ -26,6 +25,7 @@ use crate::core::builder::{
2625
use crate::core::compiler::Compiler;
2726
use crate::core::config::TargetSelection;
2827
use crate::core::config::flags::Subcommand;
28+
use crate::core::session::Mode;
2929
use crate::utils::build_stamp::{self, BuildStamp};
3030
use crate::utils::helpers;
3131

‎src/bootstrap/src/core/build_steps/compile.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ use crate::core::config::toml::target::DefaultLinuxLinkerOverride;
3333
use crate::core::config::{
3434
Allocator, CompilerBuiltins, DebuginfoLevel, LlvmLibunwind, RustcLto, TargetSelection,
3535
};
36+
use crate::core::session::{CLang, DependencyType, FileType, GitRepo, Mode};
3637
use crate::utils::build_stamp;
3738
use crate::utils::build_stamp::BuildStamp;
3839
use crate::utils::exec::command;
3940
use crate::utils::helpers::{
4041
self, exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, symlink_dir, t, up_to_date,
4142
};
42-
use crate::{CLang, DependencyType, FileType, GitRepo, Mode, debug, trace};
43+
use crate::{debug, trace};
4344

4445
/// Build a standard library for the given `target` using the given `build_compiler`.
4546
#[derive(Debug, Clone, PartialEq, Eq, Hash)]

‎src/bootstrap/src/core/build_steps/dist.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,15 @@ use crate::core::builder::{
3838
};
3939
use crate::core::compiler::Compiler;
4040
use crate::core::config::{GccCiMode, TargetSelection};
41+
use crate::core::session::{DependencyType, FileType, Mode};
42+
use crate::trace;
4143
use crate::utils::build_stamp::{self, BuildStamp};
4244
use crate::utils::channel::{self, Info};
4345
use crate::utils::exec::{BootstrapCommand, command};
4446
use crate::utils::helpers::{
4547
exe, is_dylib, move_file, t, target_supports_cranelift_backend, timeit,
4648
};
4749
use crate::utils::tarball::{GeneratedTarball, OverlayKind, Tarball};
48-
use crate::{DependencyType, FileType, Mode, trace};
4950

5051
pub(crate) const LLVM_TOOLS: &[&str] = &[
5152
"llvm-cov", // used to generate coverage report

‎src/bootstrap/src/core/build_steps/doc.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ use crate::core::builder::{
2121
};
2222
use crate::core::compiler::Compiler;
2323
use crate::core::config::{Config, TargetSelection};
24+
use crate::core::session::{FileType, Mode};
2425
use crate::utils::helpers::{submodule_path_of, symlink_dir, t, up_to_date};
25-
use crate::{FileType, Mode};
2626

2727
macro_rules! book {
2828
($($name:ident, $path:expr, $book_name:expr, $lang:expr ;)+) => {

‎src/bootstrap/src/core/build_steps/llvm.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ use crate::core::builder::{
2121
Builder, CommandLineStep, Kind, RunConfig, ShouldRun, Step, StepMetadata,
2222
};
2323
use crate::core::config::{Config, LlvmCiMode, LlvmPgoGenerationMode, TargetSelection};
24+
use crate::core::session::{CLang, GitRepo};
25+
use crate::trace;
2426
use crate::utils::build_stamp::{BuildStamp, generate_smart_stamp_hash};
2527
use crate::utils::exec::command;
2628
use crate::utils::helpers::{
2729
self, exe, get_clang_cl_resource_dir, libdir, t, unhashed_basename, up_to_date,
2830
};
29-
use crate::{CLang, GitRepo, trace};
3031

3132
/// Path where a file containing the link type (dynamic or static) is stored in the LLVM CI tarball.
3233
pub const LLVM_CI_LINK_TYPE_PATH: &str = "link-type.txt";

‎src/bootstrap/src/core/build_steps/run.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ use std::path::PathBuf;
88
use build_helper::git::get_git_untracked_files;
99
use clap_complete::{Generator, shells};
1010

11-
use crate::Mode;
1211
use crate::core::build_steps::dist::distdir;
1312
use crate::core::build_steps::test;
1413
use crate::core::build_steps::tool::{self, RustcPrivateCompilers, SourceType, Tool};
1514
use crate::core::build_steps::vendor::{VENDOR_DIR, Vendor, default_paths_to_vendor};
1615
use crate::core::builder::{Builder, CommandLineStep, Kind, RunConfig, ShouldRun, StepMetadata};
1716
use crate::core::config::TargetSelection;
1817
use crate::core::config::flags::{get_completion, top_level_help};
18+
use crate::core::session::Mode;
1919
use crate::utils::exec::command;
2020
use crate::utils::helpers::{self, t};
2121

‎src/bootstrap/src/core/build_steps/test.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use crate::core::builder::{
3838
use crate::core::compiler::Compiler;
3939
use crate::core::config::TargetSelection;
4040
use crate::core::config::flags::{Subcommand, get_completion, top_level_help};
41+
use crate::core::session::{CLang, GitRepo, Mode};
4142
use crate::core::{android, debuggers};
4243
use crate::utils::build_stamp::{self, BuildStamp};
4344
use crate::utils::exec::{BootstrapCommand, command};
@@ -47,7 +48,6 @@ use crate::utils::helpers::{
4748
target_supports_cranelift_backend, up_to_date,
4849
};
4950
use crate::utils::render_tests::{add_flags_and_try_run_tests, try_run_tests};
50-
use crate::{CLang, GitRepo, Mode};
5151

5252
mod compiletest;
5353
pub mod failed_tests;

0 commit comments

Comments
 (0)