Skip to content

Commit 1281315

Browse files
committed
Auto merge of rust-lang#79994 - JohnTitor:rollup-43wl2uj, r=JohnTitor
Rollup of 12 pull requests Successful merges: - rust-lang#79360 (std::iter: document iteration over `&T` and `&mut T`) - rust-lang#79398 (Link loop/for keyword) - rust-lang#79834 (Remove deprecated linked_list_extras methods.) - rust-lang#79845 (Fix rustup support in default_build_triple for python3) - rust-lang#79940 (fix more clippy::complexity findings) - rust-lang#79942 (Add post-init hook for static memory for miri.) - rust-lang#79954 (Fix building compiler docs with stage 0) - rust-lang#79963 (Fix typo in `DebruijnIndex` documentation) - rust-lang#79970 (Misc rustbuild improvements when the LLVM backend isn't used) - rust-lang#79973 (rustdoc light theme: Fix CSS for selected buttons) - rust-lang#79984 (Remove an unused dependency that made `rustdoc` crash) - rust-lang#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

-3
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

+1-4
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

+2-2
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

+18-18
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

+10
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

+4-5
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

+2-2
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

-3
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

+4-3
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

+3-2
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())

compiler/rustc_session/src/session.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1109,10 +1109,7 @@ impl Session {
11091109
}
11101110

11111111
pub fn link_dead_code(&self) -> bool {
1112-
match self.opts.cg.link_dead_code {
1113-
Some(explicitly_set) => explicitly_set,
1114-
None => false,
1115-
}
1112+
self.opts.cg.link_dead_code.unwrap_or(false)
11161113
}
11171114

11181115
pub fn mark_attr_known(&self, attr: &Attribute) {

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+20-21
Original file line numberDiff line numberDiff line change
@@ -1448,31 +1448,30 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
14481448
});
14491449
};
14501450

1451-
typeck_results
1451+
if let Some(cause) = typeck_results
14521452
.generator_interior_types
14531453
.iter()
14541454
.find(|ty::GeneratorInteriorTypeCause { ty, .. }| ty_matches(ty))
1455-
.map(|cause| {
1456-
// Check to see if any awaited expressions have the target type.
1457-
let from_awaited_ty = visitor
1458-
.awaits
1459-
.into_iter()
1460-
.map(|id| hir.expect_expr(id))
1461-
.find(|await_expr| {
1462-
let ty = typeck_results.expr_ty_adjusted(&await_expr);
1463-
debug!(
1464-
"maybe_note_obligation_cause_for_async_await: await_expr={:?}",
1465-
await_expr
1466-
);
1467-
ty_matches(ty)
1468-
})
1469-
.map(|expr| expr.span);
1470-
let ty::GeneratorInteriorTypeCause { span, scope_span, yield_span, expr, .. } =
1471-
cause;
1455+
{
1456+
// Check to see if any awaited expressions have the target type.
1457+
let from_awaited_ty = visitor
1458+
.awaits
1459+
.into_iter()
1460+
.map(|id| hir.expect_expr(id))
1461+
.find(|await_expr| {
1462+
let ty = typeck_results.expr_ty_adjusted(&await_expr);
1463+
debug!(
1464+
"maybe_note_obligation_cause_for_async_await: await_expr={:?}",
1465+
await_expr
1466+
);
1467+
ty_matches(ty)
1468+
})
1469+
.map(|expr| expr.span);
1470+
let ty::GeneratorInteriorTypeCause { span, scope_span, yield_span, expr, .. } = cause;
14721471

1473-
interior_or_upvar_span = Some(GeneratorInteriorOrUpvar::Interior(*span));
1474-
interior_extra_info = Some((*scope_span, *yield_span, *expr, from_awaited_ty));
1475-
});
1472+
interior_or_upvar_span = Some(GeneratorInteriorOrUpvar::Interior(*span));
1473+
interior_extra_info = Some((*scope_span, *yield_span, *expr, from_awaited_ty));
1474+
};
14761475

14771476
debug!(
14781477
"maybe_note_obligation_cause_for_async_await: interior_or_upvar={:?} \

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
447447
);
448448
nested.push(Obligation::new(
449449
obligation.cause.clone(),
450-
obligation.param_env.clone(),
450+
obligation.param_env,
451451
normalized_super_trait,
452452
));
453453
}
@@ -485,7 +485,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
485485
);
486486
nested.push(Obligation::new(
487487
obligation.cause.clone(),
488-
obligation.param_env.clone(),
488+
obligation.param_env,
489489
normalized_bound,
490490
));
491491
}

compiler/rustc_type_ir/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ rustc_index::newtype_index! {
119119
/// Bruijn index of 0, meaning "the innermost binder" (in this case, a
120120
/// fn). The region `'a` that appears in the second argument type (`&'a
121121
/// isize`) would then be assigned a De Bruijn index of 1, meaning "the
122-
/// second-innermost binder". (These indices are written on the arrays
122+
/// second-innermost binder". (These indices are written on the arrows
123123
/// in the diagram).
124124
///
125125
/// What is interesting is that De Bruijn index attached to a particular

compiler/rustc_typeck/src/check/upvar.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -294,17 +294,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
294294

295295
closure_captures.insert(*var_hir_id, upvar_id);
296296

297-
let new_capture_kind = if let Some(capture_kind) =
298-
upvar_capture_map.get(&upvar_id)
299-
{
300-
// upvar_capture_map only stores the UpvarCapture (CaptureKind),
301-
// so we create a fake capture info with no expression.
302-
let fake_capture_info =
303-
ty::CaptureInfo { expr_id: None, capture_kind: capture_kind.clone() };
304-
determine_capture_info(fake_capture_info, capture_info).capture_kind
305-
} else {
306-
capture_info.capture_kind
307-
};
297+
let new_capture_kind =
298+
if let Some(capture_kind) = upvar_capture_map.get(&upvar_id) {
299+
// upvar_capture_map only stores the UpvarCapture (CaptureKind),
300+
// so we create a fake capture info with no expression.
301+
let fake_capture_info =
302+
ty::CaptureInfo { expr_id: None, capture_kind: *capture_kind };
303+
determine_capture_info(fake_capture_info, capture_info).capture_kind
304+
} else {
305+
capture_info.capture_kind
306+
};
308307
upvar_capture_map.insert(upvar_id, new_capture_kind);
309308
}
310309
}

compiler/rustc_typeck/src/collect.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -2141,13 +2141,8 @@ fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicat
21412141
// * It must be an associated type for this trait (*not* a
21422142
// supertrait).
21432143
if let ty::Projection(projection) = ty.kind() {
2144-
if projection.substs == trait_identity_substs
2144+
projection.substs == trait_identity_substs
21452145
&& tcx.associated_item(projection.item_def_id).container.id() == def_id
2146-
{
2147-
true
2148-
} else {
2149-
false
2150-
}
21512146
} else {
21522147
false
21532148
}

library/alloc/src/collections/linked_list.rs

-62
Original file line numberDiff line numberDiff line change
@@ -1099,68 +1099,6 @@ impl<T> ExactSizeIterator for IterMut<'_, T> {}
10991099
#[stable(feature = "fused", since = "1.26.0")]
11001100
impl<T> FusedIterator for IterMut<'_, T> {}
11011101

1102-
impl<T> IterMut<'_, T> {
1103-
/// Inserts the given element just after the element most recently returned by `.next()`.
1104-
/// The inserted element does not appear in the iteration.
1105-
///
1106-
/// This method will be removed soon.
1107-
#[inline]
1108-
#[unstable(
1109-
feature = "linked_list_extras",
1110-
reason = "this is probably better handled by a cursor type -- we'll see",
1111-
issue = "27794"
1112-
)]
1113-
#[rustc_deprecated(
1114-
reason = "Deprecated in favor of CursorMut methods. This method will be removed soon.",
1115-
since = "1.47.0"
1116-
)]
1117-
pub fn insert_next(&mut self, element: T) {
1118-
match self.head {
1119-
// `push_back` is okay with aliasing `element` references
1120-
None => self.list.push_back(element),
1121-
Some(head) => unsafe {
1122-
let prev = match head.as_ref().prev {
1123-
// `push_front` is okay with aliasing nodes
1124-
None => return self.list.push_front(element),
1125-
Some(prev) => prev,
1126-
};
1127-
1128-
let node = Some(
1129-
Box::leak(box Node { next: Some(head), prev: Some(prev), element }).into(),
1130-
);
1131-
1132-
// Not creating references to entire nodes to not invalidate the
1133-
// reference to `element` we handed to the user.
1134-
(*prev.as_ptr()).next = node;
1135-
(*head.as_ptr()).prev = node;
1136-
1137-
self.list.len += 1;
1138-
},
1139-
}
1140-
}
1141-
1142-
/// Provides a reference to the next element, without changing the iterator.
1143-
///
1144-
/// This method will be removed soon.
1145-
#[inline]
1146-
#[unstable(
1147-
feature = "linked_list_extras",
1148-
reason = "this is probably better handled by a cursor type -- we'll see",
1149-
issue = "27794"
1150-
)]
1151-
#[rustc_deprecated(
1152-
reason = "Deprecated in favor of CursorMut methods. This method will be removed soon.",
1153-
since = "1.47.0"
1154-
)]
1155-
pub fn peek_next(&mut self) -> Option<&mut T> {
1156-
if self.len == 0 {
1157-
None
1158-
} else {
1159-
unsafe { self.head.as_mut().map(|node| &mut node.as_mut().element) }
1160-
}
1161-
}
1162-
}
1163-
11641102
/// A cursor over a `LinkedList`.
11651103
///
11661104
/// A `Cursor` is like an iterator, except that it can freely seek back-and-forth.

0 commit comments

Comments
 (0)