Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #94103

Merged
merged 20 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a62c9fa
Update tracking issue numbers for inline assembly sub-features
Amanieu Jan 26, 2022
ae32f43
fix assumption that ScalarPair Box is always a fat pointer
beepster4096 Feb 16, 2022
5136b54
Unify sidebar a bit more by generating a list using <ul> instead of <…
GuillaumeGomez Feb 8, 2022
0d928b6
Update rustdoc tests to adapt to changes to the sidebar
GuillaumeGomez Feb 8, 2022
60f969a
Adopt let_else in even more places
est31 Feb 15, 2022
47d5196
Add a `try_collect()` helper method to `Iterator`
a-lafrance Feb 16, 2022
d0b508e
add comment explaining the check
beepster4096 Feb 17, 2022
80fde23
Add MAIN_SEPARATOR_STR
SUPERCILEX Feb 13, 2022
94f0849
Improve comments about type folding/visiting.
nnethercote Feb 8, 2022
94fd78d
Remove CFG_PLATFORM
bjorn3 Feb 17, 2022
7fa0c20
Don't lint `needless_borrow` in method receiver positions
Jarcho Feb 17, 2022
6733170
Rollup merge of #93337 - Amanieu:asm_tracking, r=tmiasko
matthiaskrgr Feb 17, 2022
98c54c8
Rollup merge of #93758 - nnethercote:improve-folding-comments, r=BoxyUwU
matthiaskrgr Feb 17, 2022
6a2b612
Rollup merge of #93780 - GuillaumeGomez:links-in-sidebar, r=jsha
matthiaskrgr Feb 17, 2022
09350d2
Rollup merge of #93976 - SUPERCILEX:separator_str, r=yaahc
matthiaskrgr Feb 17, 2022
637d8b8
Rollup merge of #94011 - est31:let_else, r=lcnr
matthiaskrgr Feb 17, 2022
a4be35e
Rollup merge of #94041 - a-lafrance:try-collect, r=scottmcm
matthiaskrgr Feb 17, 2022
6dc62f4
Rollup merge of #94043 - DrMeepster:box_alloc_ice, r=oli-obk
matthiaskrgr Feb 17, 2022
e1bf069
Rollup merge of #94082 - bjorn3:remove_cfg_platform, r=Mark-Simulacrum
matthiaskrgr Feb 17, 2022
39c1748
Rollup merge of #94085 - flip1995:clippy_needless_borrow_temp_fix, r=…
matthiaskrgr Feb 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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