Skip to content

Commit 73a7423

Browse files
committed
Auto merge of rust-lang#94103 - matthiaskrgr:rollup-cd70ofn, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#93337 (Update tracking issue numbers for inline assembly sub-features) - rust-lang#93758 (Improve comments about type folding/visiting.) - rust-lang#93780 (Generate list instead of div items in sidebar) - rust-lang#93976 (Add MAIN_SEPARATOR_STR) - rust-lang#94011 (Even more let_else adoptions) - rust-lang#94041 (Add a `try_collect()` helper method to `Iterator`) - rust-lang#94043 (Fix ICE when using Box<T, A> with pointer sized A) - rust-lang#94082 (Remove CFG_PLATFORM) - rust-lang#94085 (Clippy: Don't lint `needless_borrow` in method receiver positions) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 30b3f35 + 39c1748 commit 73a7423

File tree

67 files changed

+499
-416
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+499
-416
lines changed

compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,9 @@ trait TypeOpInfo<'tcx> {
142142
let tcx = mbcx.infcx.tcx;
143143
let base_universe = self.base_universe();
144144

145-
let adjusted_universe = if let Some(adjusted) =
145+
let Some(adjusted_universe) =
146146
placeholder.universe.as_u32().checked_sub(base_universe.as_u32())
147-
{
148-
adjusted
149-
} else {
147+
else {
150148
mbcx.buffer_error(self.fallback_error(tcx, cause.span));
151149
return;
152150
};

compiler/rustc_borrowck/src/diagnostics/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -867,15 +867,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
867867
kind: TerminatorKind::Call { fn_span, from_hir_call, .. }, ..
868868
}) = &self.body[location.block].terminator
869869
{
870-
let (method_did, method_substs) = if let Some(info) =
870+
let Some((method_did, method_substs)) =
871871
rustc_const_eval::util::find_self_call(
872872
self.infcx.tcx,
873873
&self.body,
874874
target_temp,
875875
location.block,
876-
) {
877-
info
878-
} else {
876+
)
877+
else {
879878
return normal_ret;
880879
};
881880

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -639,11 +639,9 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
639639
let hir_map = self.infcx.tcx.hir();
640640
let my_def = self.body.source.def_id();
641641
let my_hir = hir_map.local_def_id_to_hir_id(my_def.as_local().unwrap());
642-
let td = if let Some(a) =
642+
let Some(td) =
643643
self.infcx.tcx.impl_of_method(my_def).and_then(|x| self.infcx.tcx.trait_id_of_impl(x))
644-
{
645-
a
646-
} else {
644+
else {
647645
return (false, None);
648646
};
649647
(

compiler/rustc_builtin_macros/src/concat_bytes.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ use rustc_expand::base::{self, DummyResult};
66

77
/// Emits errors for literal expressions that are invalid inside and outside of an array.
88
fn invalid_type_err(cx: &mut base::ExtCtxt<'_>, expr: &P<rustc_ast::Expr>, is_nested: bool) {
9-
let lit = if let ast::ExprKind::Lit(lit) = &expr.kind {
10-
lit
11-
} else {
9+
let ast::ExprKind::Lit(lit) = &expr.kind else {
1210
unreachable!();
1311
};
1412
match lit.kind {

compiler/rustc_builtin_macros/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#![feature(decl_macro)]
1010
#![feature(is_sorted)]
1111
#![feature(nll)]
12+
#![feature(let_else)]
1213
#![feature(proc_macro_internals)]
1314
#![feature(proc_macro_quote)]
1415
#![recursion_limit = "256"]

compiler/rustc_codegen_llvm/src/type_of.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,9 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
330330
ty::Ref(..) | ty::RawPtr(_) => {
331331
return self.field(cx, index).llvm_type(cx);
332332
}
333-
ty::Adt(def, _) if def.is_box() => {
333+
// only wide pointer boxes are handled as pointers
334+
// thin pointer boxes with scalar allocators are handled by the general logic below
335+
ty::Adt(def, substs) if def.is_box() && cx.layout_of(substs.type_at(1)).is_zst() => {
334336
let ptr_ty = cx.tcx.mk_mut_ptr(self.ty.boxed_ty());
335337
return cx.layout_of(ptr_ty).scalar_pair_element_llvm_type(cx, index, immediate);
336338
}

compiler/rustc_codegen_ssa/src/back/link.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,18 @@ pub fn each_linked_rlib(
216216
}
217217
let name = &info.crate_name[&cnum];
218218
let used_crate_source = &info.used_crate_source[&cnum];
219-
let path = if let Some((path, _)) = &used_crate_source.rlib {
220-
path
221-
} else if used_crate_source.rmeta.is_some() {
222-
return Err(format!(
223-
"could not find rlib for: `{}`, found rmeta (metadata) file",
224-
name
225-
));
219+
if let Some((path, _)) = &used_crate_source.rlib {
220+
f(cnum, &path);
226221
} else {
227-
return Err(format!("could not find rlib for: `{}`", name));
228-
};
229-
f(cnum, &path);
222+
if used_crate_source.rmeta.is_some() {
223+
return Err(format!(
224+
"could not find rlib for: `{}`, found rmeta (metadata) file",
225+
name
226+
));
227+
} else {
228+
return Err(format!("could not find rlib for: `{}`", name));
229+
}
230+
}
230231
}
231232
Ok(())
232233
}

compiler/rustc_codegen_ssa/src/back/metadata.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,7 @@ fn create_object_file(sess: &Session) -> Option<write::Object<'static>> {
200200
// `SHF_EXCLUDE` flag we can set on sections in an object file to get
201201
// automatically removed from the final output.
202202
pub fn create_rmeta_file(sess: &Session, metadata: &[u8]) -> Vec<u8> {
203-
let mut file = if let Some(file) = create_object_file(sess) {
204-
file
205-
} else {
203+
let Some(mut file) = create_object_file(sess) else {
206204
// This is used to handle all "other" targets. This includes targets
207205
// in two categories:
208206
//
@@ -262,9 +260,7 @@ pub fn create_compressed_metadata_file(
262260
) -> Vec<u8> {
263261
let mut compressed = rustc_metadata::METADATA_HEADER.to_vec();
264262
FrameEncoder::new(&mut compressed).write_all(metadata.raw_data()).unwrap();
265-
let mut file = if let Some(file) = create_object_file(sess) {
266-
file
267-
} else {
263+
let Some(mut file) = create_object_file(sess) else {
268264
return compressed.to_vec();
269265
};
270266
let section = file.add_section(

compiler/rustc_feature/src/active.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,13 @@ declare_features! (
285285
/// Allows trait methods with arbitrary self types.
286286
(active, arbitrary_self_types, "1.23.0", Some(44874), None),
287287
/// Allows using `const` operands in inline assembly.
288-
(active, asm_const, "1.58.0", Some(72016), None),
288+
(active, asm_const, "1.58.0", Some(93332), None),
289289
/// Enables experimental inline assembly support for additional architectures.
290-
(active, asm_experimental_arch, "1.58.0", Some(72016), None),
290+
(active, asm_experimental_arch, "1.58.0", Some(93335), None),
291291
/// Allows using `sym` operands in inline assembly.
292-
(active, asm_sym, "1.58.0", Some(72016), None),
292+
(active, asm_sym, "1.58.0", Some(93333), None),
293293
/// Allows the `may_unwind` option in inline assembly.
294-
(active, asm_unwind, "1.58.0", Some(72016), None),
294+
(active, asm_unwind, "1.58.0", Some(93334), None),
295295
/// Allows users to enforce equality of associated constants `TraitImpl<AssocConst=3>`.
296296
(active, associated_const_equality, "1.58.0", Some(92827), None),
297297
/// Allows the user of associated type bounds.

compiler/rustc_index/src/bit_set.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -852,11 +852,7 @@ impl<T: Idx> HybridBitSet<T> {
852852
Bound::Excluded(end) => end.index(),
853853
Bound::Unbounded => self.domain_size() - 1,
854854
};
855-
let len = if let Some(l) = end.checked_sub(start) {
856-
l
857-
} else {
858-
return;
859-
};
855+
let Some(len) = end.checked_sub(start) else { return };
860856
match self {
861857
HybridBitSet::Sparse(sparse) if sparse.len() + len < SPARSE_MAX => {
862858
// The set is sparse and has space for `elems`.

compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
553553
let ty_msg = match (local_visitor.found_node_ty, local_visitor.found_exact_method_call) {
554554
(_, Some(_)) => String::new(),
555555
(Some(ty), _) if ty.is_closure() => {
556-
let substs =
557-
if let ty::Closure(_, substs) = *ty.kind() { substs } else { unreachable!() };
556+
let ty::Closure(_, substs) = *ty.kind() else { unreachable!() };
558557
let fn_sig = substs.as_closure().sig();
559558
let args = closure_args(&fn_sig);
560559
let ret = fn_sig.output().skip_binder().to_string();
@@ -597,8 +596,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
597596
let param_type = arg_data.kind.descr();
598597
let suffix = match local_visitor.found_node_ty {
599598
Some(ty) if ty.is_closure() => {
600-
let substs =
601-
if let ty::Closure(_, substs) = *ty.kind() { substs } else { unreachable!() };
599+
let ty::Closure(_, substs) = *ty.kind() else { unreachable!() };
602600
let fn_sig = substs.as_closure().sig();
603601
let ret = fn_sig.output().skip_binder().to_string();
604602

compiler/rustc_metadata/src/rmeta/encoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
982982
for local_id in hir.iter_local_def_id() {
983983
let def_id = local_id.to_def_id();
984984
let def_kind = tcx.opt_def_kind(local_id);
985-
let def_kind = if let Some(def_kind) = def_kind { def_kind } else { continue };
985+
let Some(def_kind) = def_kind else { continue };
986986
record!(self.tables.def_kind[def_id] <- match def_kind {
987987
// Replace Ctor by the enclosing object to avoid leaking details in children crates.
988988
DefKind::Ctor(CtorOf::Struct, _) => DefKind::Struct,

compiler/rustc_middle/src/dep_graph/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl rustc_query_system::dep_graph::DepKind for DepKind {
6161
OP: for<'a> FnOnce(TaskDepsRef<'a>),
6262
{
6363
ty::tls::with_context_opt(|icx| {
64-
let icx = if let Some(icx) = icx { icx } else { return };
64+
let Some(icx) = icx else { return };
6565
op(icx.task_deps)
6666
})
6767
}

0 commit comments

Comments
 (0)