Skip to content

Commit ad211ce

Browse files
committed
Auto merge of rust-lang#135202 - GuillaumeGomez:rollup-9xgs39t, r=GuillaumeGomez
Rollup of 9 pull requests Successful merges: - rust-lang#135081 (bootstrap: Build jemalloc with support for 64K pages) - rust-lang#135174 ([AIX] Port test case run-make/reproducible-build ) - rust-lang#135177 (llvm: Ignore error value that is always false) - rust-lang#135182 (Transmute from NonNull to pointer when elaborating a box deref (MCP807)) - rust-lang#135187 (apply a workaround fix for the release roadblock) - rust-lang#135189 (Remove workaround from pull request template) - rust-lang#135193 (don't bless `proc_macro_deps.rs` unless it's necessary) - rust-lang#135198 (Avoid naming variables `str`) - rust-lang#135199 (Eliminate an unnecessary `Symbol::to_string`; use `as_str`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents fb546ee + 225ffeb commit ad211ce

32 files changed

+148
-96
lines changed

.github/pull_request_template.md

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

compiler/rustc_borrowck/src/region_infer/values.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -544,12 +544,12 @@ fn pretty_print_region_elements(elements: impl IntoIterator<Item = RegionElement
544544

545545
return result;
546546

547-
fn push_location_range(str: &mut String, location1: Location, location2: Location) {
547+
fn push_location_range(s: &mut String, location1: Location, location2: Location) {
548548
if location1 == location2 {
549-
str.push_str(&format!("{location1:?}"));
549+
s.push_str(&format!("{location1:?}"));
550550
} else {
551551
assert_eq!(location1.block, location2.block);
552-
str.push_str(&format!(
552+
s.push_str(&format!(
553553
"{:?}[{}..={}]",
554554
location1.block, location1.statement_index, location2.statement_index
555555
));

compiler/rustc_codegen_gcc/src/back/lto.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -660,9 +660,7 @@ pub unsafe fn optimize_thin_module(
660660
{
661661
let _timer =
662662
cgcx.prof.generic_activity_with_arg("LLVM_thin_lto_rename", thin_module.name());
663-
if !llvm::LLVMRustPrepareThinLTORename(thin_module.shared.data.0, llmod, target) {
664-
return Err(write::llvm_err(&dcx, LlvmError::PrepareThinLtoModule));
665-
}
663+
unsafe { llvm::LLVMRustPrepareThinLTORename(thin_module.shared.data.0, llmod, target) };
666664
save_temp_bitcode(cgcx, &module, "thin-lto-after-rename");
667665
}
668666

compiler/rustc_codegen_llvm/src/back/lto.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -737,11 +737,7 @@ pub(crate) unsafe fn optimize_thin_module(
737737
{
738738
let _timer =
739739
cgcx.prof.generic_activity_with_arg("LLVM_thin_lto_rename", thin_module.name());
740-
if unsafe {
741-
!llvm::LLVMRustPrepareThinLTORename(thin_module.shared.data.0, llmod, target)
742-
} {
743-
return Err(write::llvm_err(dcx, LlvmError::PrepareThinLtoModule));
744-
}
740+
unsafe { llvm::LLVMRustPrepareThinLTORename(thin_module.shared.data.0, llmod, target) };
745741
save_temp_bitcode(cgcx, &module, "thin-lto-after-rename");
746742
}
747743

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2374,7 +2374,7 @@ unsafe extern "C" {
23742374
Data: &ThinLTOData,
23752375
Module: &Module,
23762376
Target: &TargetMachine,
2377-
) -> bool;
2377+
);
23782378
pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
23792379
pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
23802380
pub fn LLVMRustPrepareThinLTOImport(

compiler/rustc_const_eval/src/interpret/operand.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
704704
pub fn read_str(&self, mplace: &MPlaceTy<'tcx, M::Provenance>) -> InterpResult<'tcx, &str> {
705705
let len = mplace.len(self)?;
706706
let bytes = self.read_bytes_ptr_strip_provenance(mplace.ptr(), Size::from_bytes(len))?;
707-
let str = std::str::from_utf8(bytes).map_err(|err| err_ub!(InvalidStr(err)))?;
708-
interp_ok(str)
707+
let s = std::str::from_utf8(bytes).map_err(|err| err_ub!(InvalidStr(err)))?;
708+
interp_ok(s)
709709
}
710710

711711
/// Read from a local of the current frame. Convenience method for [`InterpCx::local_at_frame_to_op`].

compiler/rustc_const_eval/src/interpret/place.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1017,9 +1017,9 @@ where
10171017
/// This is allocated in immutable global memory and deduplicated.
10181018
pub fn allocate_str_dedup(
10191019
&mut self,
1020-
str: &str,
1020+
s: &str,
10211021
) -> InterpResult<'tcx, MPlaceTy<'tcx, M::Provenance>> {
1022-
let bytes = str.as_bytes();
1022+
let bytes = s.as_bytes();
10231023
let ptr = self.allocate_bytes_dedup(bytes)?;
10241024

10251025
// Create length metadata for the string.

compiler/rustc_lint/src/nonstandard_style.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -234,18 +234,18 @@ declare_lint! {
234234
declare_lint_pass!(NonSnakeCase => [NON_SNAKE_CASE]);
235235

236236
impl NonSnakeCase {
237-
fn to_snake_case(mut str: &str) -> String {
237+
fn to_snake_case(mut name: &str) -> String {
238238
let mut words = vec![];
239239
// Preserve leading underscores
240-
str = str.trim_start_matches(|c: char| {
240+
name = name.trim_start_matches(|c: char| {
241241
if c == '_' {
242242
words.push(String::new());
243243
true
244244
} else {
245245
false
246246
}
247247
});
248-
for s in str.split('_') {
248+
for s in name.split('_') {
249249
let mut last_upper = false;
250250
let mut buf = String::new();
251251
if s.is_empty() {

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+2-8
Original file line numberDiff line numberDiff line change
@@ -1389,20 +1389,14 @@ static bool clearDSOLocalOnDeclarations(Module &Mod, TargetMachine &TM) {
13891389
return ClearDSOLocalOnDeclarations;
13901390
}
13911391

1392-
extern "C" bool LLVMRustPrepareThinLTORename(const LLVMRustThinLTOData *Data,
1392+
extern "C" void LLVMRustPrepareThinLTORename(const LLVMRustThinLTOData *Data,
13931393
LLVMModuleRef M,
13941394
LLVMTargetMachineRef TM) {
13951395
Module &Mod = *unwrap(M);
13961396
TargetMachine &Target = *unwrap(TM);
13971397

13981398
bool ClearDSOLocal = clearDSOLocalOnDeclarations(Mod, Target);
1399-
bool error = renameModuleForThinLTO(Mod, Data->Index, ClearDSOLocal);
1400-
1401-
if (error) {
1402-
LLVMRustSetLastError("renameModuleForThinLTO failed");
1403-
return false;
1404-
}
1405-
return true;
1399+
renameModuleForThinLTO(Mod, Data->Index, ClearDSOLocal);
14061400
}
14071401

14081402
extern "C" bool

compiler/rustc_log/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ pub fn init_logger(cfg: LoggerConfig) -> Result<(), Error> {
130130

131131
let subscriber = tracing_subscriber::Registry::default().with(filter).with(layer);
132132
match cfg.backtrace {
133-
Ok(str) => {
133+
Ok(backtrace_target) => {
134134
let fmt_layer = tracing_subscriber::fmt::layer()
135135
.with_writer(io::stderr)
136136
.without_time()
137-
.event_format(BacktraceFormatter { backtrace_target: str });
137+
.event_format(BacktraceFormatter { backtrace_target });
138138
let subscriber = subscriber.with(fmt_layer);
139139
tracing::subscriber::set_global_default(subscriber).unwrap();
140140
}

compiler/rustc_macros/src/symbols.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ impl Entries {
156156
Entries { map: HashMap::with_capacity(capacity) }
157157
}
158158

159-
fn insert(&mut self, span: Span, str: &str, errors: &mut Errors) -> u32 {
160-
if let Some(prev) = self.map.get(str) {
161-
errors.error(span, format!("Symbol `{str}` is duplicated"));
159+
fn insert(&mut self, span: Span, s: &str, errors: &mut Errors) -> u32 {
160+
if let Some(prev) = self.map.get(s) {
161+
errors.error(span, format!("Symbol `{s}` is duplicated"));
162162
errors.error(prev.span_of_name, "location of previous definition".to_string());
163163
prev.idx
164164
} else {
165165
let idx = self.len();
166-
self.map.insert(str.to_string(), Preinterned { idx, span_of_name: span });
166+
self.map.insert(s.to_string(), Preinterned { idx, span_of_name: span });
167167
idx
168168
}
169169
}
@@ -192,14 +192,14 @@ fn symbols_with_errors(input: TokenStream) -> (TokenStream, Vec<syn::Error>) {
192192
let mut entries = Entries::with_capacity(input.keywords.len() + input.symbols.len() + 10);
193193
let mut prev_key: Option<(Span, String)> = None;
194194

195-
let mut check_order = |span: Span, str: &str, errors: &mut Errors| {
195+
let mut check_order = |span: Span, s: &str, errors: &mut Errors| {
196196
if let Some((prev_span, ref prev_str)) = prev_key {
197-
if str < prev_str {
198-
errors.error(span, format!("Symbol `{str}` must precede `{prev_str}`"));
197+
if s < prev_str {
198+
errors.error(span, format!("Symbol `{s}` must precede `{prev_str}`"));
199199
errors.error(prev_span, format!("location of previous symbol `{prev_str}`"));
200200
}
201201
}
202-
prev_key = Some((span, str.to_string()));
202+
prev_key = Some((span, s.to_string()));
203203
};
204204

205205
// Generate the listed keywords.

compiler/rustc_mir_transform/src/elaborate_box_derefs.rs

+14-13
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,8 @@ fn build_ptr_tys<'tcx>(
2929
pub(super) fn build_projection<'tcx>(
3030
unique_ty: Ty<'tcx>,
3131
nonnull_ty: Ty<'tcx>,
32-
ptr_ty: Ty<'tcx>,
33-
) -> [PlaceElem<'tcx>; 3] {
34-
[
35-
PlaceElem::Field(FieldIdx::ZERO, unique_ty),
36-
PlaceElem::Field(FieldIdx::ZERO, nonnull_ty),
37-
PlaceElem::Field(FieldIdx::ZERO, ptr_ty),
38-
]
32+
) -> [PlaceElem<'tcx>; 2] {
33+
[PlaceElem::Field(FieldIdx::ZERO, unique_ty), PlaceElem::Field(FieldIdx::ZERO, nonnull_ty)]
3934
}
4035

4136
struct ElaborateBoxDerefVisitor<'a, 'tcx> {
@@ -75,10 +70,14 @@ impl<'a, 'tcx> MutVisitor<'tcx> for ElaborateBoxDerefVisitor<'a, 'tcx> {
7570
self.patch.add_assign(
7671
location,
7772
Place::from(ptr_local),
78-
Rvalue::Use(Operand::Copy(
79-
Place::from(place.local)
80-
.project_deeper(&build_projection(unique_ty, nonnull_ty, ptr_ty), tcx),
81-
)),
73+
Rvalue::Cast(
74+
CastKind::Transmute,
75+
Operand::Copy(
76+
Place::from(place.local)
77+
.project_deeper(&build_projection(unique_ty, nonnull_ty), tcx),
78+
),
79+
ptr_ty,
80+
),
8281
);
8382

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

136-
new_projections
137-
.extend_from_slice(&build_projection(unique_ty, nonnull_ty, ptr_ty));
135+
new_projections.extend_from_slice(&build_projection(unique_ty, nonnull_ty));
136+
// While we can't project into `NonNull<_>` in a basic block
137+
// due to MCP#807, this is debug info where it's fine.
138+
new_projections.push(PlaceElem::Field(FieldIdx::ZERO, ptr_ty));
138139
new_projections.push(PlaceElem::Deref);
139140
} else if let Some(new_projections) = new_projections.as_mut() {
140141
// Keep building up our projections list once we've started it.

compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -448,18 +448,17 @@ pub(crate) fn encode_ty<'tcx>(
448448
if let Some(cfi_encoding) = tcx.get_attr(def_id, sym::cfi_encoding) {
449449
// Use user-defined CFI encoding for type
450450
if let Some(value_str) = cfi_encoding.value_str() {
451-
let value_str = value_str.to_string();
452-
let str = value_str.trim();
453-
if !str.is_empty() {
454-
s.push_str(str);
451+
let value_str = value_str.as_str().trim();
452+
if !value_str.is_empty() {
453+
s.push_str(value_str);
455454
// Don't compress user-defined builtin types (see
456455
// https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-builtin and
457456
// https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-compression).
458457
let builtin_types = [
459458
"v", "w", "b", "c", "a", "h", "s", "t", "i", "j", "l", "m", "x", "y",
460459
"n", "o", "f", "d", "e", "g", "z", "Dh",
461460
];
462-
if !builtin_types.contains(&str) {
461+
if !builtin_types.contains(&value_str) {
463462
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
464463
}
465464
} else {

library/std/src/process.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1283,13 +1283,13 @@ impl fmt::Debug for Output {
12831283
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
12841284
let stdout_utf8 = str::from_utf8(&self.stdout);
12851285
let stdout_debug: &dyn fmt::Debug = match stdout_utf8 {
1286-
Ok(ref str) => str,
1286+
Ok(ref s) => s,
12871287
Err(_) => &self.stdout,
12881288
};
12891289

12901290
let stderr_utf8 = str::from_utf8(&self.stderr);
12911291
let stderr_debug: &dyn fmt::Debug = match stderr_utf8 {
1292-
Ok(ref str) => str,
1292+
Ok(ref s) => s,
12931293
Err(_) => &self.stderr,
12941294
};
12951295

library/std/src/sys/pal/windows/process.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ impl AsRef<OsStr> for EnvKey {
142142
}
143143
}
144144

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

library/std/src/sys_common/wtf8.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ impl Wtf8Buf {
204204
///
205205
/// Since WTF-8 is a superset of UTF-8, this always succeeds.
206206
#[inline]
207-
pub fn from_str(str: &str) -> Wtf8Buf {
208-
Wtf8Buf { bytes: <[_]>::to_vec(str.as_bytes()), is_known_utf8: true }
207+
pub fn from_str(s: &str) -> Wtf8Buf {
208+
Wtf8Buf { bytes: <[_]>::to_vec(s.as_bytes()), is_known_utf8: true }
209209
}
210210

211211
pub fn clear(&mut self) {

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

+9
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,15 @@ pub fn rustc_cargo_env(
12071207
rustc_llvm_env(builder, cargo, target)
12081208
}
12091209
}
1210+
1211+
// Build jemalloc on AArch64 with support for page sizes up to 64K
1212+
// See: https://github.com/rust-lang/rust/pull/135081
1213+
if builder.config.jemalloc
1214+
&& target.starts_with("aarch64")
1215+
&& env::var_os("JEMALLOC_SYS_WITH_LG_PAGE").is_none()
1216+
{
1217+
cargo.env("JEMALLOC_SYS_WITH_LG_PAGE", "16");
1218+
}
12101219
}
12111220

12121221
/// Pass down configuration from the LLVM build into the build of

src/build_helper/src/git.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,19 @@ pub fn get_closest_merge_commit(
129129
git.current_dir(git_dir);
130130
}
131131

132+
let channel = include_str!("../../ci/channel");
133+
132134
let merge_base = {
133-
if CiEnv::is_ci() {
135+
if CiEnv::is_ci() &&
136+
// FIXME: When running on rust-lang managed CI and it's not a nightly build,
137+
// `git_upstream_merge_base` fails with an error message similar to this:
138+
// ```
139+
// called `Result::unwrap()` on an `Err` value: "command did not execute successfully:
140+
// cd \"/checkout\" && \"git\" \"merge-base\" \"origin/master\" \"HEAD\"\nexpected success, got: exit status: 1\n"
141+
// ```
142+
// Investigate and resolve this issue instead of skipping it like this.
143+
(channel == "nightly" || !CiEnv::is_rust_lang_managed_ci_job())
144+
{
134145
git_upstream_merge_base(config, git_dir).unwrap()
135146
} else {
136147
// For non-CI environments, ignore rust-lang/rust upstream as it usually gets

src/tools/compiletest/src/compute_diff.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub fn make_diff(expected: &str, actual: &str, context_size: usize) -> Vec<Misma
3131

3232
for result in diff::lines(expected, actual) {
3333
match result {
34-
diff::Result::Left(str) => {
34+
diff::Result::Left(s) => {
3535
if lines_since_mismatch >= context_size && lines_since_mismatch > 0 {
3636
results.push(mismatch);
3737
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
4141
mismatch.lines.push(DiffLine::Context(line.to_owned()));
4242
}
4343

44-
mismatch.lines.push(DiffLine::Expected(str.to_owned()));
44+
mismatch.lines.push(DiffLine::Expected(s.to_owned()));
4545
line_number += 1;
4646
lines_since_mismatch = 0;
4747
}
48-
diff::Result::Right(str) => {
48+
diff::Result::Right(s) => {
4949
if lines_since_mismatch >= context_size && lines_since_mismatch > 0 {
5050
results.push(mismatch);
5151
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
5555
mismatch.lines.push(DiffLine::Context(line.to_owned()));
5656
}
5757

58-
mismatch.lines.push(DiffLine::Resulting(str.to_owned()));
58+
mismatch.lines.push(DiffLine::Resulting(s.to_owned()));
5959
lines_since_mismatch = 0;
6060
}
61-
diff::Result::Both(str, _) => {
61+
diff::Result::Both(s, _) => {
6262
if context_queue.len() >= context_size {
6363
let _ = context_queue.pop_front();
6464
}
6565

6666
if lines_since_mismatch < context_size {
67-
mismatch.lines.push(DiffLine::Context(str.to_owned()));
67+
mismatch.lines.push(DiffLine::Context(s.to_owned()));
6868
} else if context_size > 0 {
69-
context_queue.push_back(str);
69+
context_queue.push_back(s);
7070
}
7171

7272
line_number += 1;

0 commit comments

Comments
 (0)