Skip to content

Commit 5e57faa

Browse files
committed
Auto merge of #93069 - matthiaskrgr:rollup-gx1vkp7, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #88642 (Formally implement let chains) - #89621 (doc: guarantee call order for sort_by_cached_key) - #91278 (Use iterator instead of recursion in `codegen_place`) - #92124 (Little improves in CString `new` when creating from slice) - #92783 (Annotate dead code lint with notes about ignored derived impls) - #92797 (Remove horizontal lines at top of page) - #92920 (Move expr- and item-related pretty printing functions to modules) - #93041 (Remove some unused ordering derivations based on `DefId`) - #93051 (Add Option::is_some_with and Result::is_{ok,err}_with) - #93062 (Update books) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2f004d2 + ea1275a commit 5e57faa

Some content is hidden

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

54 files changed

+2045
-1687
lines changed

compiler/rustc_ast_lowering/src/expr.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,20 @@ impl<'hir> LoweringContext<'_, 'hir> {
392392
// If `cond` kind is `let`, returns `let`. Otherwise, wraps and returns `cond`
393393
// in a temporary block.
394394
fn manage_let_cond(&mut self, cond: &'hir hir::Expr<'hir>) -> &'hir hir::Expr<'hir> {
395-
match cond.kind {
396-
hir::ExprKind::Let(..) => cond,
397-
_ => {
398-
let span_block =
399-
self.mark_span_with_reason(DesugaringKind::CondTemporary, cond.span, None);
400-
self.expr_drop_temps(span_block, cond, AttrVec::new())
395+
fn has_let_expr<'hir>(expr: &'hir hir::Expr<'hir>) -> bool {
396+
match expr.kind {
397+
hir::ExprKind::Binary(_, lhs, rhs) => has_let_expr(lhs) || has_let_expr(rhs),
398+
hir::ExprKind::Let(..) => true,
399+
_ => false,
401400
}
402401
}
402+
if has_let_expr(cond) {
403+
cond
404+
} else {
405+
let reason = DesugaringKind::CondTemporary;
406+
let span_block = self.mark_span_with_reason(reason, cond.span, None);
407+
self.expr_drop_temps(span_block, cond, AttrVec::new())
408+
}
403409
}
404410

405411
// We desugar: `'label: while $cond $body` into:

compiler/rustc_ast_passes/src/feature_gate.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -707,11 +707,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
707707
"`if let` guards are experimental",
708708
"you can write `if matches!(<expr>, <pattern>)` instead of `if let <pattern> = <expr>`"
709709
);
710-
gate_all!(
711-
let_chains,
712-
"`let` expressions in this position are experimental",
713-
"you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`"
714-
);
710+
gate_all!(let_chains, "`let` expressions in this position are unstable");
715711
gate_all!(
716712
async_closure,
717713
"async closures are unstable",

0 commit comments

Comments
 (0)