Skip to content

Commit

Permalink
Auto merge of #94103 - matthiaskrgr:rollup-cd70ofn, r=matthiaskrgr
Browse files Browse the repository at this point in the history
Rollup of 9 pull requests

Successful merges:

 - #93337 (Update tracking issue numbers for inline assembly sub-features)
 - #93758 (Improve comments about type folding/visiting.)
 - #93780 (Generate list instead of div items in sidebar)
 - #93976 (Add MAIN_SEPARATOR_STR)
 - #94011 (Even more let_else adoptions)
 - #94041 (Add a `try_collect()` helper method to `Iterator`)
 - #94043 (Fix ICE when using Box<T, A> with pointer sized A)
 - #94082 (Remove CFG_PLATFORM)
 - #94085 (Clippy: Don't lint `needless_borrow` in method receiver positions)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Feb 17, 2022
2 parents 30b3f35 + 39c1748 commit 73a7423
Show file tree
Hide file tree
Showing 67 changed files with 499 additions and 416 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,9 @@ trait TypeOpInfo<'tcx> {
let tcx = mbcx.infcx.tcx;
let base_universe = self.base_universe();

let adjusted_universe = if let Some(adjusted) =
let Some(adjusted_universe) =
placeholder.universe.as_u32().checked_sub(base_universe.as_u32())
{
adjusted
} else {
else {
mbcx.buffer_error(self.fallback_error(tcx, cause.span));
return;
};
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -867,15 +867,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
kind: TerminatorKind::Call { fn_span, from_hir_call, .. }, ..
}) = &self.body[location.block].terminator
{
let (method_did, method_substs) = if let Some(info) =
let Some((method_did, method_substs)) =
rustc_const_eval::util::find_self_call(
self.infcx.tcx,
&self.body,
target_temp,
location.block,
) {
info
} else {
)
else {
return normal_ret;
};

Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,11 +639,9 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
let hir_map = self.infcx.tcx.hir();
let my_def = self.body.source.def_id();
let my_hir = hir_map.local_def_id_to_hir_id(my_def.as_local().unwrap());
let td = if let Some(a) =
let Some(td) =
self.infcx.tcx.impl_of_method(my_def).and_then(|x| self.infcx.tcx.trait_id_of_impl(x))
{
a
} else {
else {
return (false, None);
};
(
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_builtin_macros/src/concat_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use rustc_expand::base::{self, DummyResult};

/// Emits errors for literal expressions that are invalid inside and outside of an array.
fn invalid_type_err(cx: &mut base::ExtCtxt<'_>, expr: &P<rustc_ast::Expr>, is_nested: bool) {
let lit = if let ast::ExprKind::Lit(lit) = &expr.kind {
lit
} else {
let ast::ExprKind::Lit(lit) = &expr.kind else {
unreachable!();
};
match lit.kind {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_builtin_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#![feature(decl_macro)]
#![feature(is_sorted)]
#![feature(nll)]
#![feature(let_else)]
#![feature(proc_macro_internals)]
#![feature(proc_macro_quote)]
#![recursion_limit = "256"]
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_codegen_llvm/src/type_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,9 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
ty::Ref(..) | ty::RawPtr(_) => {
return self.field(cx, index).llvm_type(cx);
}
ty::Adt(def, _) if def.is_box() => {
// only wide pointer boxes are handled as pointers
// thin pointer boxes with scalar allocators are handled by the general logic below
ty::Adt(def, substs) if def.is_box() && cx.layout_of(substs.type_at(1)).is_zst() => {
let ptr_ty = cx.tcx.mk_mut_ptr(self.ty.boxed_ty());
return cx.layout_of(ptr_ty).scalar_pair_element_llvm_type(cx, index, immediate);
}
Expand Down
21 changes: 11 additions & 10 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,18 @@ pub fn each_linked_rlib(
}
let name = &info.crate_name[&cnum];
let used_crate_source = &info.used_crate_source[&cnum];
let path = if let Some((path, _)) = &used_crate_source.rlib {
path
} else if used_crate_source.rmeta.is_some() {
return Err(format!(
"could not find rlib for: `{}`, found rmeta (metadata) file",
name
));
if let Some((path, _)) = &used_crate_source.rlib {
f(cnum, &path);
} else {
return Err(format!("could not find rlib for: `{}`", name));
};
f(cnum, &path);
if used_crate_source.rmeta.is_some() {
return Err(format!(
"could not find rlib for: `{}`, found rmeta (metadata) file",
name
));
} else {
return Err(format!("could not find rlib for: `{}`", name));
}
}
}
Ok(())
}
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_codegen_ssa/src/back/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,7 @@ fn create_object_file(sess: &Session) -> Option<write::Object<'static>> {
// `SHF_EXCLUDE` flag we can set on sections in an object file to get
// automatically removed from the final output.
pub fn create_rmeta_file(sess: &Session, metadata: &[u8]) -> Vec<u8> {
let mut file = if let Some(file) = create_object_file(sess) {
file
} else {
let Some(mut file) = create_object_file(sess) else {
// This is used to handle all "other" targets. This includes targets
// in two categories:
//
Expand Down Expand Up @@ -262,9 +260,7 @@ pub fn create_compressed_metadata_file(
) -> Vec<u8> {
let mut compressed = rustc_metadata::METADATA_HEADER.to_vec();
FrameEncoder::new(&mut compressed).write_all(metadata.raw_data()).unwrap();
let mut file = if let Some(file) = create_object_file(sess) {
file
} else {
let Some(mut file) = create_object_file(sess) else {
return compressed.to_vec();
};
let section = file.add_section(
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,13 @@ declare_features! (
/// Allows trait methods with arbitrary self types.
(active, arbitrary_self_types, "1.23.0", Some(44874), None),
/// Allows using `const` operands in inline assembly.
(active, asm_const, "1.58.0", Some(72016), None),
(active, asm_const, "1.58.0", Some(93332), None),
/// Enables experimental inline assembly support for additional architectures.
(active, asm_experimental_arch, "1.58.0", Some(72016), None),
(active, asm_experimental_arch, "1.58.0", Some(93335), None),
/// Allows using `sym` operands in inline assembly.
(active, asm_sym, "1.58.0", Some(72016), None),
(active, asm_sym, "1.58.0", Some(93333), None),
/// Allows the `may_unwind` option in inline assembly.
(active, asm_unwind, "1.58.0", Some(72016), None),
(active, asm_unwind, "1.58.0", Some(93334), None),
/// Allows users to enforce equality of associated constants `TraitImpl<AssocConst=3>`.
(active, associated_const_equality, "1.58.0", Some(92827), None),
/// Allows the user of associated type bounds.
Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_index/src/bit_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,11 +852,7 @@ impl<T: Idx> HybridBitSet<T> {
Bound::Excluded(end) => end.index(),
Bound::Unbounded => self.domain_size() - 1,
};
let len = if let Some(l) = end.checked_sub(start) {
l
} else {
return;
};
let Some(len) = end.checked_sub(start) else { return };
match self {
HybridBitSet::Sparse(sparse) if sparse.len() + len < SPARSE_MAX => {
// The set is sparse and has space for `elems`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
let ty_msg = match (local_visitor.found_node_ty, local_visitor.found_exact_method_call) {
(_, Some(_)) => String::new(),
(Some(ty), _) if ty.is_closure() => {
let substs =
if let ty::Closure(_, substs) = *ty.kind() { substs } else { unreachable!() };
let ty::Closure(_, substs) = *ty.kind() else { unreachable!() };
let fn_sig = substs.as_closure().sig();
let args = closure_args(&fn_sig);
let ret = fn_sig.output().skip_binder().to_string();
Expand Down Expand Up @@ -597,8 +596,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
let param_type = arg_data.kind.descr();
let suffix = match local_visitor.found_node_ty {
Some(ty) if ty.is_closure() => {
let substs =
if let ty::Closure(_, substs) = *ty.kind() { substs } else { unreachable!() };
let ty::Closure(_, substs) = *ty.kind() else { unreachable!() };
let fn_sig = substs.as_closure().sig();
let ret = fn_sig.output().skip_binder().to_string();

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
for local_id in hir.iter_local_def_id() {
let def_id = local_id.to_def_id();
let def_kind = tcx.opt_def_kind(local_id);
let def_kind = if let Some(def_kind) = def_kind { def_kind } else { continue };
let Some(def_kind) = def_kind else { continue };
record!(self.tables.def_kind[def_id] <- match def_kind {
// Replace Ctor by the enclosing object to avoid leaking details in children crates.
DefKind::Ctor(CtorOf::Struct, _) => DefKind::Struct,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/dep_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl rustc_query_system::dep_graph::DepKind for DepKind {
OP: for<'a> FnOnce(TaskDepsRef<'a>),
{
ty::tls::with_context_opt(|icx| {
let icx = if let Some(icx) = icx { icx } else { return };
let Some(icx) = icx else { return };
op(icx.task_deps)
})
}
Expand Down
Loading

0 comments on commit 73a7423

Please sign in to comment.