Auto merge of #135202 - GuillaumeGomez:rollup-9xgs39t, r=GuillaumeGomez

Rollup of 9 pull requests

Successful merges:

 - #135081 (bootstrap: Build jemalloc with support for 64K pages)
 - #135174 ([AIX] Port test case run-make/reproducible-build )
 - #135177 (llvm: Ignore error value that is always false)
 - #135182 (Transmute from NonNull to pointer when elaborating a box deref (MCP807))
 - #135187 (apply a workaround fix for the release roadblock)
 - #135189 (Remove workaround from pull request template)
 - #135193 (don't bless `proc_macro_deps.rs` unless it's necessary)
 - #135198 (Avoid naming variables `str`)
 - #135199 (Eliminate an unnecessary `Symbol::to_string`; use `as_str`)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-01-07 15:22:00 +00:00
commit ad211ced81
32 changed files with 148 additions and 96 deletions

View File

@ -7,6 +7,6 @@ tracking issue or there are none, feel free to ignore this.
This PR will get automatically assigned to a reviewer. In case you would like This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using a specific user to review your work, you can assign it to them by using
r\? <reviewer name> (with the `\` removed) r? <reviewer name>
--> -->
<!-- homu-ignore:end --> <!-- homu-ignore:end -->

View File

@ -544,12 +544,12 @@ fn pretty_print_region_elements(elements: impl IntoIterator<Item = RegionElement
return result; return result;
fn push_location_range(str: &mut String, location1: Location, location2: Location) { fn push_location_range(s: &mut String, location1: Location, location2: Location) {
if location1 == location2 { if location1 == location2 {
str.push_str(&format!("{location1:?}")); s.push_str(&format!("{location1:?}"));
} else { } else {
assert_eq!(location1.block, location2.block); assert_eq!(location1.block, location2.block);
str.push_str(&format!( s.push_str(&format!(
"{:?}[{}..={}]", "{:?}[{}..={}]",
location1.block, location1.statement_index, location2.statement_index location1.block, location1.statement_index, location2.statement_index
)); ));

View File

@ -660,9 +660,7 @@ pub unsafe fn optimize_thin_module(
{ {
let _timer = let _timer =
cgcx.prof.generic_activity_with_arg("LLVM_thin_lto_rename", thin_module.name()); cgcx.prof.generic_activity_with_arg("LLVM_thin_lto_rename", thin_module.name());
if !llvm::LLVMRustPrepareThinLTORename(thin_module.shared.data.0, llmod, target) { unsafe { llvm::LLVMRustPrepareThinLTORename(thin_module.shared.data.0, llmod, target) };
return Err(write::llvm_err(&dcx, LlvmError::PrepareThinLtoModule));
}
save_temp_bitcode(cgcx, &module, "thin-lto-after-rename"); save_temp_bitcode(cgcx, &module, "thin-lto-after-rename");
} }

View File

@ -737,11 +737,7 @@ pub(crate) unsafe fn optimize_thin_module(
{ {
let _timer = let _timer =
cgcx.prof.generic_activity_with_arg("LLVM_thin_lto_rename", thin_module.name()); cgcx.prof.generic_activity_with_arg("LLVM_thin_lto_rename", thin_module.name());
if unsafe { unsafe { llvm::LLVMRustPrepareThinLTORename(thin_module.shared.data.0, llmod, target) };
!llvm::LLVMRustPrepareThinLTORename(thin_module.shared.data.0, llmod, target)
} {
return Err(write::llvm_err(dcx, LlvmError::PrepareThinLtoModule));
}
save_temp_bitcode(cgcx, &module, "thin-lto-after-rename"); save_temp_bitcode(cgcx, &module, "thin-lto-after-rename");
} }

View File

@ -2374,7 +2374,7 @@ unsafe extern "C" {
Data: &ThinLTOData, Data: &ThinLTOData,
Module: &Module, Module: &Module,
Target: &TargetMachine, Target: &TargetMachine,
) -> bool; );
pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool; pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool; pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
pub fn LLVMRustPrepareThinLTOImport( pub fn LLVMRustPrepareThinLTOImport(

View File

@ -704,8 +704,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
pub fn read_str(&self, mplace: &MPlaceTy<'tcx, M::Provenance>) -> InterpResult<'tcx, &str> { pub fn read_str(&self, mplace: &MPlaceTy<'tcx, M::Provenance>) -> InterpResult<'tcx, &str> {
let len = mplace.len(self)?; let len = mplace.len(self)?;
let bytes = self.read_bytes_ptr_strip_provenance(mplace.ptr(), Size::from_bytes(len))?; let bytes = self.read_bytes_ptr_strip_provenance(mplace.ptr(), Size::from_bytes(len))?;
let str = std::str::from_utf8(bytes).map_err(|err| err_ub!(InvalidStr(err)))?; let s = std::str::from_utf8(bytes).map_err(|err| err_ub!(InvalidStr(err)))?;
interp_ok(str) interp_ok(s)
} }
/// Read from a local of the current frame. Convenience method for [`InterpCx::local_at_frame_to_op`]. /// Read from a local of the current frame. Convenience method for [`InterpCx::local_at_frame_to_op`].

View File

@ -1017,9 +1017,9 @@ where
/// This is allocated in immutable global memory and deduplicated. /// This is allocated in immutable global memory and deduplicated.
pub fn allocate_str_dedup( pub fn allocate_str_dedup(
&mut self, &mut self,
str: &str, s: &str,
) -> InterpResult<'tcx, MPlaceTy<'tcx, M::Provenance>> { ) -> InterpResult<'tcx, MPlaceTy<'tcx, M::Provenance>> {
let bytes = str.as_bytes(); let bytes = s.as_bytes();
let ptr = self.allocate_bytes_dedup(bytes)?; let ptr = self.allocate_bytes_dedup(bytes)?;
// Create length metadata for the string. // Create length metadata for the string.

View File

@ -234,10 +234,10 @@ declare_lint! {
declare_lint_pass!(NonSnakeCase => [NON_SNAKE_CASE]); declare_lint_pass!(NonSnakeCase => [NON_SNAKE_CASE]);
impl NonSnakeCase { impl NonSnakeCase {
fn to_snake_case(mut str: &str) -> String { fn to_snake_case(mut name: &str) -> String {
let mut words = vec![]; let mut words = vec![];
// Preserve leading underscores // Preserve leading underscores
str = str.trim_start_matches(|c: char| { name = name.trim_start_matches(|c: char| {
if c == '_' { if c == '_' {
words.push(String::new()); words.push(String::new());
true true
@ -245,7 +245,7 @@ impl NonSnakeCase {
false false
} }
}); });
for s in str.split('_') { for s in name.split('_') {
let mut last_upper = false; let mut last_upper = false;
let mut buf = String::new(); let mut buf = String::new();
if s.is_empty() { if s.is_empty() {

View File

@ -1389,20 +1389,14 @@ static bool clearDSOLocalOnDeclarations(Module &Mod, TargetMachine &TM) {
return ClearDSOLocalOnDeclarations; return ClearDSOLocalOnDeclarations;
} }
extern "C" bool LLVMRustPrepareThinLTORename(const LLVMRustThinLTOData *Data, extern "C" void LLVMRustPrepareThinLTORename(const LLVMRustThinLTOData *Data,
LLVMModuleRef M, LLVMModuleRef M,
LLVMTargetMachineRef TM) { LLVMTargetMachineRef TM) {
Module &Mod = *unwrap(M); Module &Mod = *unwrap(M);
TargetMachine &Target = *unwrap(TM); TargetMachine &Target = *unwrap(TM);
bool ClearDSOLocal = clearDSOLocalOnDeclarations(Mod, Target); bool ClearDSOLocal = clearDSOLocalOnDeclarations(Mod, Target);
bool error = renameModuleForThinLTO(Mod, Data->Index, ClearDSOLocal); renameModuleForThinLTO(Mod, Data->Index, ClearDSOLocal);
if (error) {
LLVMRustSetLastError("renameModuleForThinLTO failed");
return false;
}
return true;
} }
extern "C" bool extern "C" bool

View File

@ -130,11 +130,11 @@ pub fn init_logger(cfg: LoggerConfig) -> Result<(), Error> {
let subscriber = tracing_subscriber::Registry::default().with(filter).with(layer); let subscriber = tracing_subscriber::Registry::default().with(filter).with(layer);
match cfg.backtrace { match cfg.backtrace {
Ok(str) => { Ok(backtrace_target) => {
let fmt_layer = tracing_subscriber::fmt::layer() let fmt_layer = tracing_subscriber::fmt::layer()
.with_writer(io::stderr) .with_writer(io::stderr)
.without_time() .without_time()
.event_format(BacktraceFormatter { backtrace_target: str }); .event_format(BacktraceFormatter { backtrace_target });
let subscriber = subscriber.with(fmt_layer); let subscriber = subscriber.with(fmt_layer);
tracing::subscriber::set_global_default(subscriber).unwrap(); tracing::subscriber::set_global_default(subscriber).unwrap();
} }

View File

@ -156,14 +156,14 @@ impl Entries {
Entries { map: HashMap::with_capacity(capacity) } Entries { map: HashMap::with_capacity(capacity) }
} }
fn insert(&mut self, span: Span, str: &str, errors: &mut Errors) -> u32 { fn insert(&mut self, span: Span, s: &str, errors: &mut Errors) -> u32 {
if let Some(prev) = self.map.get(str) { if let Some(prev) = self.map.get(s) {
errors.error(span, format!("Symbol `{str}` is duplicated")); errors.error(span, format!("Symbol `{s}` is duplicated"));
errors.error(prev.span_of_name, "location of previous definition".to_string()); errors.error(prev.span_of_name, "location of previous definition".to_string());
prev.idx prev.idx
} else { } else {
let idx = self.len(); let idx = self.len();
self.map.insert(str.to_string(), Preinterned { idx, span_of_name: span }); self.map.insert(s.to_string(), Preinterned { idx, span_of_name: span });
idx idx
} }
} }
@ -192,14 +192,14 @@ fn symbols_with_errors(input: TokenStream) -> (TokenStream, Vec<syn::Error>) {
let mut entries = Entries::with_capacity(input.keywords.len() + input.symbols.len() + 10); let mut entries = Entries::with_capacity(input.keywords.len() + input.symbols.len() + 10);
let mut prev_key: Option<(Span, String)> = None; let mut prev_key: Option<(Span, String)> = None;
let mut check_order = |span: Span, str: &str, errors: &mut Errors| { let mut check_order = |span: Span, s: &str, errors: &mut Errors| {
if let Some((prev_span, ref prev_str)) = prev_key { if let Some((prev_span, ref prev_str)) = prev_key {
if str < prev_str { if s < prev_str {
errors.error(span, format!("Symbol `{str}` must precede `{prev_str}`")); errors.error(span, format!("Symbol `{s}` must precede `{prev_str}`"));
errors.error(prev_span, format!("location of previous symbol `{prev_str}`")); errors.error(prev_span, format!("location of previous symbol `{prev_str}`"));
} }
} }
prev_key = Some((span, str.to_string())); prev_key = Some((span, s.to_string()));
}; };
// Generate the listed keywords. // Generate the listed keywords.

View File

@ -29,13 +29,8 @@ fn build_ptr_tys<'tcx>(
pub(super) fn build_projection<'tcx>( pub(super) fn build_projection<'tcx>(
unique_ty: Ty<'tcx>, unique_ty: Ty<'tcx>,
nonnull_ty: Ty<'tcx>, nonnull_ty: Ty<'tcx>,
ptr_ty: Ty<'tcx>, ) -> [PlaceElem<'tcx>; 2] {
) -> [PlaceElem<'tcx>; 3] { [PlaceElem::Field(FieldIdx::ZERO, unique_ty), PlaceElem::Field(FieldIdx::ZERO, nonnull_ty)]
[
PlaceElem::Field(FieldIdx::ZERO, unique_ty),
PlaceElem::Field(FieldIdx::ZERO, nonnull_ty),
PlaceElem::Field(FieldIdx::ZERO, ptr_ty),
]
} }
struct ElaborateBoxDerefVisitor<'a, 'tcx> { struct ElaborateBoxDerefVisitor<'a, 'tcx> {
@ -75,10 +70,14 @@ impl<'a, 'tcx> MutVisitor<'tcx> for ElaborateBoxDerefVisitor<'a, 'tcx> {
self.patch.add_assign( self.patch.add_assign(
location, location,
Place::from(ptr_local), Place::from(ptr_local),
Rvalue::Use(Operand::Copy( Rvalue::Cast(
Place::from(place.local) CastKind::Transmute,
.project_deeper(&build_projection(unique_ty, nonnull_ty, ptr_ty), tcx), Operand::Copy(
)), Place::from(place.local)
.project_deeper(&build_projection(unique_ty, nonnull_ty), tcx),
),
ptr_ty,
),
); );
place.local = ptr_local; place.local = ptr_local;
@ -133,8 +132,10 @@ impl<'tcx> crate::MirPass<'tcx> for ElaborateBoxDerefs {
let (unique_ty, nonnull_ty, ptr_ty) = let (unique_ty, nonnull_ty, ptr_ty) =
build_ptr_tys(tcx, boxed_ty, unique_did, nonnull_did); build_ptr_tys(tcx, boxed_ty, unique_did, nonnull_did);
new_projections new_projections.extend_from_slice(&build_projection(unique_ty, nonnull_ty));
.extend_from_slice(&build_projection(unique_ty, nonnull_ty, ptr_ty)); // While we can't project into `NonNull<_>` in a basic block
// due to MCP#807, this is debug info where it's fine.
new_projections.push(PlaceElem::Field(FieldIdx::ZERO, ptr_ty));
new_projections.push(PlaceElem::Deref); new_projections.push(PlaceElem::Deref);
} else if let Some(new_projections) = new_projections.as_mut() { } else if let Some(new_projections) = new_projections.as_mut() {
// Keep building up our projections list once we've started it. // Keep building up our projections list once we've started it.

View File

@ -448,10 +448,9 @@ pub(crate) fn encode_ty<'tcx>(
if let Some(cfi_encoding) = tcx.get_attr(def_id, sym::cfi_encoding) { if let Some(cfi_encoding) = tcx.get_attr(def_id, sym::cfi_encoding) {
// Use user-defined CFI encoding for type // Use user-defined CFI encoding for type
if let Some(value_str) = cfi_encoding.value_str() { if let Some(value_str) = cfi_encoding.value_str() {
let value_str = value_str.to_string(); let value_str = value_str.as_str().trim();
let str = value_str.trim(); if !value_str.is_empty() {
if !str.is_empty() { s.push_str(value_str);
s.push_str(str);
// Don't compress user-defined builtin types (see // Don't compress user-defined builtin types (see
// https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-builtin and // https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-builtin and
// https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-compression). // https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-compression).
@ -459,7 +458,7 @@ pub(crate) fn encode_ty<'tcx>(
"v", "w", "b", "c", "a", "h", "s", "t", "i", "j", "l", "m", "x", "y", "v", "w", "b", "c", "a", "h", "s", "t", "i", "j", "l", "m", "x", "y",
"n", "o", "f", "d", "e", "g", "z", "Dh", "n", "o", "f", "d", "e", "g", "z", "Dh",
]; ];
if !builtin_types.contains(&str) { if !builtin_types.contains(&value_str) {
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s); compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
} }
} else { } else {

View File

@ -1283,13 +1283,13 @@ impl fmt::Debug for Output {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
let stdout_utf8 = str::from_utf8(&self.stdout); let stdout_utf8 = str::from_utf8(&self.stdout);
let stdout_debug: &dyn fmt::Debug = match stdout_utf8 { let stdout_debug: &dyn fmt::Debug = match stdout_utf8 {
Ok(ref str) => str, Ok(ref s) => s,
Err(_) => &self.stdout, Err(_) => &self.stdout,
}; };
let stderr_utf8 = str::from_utf8(&self.stderr); let stderr_utf8 = str::from_utf8(&self.stderr);
let stderr_debug: &dyn fmt::Debug = match stderr_utf8 { let stderr_debug: &dyn fmt::Debug = match stderr_utf8 {
Ok(ref str) => str, Ok(ref s) => s,
Err(_) => &self.stderr, Err(_) => &self.stderr,
}; };

View File

@ -142,11 +142,11 @@ impl AsRef<OsStr> for EnvKey {
} }
} }
pub(crate) fn ensure_no_nuls<T: AsRef<OsStr>>(str: T) -> io::Result<T> { pub(crate) fn ensure_no_nuls<T: AsRef<OsStr>>(s: T) -> io::Result<T> {
if str.as_ref().encode_wide().any(|b| b == 0) { if s.as_ref().encode_wide().any(|b| b == 0) {
Err(io::const_error!(ErrorKind::InvalidInput, "nul byte found in provided data")) Err(io::const_error!(ErrorKind::InvalidInput, "nul byte found in provided data"))
} else { } else {
Ok(str) Ok(s)
} }
} }

View File

@ -204,8 +204,8 @@ impl Wtf8Buf {
/// ///
/// Since WTF-8 is a superset of UTF-8, this always succeeds. /// Since WTF-8 is a superset of UTF-8, this always succeeds.
#[inline] #[inline]
pub fn from_str(str: &str) -> Wtf8Buf { pub fn from_str(s: &str) -> Wtf8Buf {
Wtf8Buf { bytes: <[_]>::to_vec(str.as_bytes()), is_known_utf8: true } Wtf8Buf { bytes: <[_]>::to_vec(s.as_bytes()), is_known_utf8: true }
} }
pub fn clear(&mut self) { pub fn clear(&mut self) {

View File

@ -1207,6 +1207,15 @@ pub fn rustc_cargo_env(
rustc_llvm_env(builder, cargo, target) rustc_llvm_env(builder, cargo, target)
} }
} }
// Build jemalloc on AArch64 with support for page sizes up to 64K
// See: https://github.com/rust-lang/rust/pull/135081
if builder.config.jemalloc
&& target.starts_with("aarch64")
&& env::var_os("JEMALLOC_SYS_WITH_LG_PAGE").is_none()
{
cargo.env("JEMALLOC_SYS_WITH_LG_PAGE", "16");
}
} }
/// Pass down configuration from the LLVM build into the build of /// Pass down configuration from the LLVM build into the build of

View File

@ -129,8 +129,19 @@ pub fn get_closest_merge_commit(
git.current_dir(git_dir); git.current_dir(git_dir);
} }
let channel = include_str!("../../ci/channel");
let merge_base = { let merge_base = {
if CiEnv::is_ci() { if CiEnv::is_ci() &&
// FIXME: When running on rust-lang managed CI and it's not a nightly build,
// `git_upstream_merge_base` fails with an error message similar to this:
// ```
// called `Result::unwrap()` on an `Err` value: "command did not execute successfully:
// cd \"/checkout\" && \"git\" \"merge-base\" \"origin/master\" \"HEAD\"\nexpected success, got: exit status: 1\n"
// ```
// Investigate and resolve this issue instead of skipping it like this.
(channel == "nightly" || !CiEnv::is_rust_lang_managed_ci_job())
{
git_upstream_merge_base(config, git_dir).unwrap() git_upstream_merge_base(config, git_dir).unwrap()
} else { } else {
// For non-CI environments, ignore rust-lang/rust upstream as it usually gets // For non-CI environments, ignore rust-lang/rust upstream as it usually gets

View File

@ -31,7 +31,7 @@ pub fn make_diff(expected: &str, actual: &str, context_size: usize) -> Vec<Misma
for result in diff::lines(expected, actual) { for result in diff::lines(expected, actual) {
match result { match result {
diff::Result::Left(str) => { diff::Result::Left(s) => {
if lines_since_mismatch >= context_size && lines_since_mismatch > 0 { if lines_since_mismatch >= context_size && lines_since_mismatch > 0 {
results.push(mismatch); results.push(mismatch);
mismatch = Mismatch::new(line_number - context_queue.len() as u32); mismatch = Mismatch::new(line_number - context_queue.len() as u32);
@ -41,11 +41,11 @@ pub fn make_diff(expected: &str, actual: &str, context_size: usize) -> Vec<Misma
mismatch.lines.push(DiffLine::Context(line.to_owned())); mismatch.lines.push(DiffLine::Context(line.to_owned()));
} }
mismatch.lines.push(DiffLine::Expected(str.to_owned())); mismatch.lines.push(DiffLine::Expected(s.to_owned()));
line_number += 1; line_number += 1;
lines_since_mismatch = 0; lines_since_mismatch = 0;
} }
diff::Result::Right(str) => { diff::Result::Right(s) => {
if lines_since_mismatch >= context_size && lines_since_mismatch > 0 { if lines_since_mismatch >= context_size && lines_since_mismatch > 0 {
results.push(mismatch); results.push(mismatch);
mismatch = Mismatch::new(line_number - context_queue.len() as u32); mismatch = Mismatch::new(line_number - context_queue.len() as u32);
@ -55,18 +55,18 @@ pub fn make_diff(expected: &str, actual: &str, context_size: usize) -> Vec<Misma
mismatch.lines.push(DiffLine::Context(line.to_owned())); mismatch.lines.push(DiffLine::Context(line.to_owned()));
} }
mismatch.lines.push(DiffLine::Resulting(str.to_owned())); mismatch.lines.push(DiffLine::Resulting(s.to_owned()));
lines_since_mismatch = 0; lines_since_mismatch = 0;
} }
diff::Result::Both(str, _) => { diff::Result::Both(s, _) => {
if context_queue.len() >= context_size { if context_queue.len() >= context_size {
let _ = context_queue.pop_front(); let _ = context_queue.pop_front();
} }
if lines_since_mismatch < context_size { if lines_since_mismatch < context_size {
mismatch.lines.push(DiffLine::Context(str.to_owned())); mismatch.lines.push(DiffLine::Context(s.to_owned()));
} else if context_size > 0 { } else if context_size > 0 {
context_queue.push_back(str); context_queue.push_back(s);
} }
line_number += 1; line_number += 1;

View File

@ -619,12 +619,17 @@ fn check_proc_macro_dep_list(root: &Path, cargo: &Path, bless: bool, bad: &mut b
} }
// Remove the proc-macro crates themselves // Remove the proc-macro crates themselves
proc_macro_deps.retain(|pkg| !is_proc_macro_pkg(&metadata[pkg])); proc_macro_deps.retain(|pkg| !is_proc_macro_pkg(&metadata[pkg]));
let proc_macro_deps_iter = proc_macro_deps.into_iter().map(|dep| metadata[dep].name.clone());
if bless { let proc_macro_deps: HashSet<_> =
let mut proc_macro_deps: Vec<_> = proc_macro_deps_iter.collect(); proc_macro_deps.into_iter().map(|dep| metadata[dep].name.clone()).collect();
let expected = proc_macro_deps::CRATES.iter().map(|s| s.to_string()).collect::<HashSet<_>>();
let needs_blessing = proc_macro_deps.difference(&expected).next().is_some()
|| expected.difference(&proc_macro_deps).next().is_some();
if needs_blessing && bless {
let mut proc_macro_deps: Vec<_> = proc_macro_deps.into_iter().collect();
proc_macro_deps.sort(); proc_macro_deps.sort();
proc_macro_deps.dedup();
let mut file = File::create(root.join("src/bootstrap/src/utils/proc_macro_deps.rs")) let mut file = File::create(root.join("src/bootstrap/src/utils/proc_macro_deps.rs"))
.expect("`proc_macro_deps` should exist"); .expect("`proc_macro_deps` should exist");
writeln!( writeln!(
@ -646,10 +651,8 @@ pub static CRATES: &[&str] = &[
) )
.unwrap(); .unwrap();
} else { } else {
let proc_macro_deps: HashSet<_> = proc_macro_deps_iter.collect();
let expected =
proc_macro_deps::CRATES.iter().map(|s| s.to_string()).collect::<HashSet<_>>();
let old_bad = *bad; let old_bad = *bad;
for missing in proc_macro_deps.difference(&expected) { for missing in proc_macro_deps.difference(&expected) {
tidy_error!( tidy_error!(
bad, bad,

View File

@ -7,7 +7,7 @@
fn main() { fn main() {
// CHECK-LABEL: fn main( // CHECK-LABEL: fn main(
// CHECK: [[box:_.*]] = ShallowInitBox( // CHECK: [[box:_.*]] = ShallowInitBox(
// CHECK: [[ptr:_.*]] = copy ((([[box]].0: std::ptr::Unique<S>).0: std::ptr::NonNull<S>).0: *const S); // CHECK: [[ptr:_.*]] = copy (([[box]].0: std::ptr::Unique<S>).0: std::ptr::NonNull<S>) as *const S (Transmute);
// CHECK: (*[[ptr]]) = S::new() -> [return: [[ret:bb.*]], unwind: [[unwind:bb.*]]]; // CHECK: (*[[ptr]]) = S::new() -> [return: [[ret:bb.*]], unwind: [[unwind:bb.*]]];
// CHECK: [[ret]]: { // CHECK: [[ret]]: {
// CHECK: [[box2:_.*]] = move [[box]]; // CHECK: [[box2:_.*]] = move [[box]];

View File

@ -32,11 +32,11 @@
bb1: { bb1: {
StorageLive(_7); StorageLive(_7);
_7 = ShallowInitBox(move _6, i32); _7 = ShallowInitBox(move _6, i32);
_8 = copy (((_7.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); _8 = copy ((_7.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>) as *const i32 (Transmute);
(*_8) = const 42_i32; (*_8) = const 42_i32;
_3 = move _7; _3 = move _7;
StorageDead(_7); StorageDead(_7);
_9 = copy (((_3.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); _9 = copy ((_3.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>) as *const i32 (Transmute);
_2 = copy (*_9); _2 = copy (*_9);
- _1 = Add(move _2, const 0_i32); - _1 = Add(move _2, const 0_i32);
- StorageDead(_2); - StorageDead(_2);

View File

@ -32,11 +32,11 @@
bb1: { bb1: {
StorageLive(_7); StorageLive(_7);
_7 = ShallowInitBox(move _6, i32); _7 = ShallowInitBox(move _6, i32);
_8 = copy (((_7.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); _8 = copy ((_7.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>) as *const i32 (Transmute);
(*_8) = const 42_i32; (*_8) = const 42_i32;
_3 = move _7; _3 = move _7;
StorageDead(_7); StorageDead(_7);
_9 = copy (((_3.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); _9 = copy ((_3.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>) as *const i32 (Transmute);
_2 = copy (*_9); _2 = copy (*_9);
- _1 = Add(move _2, const 0_i32); - _1 = Add(move _2, const 0_i32);
- StorageDead(_2); - StorageDead(_2);

View File

@ -12,9 +12,9 @@
bb0: { bb0: {
StorageLive(_1); StorageLive(_1);
- _1 = const 1_usize as std::boxed::Box<Never> (Transmute); - _1 = const 1_usize as std::boxed::Box<Never> (Transmute);
- _2 = copy (((_1.0: std::ptr::Unique<Never>).0: std::ptr::NonNull<Never>).0: *const Never); - _2 = copy ((_1.0: std::ptr::Unique<Never>).0: std::ptr::NonNull<Never>) as *const Never (Transmute);
+ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global); + _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global);
+ _2 = const {0x1 as *const Never}; + _2 = const std::ptr::NonNull::<Never> {{ pointer: {0x1 as *const Never} }} as *const Never (Transmute);
unreachable; unreachable;
} }
} }

View File

@ -12,9 +12,9 @@
bb0: { bb0: {
StorageLive(_1); StorageLive(_1);
- _1 = const 1_usize as std::boxed::Box<Never> (Transmute); - _1 = const 1_usize as std::boxed::Box<Never> (Transmute);
- _2 = copy (((_1.0: std::ptr::Unique<Never>).0: std::ptr::NonNull<Never>).0: *const Never); - _2 = copy ((_1.0: std::ptr::Unique<Never>).0: std::ptr::NonNull<Never>) as *const Never (Transmute);
+ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global); + _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global);
+ _2 = const {0x1 as *const Never}; + _2 = const std::ptr::NonNull::<Never> {{ pointer: {0x1 as *const Never} }} as *const Never (Transmute);
unreachable; unreachable;
} }
} }

View File

@ -13,7 +13,7 @@
StorageLive(_1); StorageLive(_1);
- _1 = const 1_usize as std::boxed::Box<Never> (Transmute); - _1 = const 1_usize as std::boxed::Box<Never> (Transmute);
+ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global); + _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global);
_2 = copy (((_1.0: std::ptr::Unique<Never>).0: std::ptr::NonNull<Never>).0: *const Never); _2 = copy ((_1.0: std::ptr::Unique<Never>).0: std::ptr::NonNull<Never>) as *const Never (Transmute);
unreachable; unreachable;
} }
} }

View File

@ -13,7 +13,7 @@
StorageLive(_1); StorageLive(_1);
- _1 = const 1_usize as std::boxed::Box<Never> (Transmute); - _1 = const 1_usize as std::boxed::Box<Never> (Transmute);
+ _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global); + _1 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global);
_2 = copy (((_1.0: std::ptr::Unique<Never>).0: std::ptr::NonNull<Never>).0: *const Never); _2 = copy ((_1.0: std::ptr::Unique<Never>).0: std::ptr::NonNull<Never>) as *const Never (Transmute);
unreachable; unreachable;
} }
} }

View File

@ -17,7 +17,7 @@
} }
bb1: { bb1: {
_2 = copy (((_1.0: std::ptr::Unique<Never>).0: std::ptr::NonNull<Never>).0: *const Never); _2 = copy ((_1.0: std::ptr::Unique<Never>).0: std::ptr::NonNull<Never>) as *const Never (Transmute);
PlaceMention((*_2)); PlaceMention((*_2));
unreachable; unreachable;
} }

View File

@ -17,7 +17,7 @@
} }
bb1: { bb1: {
_2 = copy (((_1.0: std::ptr::Unique<Never>).0: std::ptr::NonNull<Never>).0: *const Never); _2 = copy ((_1.0: std::ptr::Unique<Never>).0: std::ptr::NonNull<Never>) as *const Never (Transmute);
PlaceMention((*_2)); PlaceMention((*_2));
unreachable; unreachable;
} }

View File

@ -9,7 +9,7 @@ fn box_to_raw_mut(_1: &mut Box<i32>) -> *mut i32 {
bb0: { bb0: {
Retag([fn entry] _1); Retag([fn entry] _1);
_2 = deref_copy (*_1); _2 = deref_copy (*_1);
_3 = copy (((_2.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); _3 = copy ((_2.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>) as *const i32 (Transmute);
_0 = &raw mut (*_3); _0 = &raw mut (*_3);
Retag([raw] _0); Retag([raw] _0);
return; return;

View File

@ -9,7 +9,7 @@ fn box_to_raw_mut(_1: &mut Box<i32>) -> *mut i32 {
bb0: { bb0: {
Retag([fn entry] _1); Retag([fn entry] _1);
_2 = deref_copy (*_1); _2 = deref_copy (*_1);
_3 = copy (((_2.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32); _3 = copy ((_2.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>) as *const i32 (Transmute);
_0 = &raw mut (*_3); _0 = &raw mut (*_3);
Retag([raw] _0); Retag([raw] _0);
return; return;

View File

@ -21,7 +21,7 @@
// Tracking Issue: https://github.com/rust-lang/rust/issues/129080 // Tracking Issue: https://github.com/rust-lang/rust/issues/129080
use run_make_support::{ use run_make_support::{
bin_name, cwd, diff, is_darwin, is_windows, rfs, run_in_tmpdir, rust_lib_name, rustc, bin_name, cwd, diff, is_darwin, is_windows, regex, rfs, run_in_tmpdir, rust_lib_name, rustc,
}; };
fn main() { fn main() {
@ -117,7 +117,34 @@ fn smoke_test(flag: Option<SmokeFlag>) {
.input("reproducible-build.rs") .input("reproducible-build.rs")
.linker(&cwd().join(bin_name("linker")).display().to_string()) .linker(&cwd().join(bin_name("linker")).display().to_string())
.run(); .run();
diff().actual_file("linker-arguments1").expected_file("linker-arguments2").run();
#[cfg(not(target_os = "aix"))]
{
diff().actual_file("linker-arguments1").expected_file("linker-arguments2").run();
}
#[cfg(target_os = "aix")]
{
// The AIX link command includes an additional argument
// that specifies the file containing exported symbols, e.g.,
// -bE:/tmp/rustcO6hxkY/list.exp. In this example, the part of the
// directory name "rustcO6hxkY" is randomly generated to ensure that
// different linking processes do not collide. For the purpose
// of comparing link arguments, the randomly generated part is
// replaced with a placeholder.
let content1 =
std::fs::read_to_string("linker-arguments1").expect("Failed to read file");
let content2 =
std::fs::read_to_string("linker-arguments2").expect("Failed to read file");
// Define the regex for the directory name containing the random substring.
let re = regex::Regex::new(r"rustc[a-zA-Z0-9]{6}/list\.exp").expect("Invalid regex");
// Compare link commands with random strings replaced by placeholders.
assert!(
re.replace_all(&content1, "rustcXXXXXX/list.exp").to_string()
== re.replace_all(&content2, "rustcXXXXXX/list.exp").to_string()
);
}
}); });
} }
@ -207,7 +234,21 @@ fn diff_dir_test(crate_type: CrateType, remap_type: RemapType) {
std::env::set_current_dir(&base_dir).unwrap(); std::env::set_current_dir(&base_dir).unwrap();
match crate_type { match crate_type {
CrateType::Bin => { CrateType::Bin => {
assert!(rfs::read(bin_name("reproducible-build")) == rfs::read(bin_name("foo"))); #[cfg(not(target_os = "aix"))]
{
assert!(
rfs::read(bin_name("reproducible-build")) == rfs::read(bin_name("foo"))
);
}
#[cfg(target_os = "aix")]
{
// At the 4th-byte offset, the AIX XCOFF file header defines a
// 4-byte timestamp. Nullify the timestamp before performing a
// binary comparison.
let mut file1 = rfs::read(bin_name("reproducible-build"));
let mut file2 = rfs::read(bin_name("foo"));
assert!(file1[4..8].fill(0x00) == file2[4..8].fill(0x00));
};
} }
CrateType::Rlib => { CrateType::Rlib => {
assert!( assert!(