1
Fork 0

Auto merge of #134724 - onur-ozkan:type-improvements, r=jieyouxu

improve type mutation for certain structures

self-explanatory
This commit is contained in:
bors 2024-12-24 16:40:11 +00:00
commit d53b0ff6b5
4 changed files with 34 additions and 53 deletions

View file

@ -31,8 +31,13 @@ pub struct Std {
} }
impl Std { impl Std {
pub fn new_with_build_kind(target: TargetSelection, kind: Option<Kind>) -> Self { pub fn new(target: TargetSelection) -> Self {
Self { target, crates: vec![], override_build_kind: kind } Self { target, crates: vec![], override_build_kind: None }
}
pub fn build_kind(mut self, kind: Option<Kind>) -> Self {
self.override_build_kind = kind;
self
} }
} }
@ -167,20 +172,17 @@ pub struct Rustc {
impl Rustc { impl Rustc {
pub fn new(target: TargetSelection, builder: &Builder<'_>) -> Self { pub fn new(target: TargetSelection, builder: &Builder<'_>) -> Self {
Self::new_with_build_kind(target, builder, None)
}
pub fn new_with_build_kind(
target: TargetSelection,
builder: &Builder<'_>,
kind: Option<Kind>,
) -> Self {
let crates = builder let crates = builder
.in_tree_crates("rustc-main", Some(target)) .in_tree_crates("rustc-main", Some(target))
.into_iter() .into_iter()
.map(|krate| krate.name.to_string()) .map(|krate| krate.name.to_string())
.collect(); .collect();
Self { target, crates, override_build_kind: kind } Self { target, crates, override_build_kind: None }
}
pub fn build_kind(mut self, build_kind: Option<Kind>) -> Self {
self.override_build_kind = build_kind;
self
} }
} }
@ -216,7 +218,7 @@ impl Step for Rustc {
builder.ensure(crate::core::build_steps::compile::Std::new(compiler, compiler.host)); builder.ensure(crate::core::build_steps::compile::Std::new(compiler, compiler.host));
builder.ensure(crate::core::build_steps::compile::Std::new(compiler, target)); builder.ensure(crate::core::build_steps::compile::Std::new(compiler, target));
} else { } else {
builder.ensure(Std::new_with_build_kind(target, self.override_build_kind)); builder.ensure(Std::new(target).build_kind(self.override_build_kind));
} }
let mut cargo = builder::Cargo::new( let mut cargo = builder::Cargo::new(

View file

@ -215,7 +215,7 @@ impl Step for Rustc {
builder.ensure(compile::Std::new(compiler, compiler.host)); builder.ensure(compile::Std::new(compiler, compiler.host));
builder.ensure(compile::Std::new(compiler, target)); builder.ensure(compile::Std::new(compiler, target));
} else { } else {
builder.ensure(check::Std::new_with_build_kind(target, Some(Kind::Check))); builder.ensure(check::Std::new(target).build_kind(Some(Kind::Check)));
} }
let mut cargo = builder::Cargo::new( let mut cargo = builder::Cargo::new(
@ -285,7 +285,7 @@ macro_rules! lint_any {
let compiler = builder.compiler(builder.top_stage, builder.config.build); let compiler = builder.compiler(builder.top_stage, builder.config.build);
let target = self.target; let target = self.target;
builder.ensure(check::Rustc::new_with_build_kind(target, builder, Some(Kind::Check))); builder.ensure(check::Rustc::new(target, builder).build_kind(Some(Kind::Check)));
let cargo = prepare_tool_cargo( let cargo = prepare_tool_cargo(
builder, builder,

View file

@ -57,41 +57,20 @@ impl Std {
} }
} }
pub fn force_recompile(compiler: Compiler, target: TargetSelection) -> Self { pub fn force_recompile(mut self, force_recompile: bool) -> Self {
Self { self.force_recompile = force_recompile;
target, self
compiler,
crates: Default::default(),
force_recompile: true,
extra_rust_args: &[],
is_for_mir_opt_tests: false,
}
} }
pub fn new_for_mir_opt_tests(compiler: Compiler, target: TargetSelection) -> Self { #[allow(clippy::wrong_self_convention)]
Self { pub fn is_for_mir_opt_tests(mut self, is_for_mir_opt_tests: bool) -> Self {
target, self.is_for_mir_opt_tests = is_for_mir_opt_tests;
compiler, self
crates: Default::default(),
force_recompile: false,
extra_rust_args: &[],
is_for_mir_opt_tests: true,
}
} }
pub fn new_with_extra_rust_args( pub fn extra_rust_args(mut self, extra_rust_args: &'static [&'static str]) -> Self {
compiler: Compiler, self.extra_rust_args = extra_rust_args;
target: TargetSelection, self
extra_rust_args: &'static [&'static str],
) -> Self {
Self {
target,
compiler,
crates: Default::default(),
force_recompile: false,
extra_rust_args,
is_for_mir_opt_tests: false,
}
} }
fn copy_extra_objects( fn copy_extra_objects(

View file

@ -1718,7 +1718,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
// ensure that `libproc_macro` is available on the host. // ensure that `libproc_macro` is available on the host.
if suite == "mir-opt" { if suite == "mir-opt" {
builder.ensure(compile::Std::new_for_mir_opt_tests(compiler, compiler.host)); builder.ensure(compile::Std::new(compiler, compiler.host).is_for_mir_opt_tests(true));
} else { } else {
builder.ensure(compile::Std::new(compiler, compiler.host)); builder.ensure(compile::Std::new(compiler, compiler.host));
} }
@ -1731,7 +1731,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
let mut cmd = builder.tool_cmd(Tool::Compiletest); let mut cmd = builder.tool_cmd(Tool::Compiletest);
if suite == "mir-opt" { if suite == "mir-opt" {
builder.ensure(compile::Std::new_for_mir_opt_tests(compiler, target)); builder.ensure(compile::Std::new(compiler, target).is_for_mir_opt_tests(true));
} else { } else {
builder.ensure(compile::Std::new(compiler, target)); builder.ensure(compile::Std::new(compiler, target));
} }
@ -2737,7 +2737,7 @@ impl Step for Crate {
// Prepare sysroot // Prepare sysroot
// See [field@compile::Std::force_recompile]. // See [field@compile::Std::force_recompile].
builder.ensure(compile::Std::force_recompile(compiler, compiler.host)); builder.ensure(compile::Std::new(compiler, compiler.host).force_recompile(true));
// If we're not doing a full bootstrap but we're testing a stage2 // If we're not doing a full bootstrap but we're testing a stage2
// version of libstd, then what we're actually testing is the libstd // version of libstd, then what we're actually testing is the libstd
@ -2781,7 +2781,7 @@ impl Step for Crate {
} else { } else {
// Also prepare a sysroot for the target. // Also prepare a sysroot for the target.
if builder.config.build != target { if builder.config.build != target {
builder.ensure(compile::Std::force_recompile(compiler, target)); builder.ensure(compile::Std::new(compiler, target).force_recompile(true));
builder.ensure(RemoteCopyLibs { compiler, target }); builder.ensure(RemoteCopyLibs { compiler, target });
} }
@ -3557,10 +3557,10 @@ impl Step for CodegenGCC {
let compiler = self.compiler; let compiler = self.compiler;
let target = self.target; let target = self.target;
builder.ensure(compile::Std::new_with_extra_rust_args(compiler, target, &[ builder.ensure(
"-Csymbol-mangling-version=v0", compile::Std::new(compiler, target)
"-Cpanic=abort", .extra_rust_args(&["-Csymbol-mangling-version=v0", "-Cpanic=abort"]),
])); );
// If we're not doing a full bootstrap but we're testing a stage2 // If we're not doing a full bootstrap but we're testing a stage2
// version of libstd, then what we're actually testing is the libstd // version of libstd, then what we're actually testing is the libstd