Skip to content

Rollup of 9 pull requests #135202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
7f31b57
Replace the random substring of a linker argument with a placeholder …
xingxue-ibm Jan 6, 2025
fc32dd4
llvm: Ignore error value that is always false
maurer Jan 7, 2025
ad5f912
Transmute from NonNull to pointer when elaborating a box deref (MCP807)
scottmcm Nov 15, 2024
53a5857
bootstrap: Build jemalloc for AArch64 with support for 64K pages
mrkajetanp Jan 3, 2025
614dc1c
apply a workaround fix for the release blocker issue
onur-ozkan Jan 7, 2025
7012328
Remove workaround from pull request template
Urgau Jan 7, 2025
b0324cc
don't bless `proc_macro_deps.rs` unless it's necessary
onur-ozkan Jan 7, 2025
7cc99a8
Eliminate an unnecessary `Symbol::to_string`; use `as_str`
joshtriplett Jan 7, 2025
bb6bbfa
Avoid naming variables `str`
joshtriplett Jan 7, 2025
2b97db2
Rollup merge of #135081 - mrkajetanp:jemalloc-64k, r=Kobzol
GuillaumeGomez Jan 7, 2025
2338e57
Rollup merge of #135174 - xingxue-ibm:reproducible-build-aix, r=jieyouxu
GuillaumeGomez Jan 7, 2025
020d875
Rollup merge of #135177 - maurer:rename-module, r=nikic
GuillaumeGomez Jan 7, 2025
a33da79
Rollup merge of #135182 - scottmcm:box-deref-via-transmute, r=oli-obk
GuillaumeGomez Jan 7, 2025
2598d60
Rollup merge of #135187 - onur-ozkan:release-fix, r=pietroalbini
GuillaumeGomez Jan 7, 2025
ebf2e51
Rollup merge of #135189 - Urgau:triagebot-html-ignored, r=lqd
GuillaumeGomez Jan 7, 2025
ccaa0f3
Rollup merge of #135193 - onur-ozkan:tidy-cache-invalidation, r=jieyouxu
GuillaumeGomez Jan 7, 2025
ec26620
Rollup merge of #135198 - joshtriplett:str-is-a-type, r=jieyouxu
GuillaumeGomez Jan 7, 2025
225ffeb
Rollup merge of #135199 - joshtriplett:unnecessary-to-string, r=lqd
GuillaumeGomez Jan 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 -->
6 changes: 3 additions & 3 deletions compiler/rustc_borrowck/src/region_infer/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,12 +544,12 @@ fn pretty_print_region_elements(elements: impl IntoIterator<Item = RegionElement

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 {
str.push_str(&format!("{location1:?}"));
s.push_str(&format!("{location1:?}"));
} else {
assert_eq!(location1.block, location2.block);
str.push_str(&format!(
s.push_str(&format!(
"{:?}[{}..={}]",
location1.block, location1.statement_index, location2.statement_index
));
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_codegen_gcc/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,9 +660,7 @@ pub unsafe fn optimize_thin_module(
{
let _timer =
cgcx.prof.generic_activity_with_arg("LLVM_thin_lto_rename", thin_module.name());
if !llvm::LLVMRustPrepareThinLTORename(thin_module.shared.data.0, llmod, target) {
return Err(write::llvm_err(&dcx, LlvmError::PrepareThinLtoModule));
}
unsafe { llvm::LLVMRustPrepareThinLTORename(thin_module.shared.data.0, llmod, target) };
save_temp_bitcode(cgcx, &module, "thin-lto-after-rename");
}

Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_codegen_llvm/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,11 +737,7 @@ pub(crate) unsafe fn optimize_thin_module(
{
let _timer =
cgcx.prof.generic_activity_with_arg("LLVM_thin_lto_rename", thin_module.name());
if unsafe {
!llvm::LLVMRustPrepareThinLTORename(thin_module.shared.data.0, llmod, target)
} {
return Err(write::llvm_err(dcx, LlvmError::PrepareThinLtoModule));
}
unsafe { llvm::LLVMRustPrepareThinLTORename(thin_module.shared.data.0, llmod, target) };
save_temp_bitcode(cgcx, &module, "thin-lto-after-rename");
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2374,7 +2374,7 @@ unsafe extern "C" {
Data: &ThinLTOData,
Module: &Module,
Target: &TargetMachine,
) -> bool;
);
pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
pub fn LLVMRustPrepareThinLTOImport(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/interpret/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
let len = mplace.len(self)?;
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)))?;
interp_ok(str)
let s = std::str::from_utf8(bytes).map_err(|err| err_ub!(InvalidStr(err)))?;
interp_ok(s)
}

/// Read from a local of the current frame. Convenience method for [`InterpCx::local_at_frame_to_op`].
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1017,9 +1017,9 @@ where
/// This is allocated in immutable global memory and deduplicated.
pub fn allocate_str_dedup(
&mut self,
str: &str,
s: &str,
) -> InterpResult<'tcx, MPlaceTy<'tcx, M::Provenance>> {
let bytes = str.as_bytes();
let bytes = s.as_bytes();
let ptr = self.allocate_bytes_dedup(bytes)?;

// Create length metadata for the string.
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_lint/src/nonstandard_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,18 +234,18 @@ declare_lint! {
declare_lint_pass!(NonSnakeCase => [NON_SNAKE_CASE]);

impl NonSnakeCase {
fn to_snake_case(mut str: &str) -> String {
fn to_snake_case(mut name: &str) -> String {
let mut words = vec![];
// Preserve leading underscores
str = str.trim_start_matches(|c: char| {
name = name.trim_start_matches(|c: char| {
if c == '_' {
words.push(String::new());
true
} else {
false
}
});
for s in str.split('_') {
for s in name.split('_') {
let mut last_upper = false;
let mut buf = String::new();
if s.is_empty() {
Expand Down
10 changes: 2 additions & 8 deletions compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1389,20 +1389,14 @@ static bool clearDSOLocalOnDeclarations(Module &Mod, TargetMachine &TM) {
return ClearDSOLocalOnDeclarations;
}

extern "C" bool LLVMRustPrepareThinLTORename(const LLVMRustThinLTOData *Data,
extern "C" void LLVMRustPrepareThinLTORename(const LLVMRustThinLTOData *Data,
LLVMModuleRef M,
LLVMTargetMachineRef TM) {
Module &Mod = *unwrap(M);
TargetMachine &Target = *unwrap(TM);

bool ClearDSOLocal = clearDSOLocalOnDeclarations(Mod, Target);
bool error = renameModuleForThinLTO(Mod, Data->Index, ClearDSOLocal);

if (error) {
LLVMRustSetLastError("renameModuleForThinLTO failed");
return false;
}
return true;
renameModuleForThinLTO(Mod, Data->Index, ClearDSOLocal);
}

extern "C" bool
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ pub fn init_logger(cfg: LoggerConfig) -> Result<(), Error> {

let subscriber = tracing_subscriber::Registry::default().with(filter).with(layer);
match cfg.backtrace {
Ok(str) => {
Ok(backtrace_target) => {
let fmt_layer = tracing_subscriber::fmt::layer()
.with_writer(io::stderr)
.without_time()
.event_format(BacktraceFormatter { backtrace_target: str });
.event_format(BacktraceFormatter { backtrace_target });
let subscriber = subscriber.with(fmt_layer);
tracing::subscriber::set_global_default(subscriber).unwrap();
}
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_macros/src/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ impl Entries {
Entries { map: HashMap::with_capacity(capacity) }
}

fn insert(&mut self, span: Span, str: &str, errors: &mut Errors) -> u32 {
if let Some(prev) = self.map.get(str) {
errors.error(span, format!("Symbol `{str}` is duplicated"));
fn insert(&mut self, span: Span, s: &str, errors: &mut Errors) -> u32 {
if let Some(prev) = self.map.get(s) {
errors.error(span, format!("Symbol `{s}` is duplicated"));
errors.error(prev.span_of_name, "location of previous definition".to_string());
prev.idx
} else {
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
}
}
Expand Down Expand Up @@ -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 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 str < prev_str {
errors.error(span, format!("Symbol `{str}` must precede `{prev_str}`"));
if s < prev_str {
errors.error(span, format!("Symbol `{s}` must precede `{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.
Expand Down
27 changes: 14 additions & 13 deletions compiler/rustc_mir_transform/src/elaborate_box_derefs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,8 @@ fn build_ptr_tys<'tcx>(
pub(super) fn build_projection<'tcx>(
unique_ty: Ty<'tcx>,
nonnull_ty: Ty<'tcx>,
ptr_ty: Ty<'tcx>,
) -> [PlaceElem<'tcx>; 3] {
[
PlaceElem::Field(FieldIdx::ZERO, unique_ty),
PlaceElem::Field(FieldIdx::ZERO, nonnull_ty),
PlaceElem::Field(FieldIdx::ZERO, ptr_ty),
]
) -> [PlaceElem<'tcx>; 2] {
[PlaceElem::Field(FieldIdx::ZERO, unique_ty), PlaceElem::Field(FieldIdx::ZERO, nonnull_ty)]
}

struct ElaborateBoxDerefVisitor<'a, 'tcx> {
Expand Down Expand Up @@ -75,10 +70,14 @@ impl<'a, 'tcx> MutVisitor<'tcx> for ElaborateBoxDerefVisitor<'a, 'tcx> {
self.patch.add_assign(
location,
Place::from(ptr_local),
Rvalue::Use(Operand::Copy(
Place::from(place.local)
.project_deeper(&build_projection(unique_ty, nonnull_ty, ptr_ty), tcx),
)),
Rvalue::Cast(
CastKind::Transmute,
Operand::Copy(
Place::from(place.local)
.project_deeper(&build_projection(unique_ty, nonnull_ty), tcx),
),
ptr_ty,
),
);

place.local = ptr_local;
Expand Down Expand Up @@ -133,8 +132,10 @@ impl<'tcx> crate::MirPass<'tcx> for ElaborateBoxDerefs {
let (unique_ty, nonnull_ty, ptr_ty) =
build_ptr_tys(tcx, boxed_ty, unique_did, nonnull_did);

new_projections
.extend_from_slice(&build_projection(unique_ty, nonnull_ty, ptr_ty));
new_projections.extend_from_slice(&build_projection(unique_ty, nonnull_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);
} else if let Some(new_projections) = new_projections.as_mut() {
// Keep building up our projections list once we've started it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,18 +448,17 @@ pub(crate) fn encode_ty<'tcx>(
if let Some(cfi_encoding) = tcx.get_attr(def_id, sym::cfi_encoding) {
// Use user-defined CFI encoding for type
if let Some(value_str) = cfi_encoding.value_str() {
let value_str = value_str.to_string();
let str = value_str.trim();
if !str.is_empty() {
s.push_str(str);
let value_str = value_str.as_str().trim();
if !value_str.is_empty() {
s.push_str(value_str);
// 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-compression).
let builtin_types = [
"v", "w", "b", "c", "a", "h", "s", "t", "i", "j", "l", "m", "x", "y",
"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);
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1283,13 +1283,13 @@ impl fmt::Debug for Output {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
let stdout_utf8 = str::from_utf8(&self.stdout);
let stdout_debug: &dyn fmt::Debug = match stdout_utf8 {
Ok(ref str) => str,
Ok(ref s) => s,
Err(_) => &self.stdout,
};

let stderr_utf8 = str::from_utf8(&self.stderr);
let stderr_debug: &dyn fmt::Debug = match stderr_utf8 {
Ok(ref str) => str,
Ok(ref s) => s,
Err(_) => &self.stderr,
};

Expand Down
6 changes: 3 additions & 3 deletions library/std/src/sys/pal/windows/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ impl AsRef<OsStr> for EnvKey {
}
}

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

Expand Down
4 changes: 2 additions & 2 deletions library/std/src/sys_common/wtf8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ impl Wtf8Buf {
///
/// Since WTF-8 is a superset of UTF-8, this always succeeds.
#[inline]
pub fn from_str(str: &str) -> Wtf8Buf {
Wtf8Buf { bytes: <[_]>::to_vec(str.as_bytes()), is_known_utf8: true }
pub fn from_str(s: &str) -> Wtf8Buf {
Wtf8Buf { bytes: <[_]>::to_vec(s.as_bytes()), is_known_utf8: true }
}

pub fn clear(&mut self) {
Expand Down
9 changes: 9 additions & 0 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,15 @@ pub fn rustc_cargo_env(
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
Expand Down
13 changes: 12 additions & 1 deletion src/build_helper/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,19 @@ pub fn get_closest_merge_commit(
git.current_dir(git_dir);
}

let channel = include_str!("../../ci/channel");

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()
} else {
// For non-CI environments, ignore rust-lang/rust upstream as it usually gets
Expand Down
14 changes: 7 additions & 7 deletions src/tools/compiletest/src/compute_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn make_diff(expected: &str, actual: &str, context_size: usize) -> Vec<Misma

for result in diff::lines(expected, actual) {
match result {
diff::Result::Left(str) => {
diff::Result::Left(s) => {
if lines_since_mismatch >= context_size && lines_since_mismatch > 0 {
results.push(mismatch);
mismatch = Mismatch::new(line_number - context_queue.len() as u32);
Expand All @@ -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::Expected(str.to_owned()));
mismatch.lines.push(DiffLine::Expected(s.to_owned()));
line_number += 1;
lines_since_mismatch = 0;
}
diff::Result::Right(str) => {
diff::Result::Right(s) => {
if lines_since_mismatch >= context_size && lines_since_mismatch > 0 {
results.push(mismatch);
mismatch = Mismatch::new(line_number - context_queue.len() as u32);
Expand All @@ -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::Resulting(str.to_owned()));
mismatch.lines.push(DiffLine::Resulting(s.to_owned()));
lines_since_mismatch = 0;
}
diff::Result::Both(str, _) => {
diff::Result::Both(s, _) => {
if context_queue.len() >= context_size {
let _ = context_queue.pop_front();
}

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 {
context_queue.push_back(str);
context_queue.push_back(s);
}

line_number += 1;
Expand Down
Loading
Loading