Adopt let_else across the compiler
This performs a substitution of code following the pattern: let <id> = if let <pat> = ... { identity } else { ... : ! }; To simplify it to: let <pat> = ... { identity } else { ... : ! }; By adopting the let_else feature.
This commit is contained in:
parent
c1026539bd
commit
1418df5888
51 changed files with 69 additions and 137 deletions
|
@ -17,6 +17,7 @@
|
|||
#![feature(hash_drain_filter)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(let_else)]
|
||||
#![feature(never_type)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(control_flow_enum)]
|
||||
|
|
|
@ -1038,13 +1038,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
let hir = self.tcx.hir();
|
||||
let parent_node = hir.get_parent_node(obligation.cause.body_id);
|
||||
let node = hir.find(parent_node);
|
||||
let (sig, body_id) = if let Some(hir::Node::Item(hir::Item {
|
||||
let Some(hir::Node::Item(hir::Item {
|
||||
kind: hir::ItemKind::Fn(sig, _, body_id),
|
||||
..
|
||||
})) = node
|
||||
{
|
||||
(sig, body_id)
|
||||
} else {
|
||||
else {
|
||||
return false;
|
||||
};
|
||||
let body = hir.body(*body_id);
|
||||
|
|
|
@ -647,9 +647,7 @@ fn receiver_is_dispatchable<'tcx>(
|
|||
debug!("receiver_is_dispatchable: method = {:?}, receiver_ty = {:?}", method, receiver_ty);
|
||||
|
||||
let traits = (tcx.lang_items().unsize_trait(), tcx.lang_items().dispatch_from_dyn_trait());
|
||||
let (unsize_did, dispatch_from_dyn_did) = if let (Some(u), Some(cu)) = traits {
|
||||
(u, cu)
|
||||
} else {
|
||||
let (Some(unsize_did), Some(dispatch_from_dyn_did)) = traits else {
|
||||
debug!("receiver_is_dispatchable: Missing Unsize or DispatchFromDyn traits");
|
||||
return false;
|
||||
};
|
||||
|
|
|
@ -164,9 +164,7 @@ impl<'tcx> OnUnimplementedDirective {
|
|||
) -> Result<Option<Self>, ErrorReported> {
|
||||
let attrs = tcx.get_attrs(impl_def_id);
|
||||
|
||||
let attr = if let Some(item) = tcx.sess.find_by_name(&attrs, sym::rustc_on_unimplemented) {
|
||||
item
|
||||
} else {
|
||||
let Some(attr) = tcx.sess.find_by_name(&attrs, sym::rustc_on_unimplemented) else {
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
|
|
|
@ -716,9 +716,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
cause.clone(),
|
||||
);
|
||||
|
||||
let data = if let ty::Dynamic(ref data, ..) = normalized_ty.kind() {
|
||||
data
|
||||
} else {
|
||||
let ty::Dynamic(data, ..) = normalized_ty.kind() else {
|
||||
return None;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue