Skip to content

Commit 1281315

Browse files
committed
Auto merge of #79994 - JohnTitor:rollup-43wl2uj, r=JohnTitor
Rollup of 12 pull requests Successful merges: - #79360 (std::iter: document iteration over `&T` and `&mut T`) - #79398 (Link loop/for keyword) - #79834 (Remove deprecated linked_list_extras methods.) - #79845 (Fix rustup support in default_build_triple for python3) - #79940 (fix more clippy::complexity findings) - #79942 (Add post-init hook for static memory for miri.) - #79954 (Fix building compiler docs with stage 0) - #79963 (Fix typo in `DebruijnIndex` documentation) - #79970 (Misc rustbuild improvements when the LLVM backend isn't used) - #79973 (rustdoc light theme: Fix CSS for selected buttons) - #79984 (Remove an unused dependency that made `rustdoc` crash) - #79985 (Fixes submit event of the search input) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents dd11f45 + 3213089 commit 1281315

File tree

28 files changed

+187
-188
lines changed

28 files changed

+187
-188
lines changed

Cargo.lock

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -725,9 +725,6 @@ checksum = "9a21fa21941700a3cd8fcb4091f361a6a712fac632f85d9f487cc892045d55c6"
725725
[[package]]
726726
name = "coverage_test_macros"
727727
version = "0.0.0"
728-
dependencies = [
729-
"proc-macro2",
730-
]
731728

732729
[[package]]
733730
name = "cpuid-bool"

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,10 +597,7 @@ impl<'a> TraitDef<'a> {
597597

598598
let mut ty_params = params
599599
.iter()
600-
.filter_map(|param| match param.kind {
601-
ast::GenericParamKind::Type { .. } => Some(param),
602-
_ => None,
603-
})
600+
.filter(|param| matches!(param.kind, ast::GenericParamKind::Type{..}))
604601
.peekable();
605602

606603
if ty_params.peek().is_some() {

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,8 +854,8 @@ fn generic_simd_intrinsic(
854854
));
855855
}
856856

857-
if name_str.starts_with("simd_shuffle") {
858-
let n: u64 = name_str["simd_shuffle".len()..].parse().unwrap_or_else(|_| {
857+
if let Some(stripped) = name_str.strip_prefix("simd_shuffle") {
858+
let n: u64 = stripped.parse().unwrap_or_else(|_| {
859859
span_bug!(span, "bad `simd_shuffle` instruction only caught in codegen?")
860860
});
861861

compiler/rustc_llvm/build.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,10 @@ fn main() {
201201
cmd.args(&components);
202202

203203
for lib in output(&mut cmd).split_whitespace() {
204-
let name = if lib.starts_with("-l") {
205-
&lib[2..]
206-
} else if lib.starts_with('-') {
207-
&lib[1..]
204+
let name = if let Some(stripped) = lib.strip_prefix("-l") {
205+
stripped
206+
} else if let Some(stripped) = lib.strip_prefix('-') {
207+
stripped
208208
} else if Path::new(lib).exists() {
209209
// On MSVC llvm-config will print the full name to libraries, but
210210
// we're only interested in the name part
@@ -241,17 +241,17 @@ fn main() {
241241
cmd.arg(llvm_link_arg).arg("--ldflags");
242242
for lib in output(&mut cmd).split_whitespace() {
243243
if is_crossed {
244-
if lib.starts_with("-LIBPATH:") {
245-
println!("cargo:rustc-link-search=native={}", lib[9..].replace(&host, &target));
246-
} else if lib.starts_with("-L") {
247-
println!("cargo:rustc-link-search=native={}", lib[2..].replace(&host, &target));
244+
if let Some(stripped) = lib.strip_prefix("-LIBPATH:") {
245+
println!("cargo:rustc-link-search=native={}", stripped.replace(&host, &target));
246+
} else if let Some(stripped) = lib.strip_prefix("-L") {
247+
println!("cargo:rustc-link-search=native={}", stripped.replace(&host, &target));
248248
}
249-
} else if lib.starts_with("-LIBPATH:") {
250-
println!("cargo:rustc-link-search=native={}", &lib[9..]);
251-
} else if lib.starts_with("-l") {
252-
println!("cargo:rustc-link-lib={}", &lib[2..]);
253-
} else if lib.starts_with("-L") {
254-
println!("cargo:rustc-link-search=native={}", &lib[2..]);
249+
} else if let Some(stripped) = lib.strip_prefix("-LIBPATH:") {
250+
println!("cargo:rustc-link-search=native={}", stripped);
251+
} else if let Some(stripped) = lib.strip_prefix("-l") {
252+
println!("cargo:rustc-link-lib={}", stripped);
253+
} else if let Some(stripped) = lib.strip_prefix("-L") {
254+
println!("cargo:rustc-link-search=native={}", stripped);
255255
}
256256
}
257257

@@ -262,10 +262,10 @@ fn main() {
262262
let llvm_linker_flags = tracked_env_var_os("LLVM_LINKER_FLAGS");
263263
if let Some(s) = llvm_linker_flags {
264264
for lib in s.into_string().unwrap().split_whitespace() {
265-
if lib.starts_with("-l") {
266-
println!("cargo:rustc-link-lib={}", &lib[2..]);
267-
} else if lib.starts_with("-L") {
268-
println!("cargo:rustc-link-search=native={}", &lib[2..]);
265+
if let Some(stripped) = lib.strip_prefix("-l") {
266+
println!("cargo:rustc-link-lib={}", stripped);
267+
} else if let Some(stripped) = lib.strip_prefix("-L") {
268+
println!("cargo:rustc-link-search=native={}", stripped);
269269
}
270270
}
271271
}

compiler/rustc_mir/src/interpret/machine.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::hash::Hash;
99
use rustc_middle::mir;
1010
use rustc_middle::ty::{self, Ty};
1111
use rustc_span::def_id::DefId;
12+
use rustc_target::abi::Size;
1213

1314
use super::{
1415
AllocId, Allocation, AllocationExtra, CheckInAllocMsg, Frame, ImmTy, InterpCx, InterpResult,
@@ -299,6 +300,15 @@ pub trait Machine<'mir, 'tcx>: Sized {
299300
Ok(())
300301
}
301302

303+
/// Called after initializing static memory using the interpreter.
304+
fn after_static_mem_initialized(
305+
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
306+
_ptr: Pointer<Self::PointerTag>,
307+
_size: Size,
308+
) -> InterpResult<'tcx> {
309+
Ok(())
310+
}
311+
302312
/// Executes a retagging operation
303313
#[inline]
304314
fn retag(

compiler/rustc_mir/src/interpret/traits.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
5656
// If you touch this code, be sure to also make the corresponding changes to
5757
// `get_vtable` in `rust_codegen_llvm/meth.rs`.
5858
// /////////////////////////////////////////////////////////////////////////////////////////
59-
let vtable = self.memory.allocate(
60-
ptr_size * u64::try_from(methods.len()).unwrap().checked_add(3).unwrap(),
61-
ptr_align,
62-
MemoryKind::Vtable,
63-
);
59+
let vtable_size = ptr_size * u64::try_from(methods.len()).unwrap().checked_add(3).unwrap();
60+
let vtable = self.memory.allocate(vtable_size, ptr_align, MemoryKind::Vtable);
6461

6562
let drop = Instance::resolve_drop_in_place(tcx, ty);
6663
let drop = self.memory.create_fn_alloc(FnVal::Instance(drop));
@@ -93,6 +90,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
9390
}
9491
}
9592

93+
M::after_static_mem_initialized(self, vtable, vtable_size)?;
94+
9695
self.memory.mark_immutable(vtable.alloc_id)?;
9796
assert!(self.vtables.insert((ty, poly_trait_ref), vtable).is_none());
9897

compiler/rustc_mir/src/transform/coverage/debug.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl DebugCounters {
285285
),
286286
};
287287
counters
288-
.insert(id.into(), DebugCounter::new(counter_kind.clone(), some_block_label))
288+
.insert(id, DebugCounter::new(counter_kind.clone(), some_block_label))
289289
.expect_none(
290290
"attempt to add the same counter_kind to DebugCounters more than once",
291291
);
@@ -340,7 +340,7 @@ impl DebugCounters {
340340
if self.some_counters.is_some() && (counter_format.block || !counter_format.id) {
341341
let counters = self.some_counters.as_ref().unwrap();
342342
if let Some(DebugCounter { some_block_label: Some(block_label), .. }) =
343-
counters.get(&id.into())
343+
counters.get(&id)
344344
{
345345
return if counter_format.id {
346346
format!("{}#{}", block_label, id.index())

compiler/rustc_mir/src/transform/coverage/test_macros/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,3 @@ edition = "2018"
77
[lib]
88
proc-macro = true
99
doctest = false
10-
11-
[dependencies]
12-
proc-macro2 = "1"

compiler/rustc_mir/src/transform/early_otherwise_branch.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,10 @@ impl<'a, 'tcx> Helper<'a, 'tcx> {
216216
let discr = self.find_switch_discriminant_info(bb, switch)?;
217217

218218
// go through each target, finding a discriminant read, and a switch
219-
let results = discr.targets_with_values.iter().map(|(value, target)| {
220-
self.find_discriminant_switch_pairing(&discr, target.clone(), value.clone())
221-
});
219+
let results = discr
220+
.targets_with_values
221+
.iter()
222+
.map(|(value, target)| self.find_discriminant_switch_pairing(&discr, *target, *value));
222223

223224
// if the optimization did not apply for one of the targets, then abort
224225
if results.clone().any(|x| x.is_none()) || results.len() == 0 {

compiler/rustc_mir_build/src/build/scope.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
616616
debug!("stmt_expr Break val block_context.push(SubExpr)");
617617
self.block_context.push(BlockFrame::SubExpr);
618618
unpack!(block = self.into(destination, dest_scope, block, value));
619-
dest_scope
620-
.map(|scope| self.unschedule_drop(scope, destination.as_local().unwrap()));
619+
if let Some(scope) = dest_scope {
620+
self.unschedule_drop(scope, destination.as_local().unwrap())
621+
};
621622
self.block_context.pop();
622623
} else {
623624
self.cfg.push_assign_unit(block, source_info, destination, self.hir.tcx())

0 commit comments

Comments
 (0)