Rollup merge of #94011 - est31:let_else, r=lcnr

Even more let_else adoptions

Continuation of #89933, #91018, #91481, #93046, #93590.
This commit is contained in:
Matthias Krüger 2022-02-17 23:00:59 +01:00 committed by GitHub
commit 637d8b89e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 50 additions and 104 deletions

View file

@ -51,9 +51,7 @@ crate fn where_clauses(cx: &DocContext<'_>, clauses: Vec<WP>) -> Vec<WP> {
// Look for equality predicates on associated types that can be merged into
// general bound predicates
equalities.retain(|&(ref lhs, ref rhs)| {
let (self_, trait_did, name) = if let Some(p) = lhs.projection() {
p
} else {
let Some((self_, trait_did, name)) = lhs.projection() else {
return true;
};
let generic = match self_ {

View file

@ -236,9 +236,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {
let should_panic;
let ignore;
let edition;
let kind = if let Some(Event::Start(Tag::CodeBlock(kind))) = event {
kind
} else {
let Some(Event::Start(Tag::CodeBlock(kind))) = event else {
return event;
};

View file

@ -1752,9 +1752,7 @@ fn document_type_layout(w: &mut Buffer, cx: &Context<'_>, ty_def_id: DefId) {
<ul>",
);
let adt = if let Adt(adt, _) = ty_layout.ty.kind() {
adt
} else {
let Adt(adt, _) = ty_layout.ty.kind() else {
span_bug!(tcx.def_span(ty_def_id), "not an adt")
};

View file

@ -1226,9 +1226,7 @@ impl LinkCollector<'_, '_> {
let base_node =
if item.is_mod() && inner_docs { self.mod_ids.last().copied() } else { parent_node };
let mut module_id = if let Some(id) = base_node {
id
} else {
let Some(mut module_id) = base_node else {
// This is a bug.
debug!("attempting to resolve item without parent module: {}", path_str);
resolution_failure(
@ -1977,9 +1975,7 @@ fn resolution_failure(
// If so, report it and say the first which failed; if not, say the first path segment didn't resolve.
let mut name = path_str;
'outer: loop {
let (start, end) = if let Some(x) = split(name) {
x
} else {
let Some((start, end)) = split(name) else {
// avoid bug that marked [Quux::Z] as missing Z, not Quux
if partial_res.is_none() {
*unresolved = name.into();

View file

@ -152,9 +152,7 @@ where
}
hir::ExprKind::MethodCall(_, _, span) => {
let types = tcx.typeck(ex.hir_id.owner);
let def_id = if let Some(def_id) = types.type_dependent_def_id(ex.hir_id) {
def_id
} else {
let Some(def_id) = types.type_dependent_def_id(ex.hir_id) else {
trace!("type_dependent_def_id({}) = None", ex.hir_id);
return;
};

View file

@ -188,9 +188,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
debug!("maybe_inline_local res: {:?}", res);
let tcx = self.cx.tcx;
let res_did = if let Some(did) = res.opt_def_id() {
did
} else {
let Some(res_did) = res.opt_def_id() else {
return false;
};