Skip to content

Commit 908d0a5

Browse files
Rollup merge of rust-lang#161123 - Zalathar:imports, r=jieyouxu
bootstrap: Clean up some inconsistent imports and paths I have been experimenting with moving code out of bootstrap's `lib.rs`, and along the way I noticed a few inconsistently-used imports and qualified paths that add friction to that process. There should be no change to bootstrap behaviour.
2 parents 6f0ad15 + 364e1ff commit 908d0a5

17 files changed

Lines changed: 42 additions & 39 deletions

File tree

src/bootstrap/src/cli_main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use std::time::Instant;
1414
use std::{env, process};
1515

1616
use crate::core::builder::StepStack;
17-
use crate::core::config::flags::Flags;
18-
use crate::core::config::{ChangeId, Config, Subcommand};
17+
use crate::core::config::flags::{Flags, Subcommand};
18+
use crate::core::config::{ChangeId, Config};
1919
use crate::utils::change_tracker::{
2020
CONFIG_CHANGE_HISTORY, find_recent_config_change_ids, human_readable_changes,
2121
};

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ use crate::core::builder::{
1616
self, Alias, Builder, Cargo, CommandLineStep, Kind, RunConfig, ShouldRun, Step, StepMetadata,
1717
crate_description,
1818
};
19-
use crate::core::config::{Subcommand, TargetSelection};
19+
use crate::core::config::TargetSelection;
20+
use crate::core::config::flags::Subcommand;
2021
use crate::utils::build_stamp::{self, BuildStamp};
2122
use crate::utils::helpers::t;
2223
use crate::{CodegenBackendKind, Compiler, Mode};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::path::Path;
1212
use crate::core::builder::{
1313
Builder, CommandLineStep, Kind, RunConfig, ShouldRun, crate_description,
1414
};
15-
use crate::core::config::Subcommand;
15+
use crate::core::config::flags::Subcommand;
1616
use crate::utils::build_stamp::BuildStamp;
1717
use crate::utils::helpers::t;
1818
use crate::{Build, Compiler, Mode};

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ use crate::core::build_steps::check::{CompilerForCheck, prepare_compiler_for_che
1818
use crate::core::build_steps::compile::{
1919
ArtifactKeepMode, run_cargo, rustc_cargo, std_cargo, std_crates_for_make_run,
2020
};
21-
use crate::core::builder;
2221
use crate::core::builder::{
23-
Alias, Builder, CommandLineStep, Kind, RunConfig, ShouldRun, StepMetadata, crate_description,
22+
self, Alias, Builder, CommandLineStep, Kind, RunConfig, ShouldRun, StepMetadata,
23+
crate_description,
2424
};
25-
use crate::core::config::{Subcommand, TargetSelection};
25+
use crate::core::config::TargetSelection;
26+
use crate::core::config::flags::Subcommand;
2627
use crate::utils::build_stamp::{self, BuildStamp};
2728
use crate::utils::helpers;
2829
use crate::{Compiler, Mode};

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ use crate::core::build_steps::tool::{
1616
self, RustcPrivateCompilers, SourceType, Tool, prepare_tool_cargo,
1717
};
1818
use crate::core::builder::{
19-
self, Builder, CommandLineStep, Compiler, Kind, RunConfig, ShouldRun, Step, StepMetadata,
19+
self, Builder, CommandLineStep, Kind, RunConfig, ShouldRun, Step, StepMetadata,
2020
crate_description,
2121
};
2222
use crate::core::config::{Config, TargetSelection};
2323
use crate::utils::helpers::{submodule_path_of, symlink_dir, t, up_to_date};
24-
use crate::{FileType, Mode};
24+
use crate::{Compiler, FileType, Mode};
2525

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

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ use crate::core::build_steps::tool::{
3131
use crate::core::build_steps::toolstate::ToolState;
3232
use crate::core::build_steps::{compile, dist, llvm};
3333
use crate::core::builder::{
34-
self, Alias, Builder, CommandLineStep, Compiler, Kind, RunConfig, ShouldRun, Step,
35-
StepMetadata, crate_description,
34+
self, Alias, Builder, CommandLineStep, Kind, RunConfig, ShouldRun, Step, StepMetadata,
35+
crate_description,
3636
};
3737
use crate::core::config::TargetSelection;
3838
use crate::core::config::flags::{Subcommand, get_completion, top_level_help};
@@ -45,7 +45,7 @@ use crate::utils::helpers::{
4545
up_to_date,
4646
};
4747
use crate::utils::render_tests::{add_flags_and_try_run_tests, try_run_tests};
48-
use crate::{CLang, CodegenBackendKind, GitRepo, Mode, TestTarget, envify};
48+
use crate::{CLang, CodegenBackendKind, Compiler, GitRepo, Mode, TestTarget, envify};
4949

5050
mod compiletest;
5151
pub mod failed_tests;

src/bootstrap/src/core/builder/cargo.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use crate::utils::build_stamp;
1212
use crate::utils::exec::{BootstrapCommand, command};
1313
use crate::utils::helpers::{self, LldThreads, check_cfg_arg, linker_flags, t};
1414
use crate::{
15-
CLang, Compiler, EXTRA_CHECK_CFGS, GitRepo, Mode, RemapScheme, prepare_behaviour_dump_dir,
15+
CLang, Compiler, EXTRA_CHECK_CFGS, GitRepo, Mode, RemapScheme, envify,
16+
prepare_behaviour_dump_dir,
1617
};
1718

1819
/// Represents flag values in `String` form with a `\x1f` delimiter to pass to the compiler later.
@@ -349,15 +350,15 @@ impl Cargo {
349350
// any fingerprint difference between host==target versus cross-compiled targets
350351
// when it comes to those host build artifacts.
351352
if let Some(host_linker) = builder.linker(compiler.host) {
352-
let host = crate::envify(&compiler.host.triple);
353+
let host = envify(&compiler.host.triple);
353354
self.command.env(format!("CARGO_TARGET_{host}_LINKER"), host_linker);
354355
}
355356
for arg in linker_flags(builder, compiler.host, LldThreads::Yes) {
356357
self.hostflags.arg(&arg);
357358
}
358359

359360
if let Some(target_linker) = builder.linker(target) {
360-
let target = crate::envify(&target.triple);
361+
let target = envify(&target.triple);
361362
self.command.env(format!("CARGO_TARGET_{target}_LINKER"), target_linker);
362363
}
363364
// We want to set -Clinker using Cargo, therefore we only call `linker_flags` and not

src/bootstrap/src/core/builder/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use clap::ValueEnum;
1414
use tracing::instrument;
1515

1616
pub use self::cargo::{Cargo, apply_pgo, cargo_profile_var};
17-
pub use crate::Compiler;
1817
use crate::core::build_steps::compile::{Std, StdLink, looks_like_codegen_backend};
1918
use crate::core::build_steps::tool::RustcPrivateCompilers;
2019
use crate::core::build_steps::{
@@ -29,7 +28,7 @@ use crate::utils::cache::Cache;
2928
use crate::utils::exec::{BootstrapCommand, ExecutionContext, command};
3029
use crate::utils::helpers::{self, LldThreads, add_dylib_path, exe, libdir, linker_args, t};
3130
use crate::utils::tracing::format_location;
32-
use crate::{Build, Crate, trace};
31+
use crate::{Build, Compiler, Crate, trace};
3332

3433
mod cargo;
3534
mod cli_paths;

src/bootstrap/src/core/config/config.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ use crate::CodegenBackendKind;
3232
use crate::core::build_steps::llvm;
3333
use crate::core::build_steps::llvm::LLVM_INVALIDATION_PATHS;
3434
use crate::core::build_steps::test::failed_tests::collect_previously_failed_tests;
35-
pub use crate::core::config::flags::Subcommand;
36-
use crate::core::config::flags::{Color, Flags, Warnings};
35+
use crate::core::config::flags::{Color, Flags, Subcommand, Warnings};
3736
use crate::core::config::macros::check_ci_llvm;
3837
use crate::core::config::target_selection::TargetSelectionList;
3938
use crate::core::config::toml::TomlConfig;

src/bootstrap/src/core/config/tests.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use super::toml::rust::parse_codegen_backends;
1414
use super::{Config, DebuggerPath, RUSTC_IF_UNCHANGED_ALLOWED_PATHS};
1515
use crate::core::build_steps::clippy::{LintConfig, get_clippy_rules_in_order};
1616
use crate::core::build_steps::llvm::LLVM_INVALIDATION_PATHS;
17+
use crate::core::config::flags::Subcommand;
1718
use crate::core::config::{
1819
BootstrapOverrideLld, ChangeId, CompilerBuiltins, Target, TargetSelection,
1920
};
@@ -287,7 +288,7 @@ fn order_of_clippy_rules() {
287288
let config = TestCtx::new().config(&args[0]).args(&args[1..]).create_config();
288289

289290
let actual = match config.cmd.clone() {
290-
crate::Subcommand::Clippy { allow, deny, warn, forbid, .. } => {
291+
Subcommand::Clippy { allow, deny, warn, forbid, .. } => {
291292
let cfg = LintConfig { allow, deny, warn, forbid };
292293
let args_vec: Vec<String> = args.iter().map(|s| s.to_string()).collect();
293294
get_clippy_rules_in_order(&args_vec, &cfg)
@@ -311,7 +312,7 @@ fn clippy_rule_separate_prefix() {
311312
let config = TestCtx::new().config(&args[0]).args(&args[1..]).create_config();
312313

313314
let actual = match config.cmd.clone() {
314-
crate::Subcommand::Clippy { allow, deny, warn, forbid, .. } => {
315+
Subcommand::Clippy { allow, deny, warn, forbid, .. } => {
315316
let cfg = LintConfig { allow, deny, warn, forbid };
316317
let args_vec: Vec<String> = args.iter().map(|s| s.to_string()).collect();
317318
get_clippy_rules_in_order(&args_vec, &cfg)

0 commit comments

Comments
 (0)