Skip to content

Commit 5cc6072

Browse files
committed
Auto merge of #139101 - matthiaskrgr:rollup-zhu7hf6, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #138692 (Reject `{true,false}` as revision names) - #138757 (wasm: increase default thread stack size to 1 MB) - #138988 (Change the syntax of the internal `weak!` macro) - #139056 (use `try_fold` instead of `fold`) - #139057 (use `slice::contains` where applicable) - #139086 (Various cleanup in ExprUseVisitor) - #139097 (Add more tests for pin!().) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8989165 + 8b7088a commit 5cc6072

File tree

28 files changed

+336
-208
lines changed

28 files changed

+336
-208
lines changed

compiler/rustc_builtin_macros/src/edition_panic.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ pub(crate) fn use_panic_2021(mut span: Span) -> bool {
7474
// (To avoid using the edition of e.g. the assert!() or debug_assert!() definition.)
7575
loop {
7676
let expn = span.ctxt().outer_expn_data();
77-
if let Some(features) = expn.allow_internal_unstable {
78-
if features.iter().any(|&f| f == sym::edition_panic) {
79-
span = expn.call_site;
80-
continue;
81-
}
77+
if let Some(features) = expn.allow_internal_unstable
78+
&& features.contains(&sym::edition_panic)
79+
{
80+
span = expn.call_site;
81+
continue;
8282
}
8383
break expn.edition >= Edition::Edition2021;
8484
}

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2186,7 +2186,7 @@ fn msvc_imps_needed(tcx: TyCtxt<'_>) -> bool {
21862186
// indirectly from ThinLTO. In theory these are not needed as ThinLTO could resolve
21872187
// these, but it currently does not do so.
21882188
let can_have_static_objects =
2189-
tcx.sess.lto() == Lto::Thin || tcx.crate_types().iter().any(|ct| *ct == CrateType::Rlib);
2189+
tcx.sess.lto() == Lto::Thin || tcx.crate_types().contains(&CrateType::Rlib);
21902190

21912191
tcx.sess.target.is_like_windows &&
21922192
can_have_static_objects &&

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
604604
if let Some((name, _)) = lang_items::extract(attrs)
605605
&& let Some(lang_item) = LangItem::from_name(name)
606606
{
607-
if WEAK_LANG_ITEMS.iter().any(|&l| l == lang_item) {
607+
if WEAK_LANG_ITEMS.contains(&lang_item) {
608608
codegen_fn_attrs.flags |= CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL;
609609
}
610610
if let Some(link_name) = lang_item.link_name() {

compiler/rustc_hir_typeck/src/expr_use_visitor.rs

Lines changed: 49 additions & 93 deletions
Large diffs are not rendered by default.

compiler/rustc_hir_typeck/src/upvar.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
//! from there).
1919
//!
2020
//! The fact that we are inferring borrow kinds as we go results in a
21-
//! semi-hacky interaction with mem-categorization. In particular,
22-
//! mem-categorization will query the current borrow kind as it
23-
//! categorizes, and we'll return the *current* value, but this may get
21+
//! semi-hacky interaction with the way `ExprUseVisitor` is computing
22+
//! `Place`s. In particular, it will query the current borrow kind as it
23+
//! goes, and we'll return the *current* value, but this may get
2424
//! adjusted later. Therefore, in this module, we generally ignore the
25-
//! borrow kind (and derived mutabilities) that are returned from
26-
//! mem-categorization, since they may be inaccurate. (Another option
25+
//! borrow kind (and derived mutabilities) that `ExprUseVisitor` returns
26+
//! within `Place`s, since they may be inaccurate. (Another option
2727
//! would be to use a unification scheme, where instead of returning a
2828
//! concrete borrow kind like `ty::ImmBorrow`, we return a
2929
//! `ty::InferBorrow(upvar_id)` or something like that, but this would

compiler/rustc_middle/src/hir/place.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ pub struct Projection<'tcx> {
5353
pub kind: ProjectionKind,
5454
}
5555

56-
/// A `Place` represents how a value is located in memory.
56+
/// A `Place` represents how a value is located in memory. This does not
57+
/// always correspond to a syntactic place expression. For example, when
58+
/// processing a pattern, a `Place` can be used to refer to the sub-value
59+
/// currently being inspected.
5760
///
5861
/// This is an HIR version of [`rustc_middle::mir::Place`].
5962
#[derive(Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
@@ -67,7 +70,10 @@ pub struct Place<'tcx> {
6770
pub projections: Vec<Projection<'tcx>>,
6871
}
6972

70-
/// A `PlaceWithHirId` represents how a value is located in memory.
73+
/// A `PlaceWithHirId` represents how a value is located in memory. This does not
74+
/// always correspond to a syntactic place expression. For example, when
75+
/// processing a pattern, a `Place` can be used to refer to the sub-value
76+
/// currently being inspected.
7177
///
7278
/// This is an HIR version of [`rustc_middle::mir::Place`].
7379
#[derive(Clone, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]

compiler/rustc_mir_build/src/builder/scope.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ fn build_scope_drops<'tcx>(
14961496
// path, then don't generate the drop. (We only take this into
14971497
// account for non-unwind paths so as not to disturb the
14981498
// caching mechanism.)
1499-
if scope.moved_locals.iter().any(|&o| o == local) {
1499+
if scope.moved_locals.contains(&local) {
15001500
continue;
15011501
}
15021502

compiler/rustc_passes/src/entry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct EntryContext<'tcx> {
2424
}
2525

2626
fn entry_fn(tcx: TyCtxt<'_>, (): ()) -> Option<(DefId, EntryFnType)> {
27-
let any_exe = tcx.crate_types().iter().any(|ty| *ty == CrateType::Executable);
27+
let any_exe = tcx.crate_types().contains(&CrateType::Executable);
2828
if !any_exe {
2929
// No need to find a main function.
3030
return None;

compiler/rustc_session/src/utils.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,15 @@ pub fn extra_compiler_flags() -> Option<(Vec<String>, bool)> {
149149
arg[a.len()..].to_string()
150150
};
151151
let option = content.split_once('=').map(|s| s.0).unwrap_or(&content);
152-
if ICE_REPORT_COMPILER_FLAGS_EXCLUDE.iter().any(|exc| option == *exc) {
152+
if ICE_REPORT_COMPILER_FLAGS_EXCLUDE.contains(&option) {
153153
excluded_cargo_defaults = true;
154154
} else {
155155
result.push(a.to_string());
156-
match ICE_REPORT_COMPILER_FLAGS_STRIP_VALUE.iter().find(|s| option == **s) {
157-
Some(s) => result.push(format!("{s}=[REDACTED]")),
158-
None => result.push(content),
159-
}
156+
result.push(if ICE_REPORT_COMPILER_FLAGS_STRIP_VALUE.contains(&option) {
157+
format!("{option}=[REDACTED]")
158+
} else {
159+
content
160+
});
160161
}
161162
}
162163
}

compiler/rustc_span/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ impl Span {
876876
self.ctxt()
877877
.outer_expn_data()
878878
.allow_internal_unstable
879-
.is_some_and(|features| features.iter().any(|&f| f == feature))
879+
.is_some_and(|features| features.contains(&feature))
880880
}
881881

882882
/// Checks if this span arises from a compiler desugaring of kind `kind`.

0 commit comments

Comments
 (0)