about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_ast_lowering/src/block.rs1
-rw-r--r--src/test/ui/let-else/let-else-allow-unused.rs14
2 files changed, 15 insertions, 0 deletions
diff --git a/compiler/rustc_ast_lowering/src/block.rs b/compiler/rustc_ast_lowering/src/block.rs
index 4eab936f85f..082c5bb7833 100644
--- a/compiler/rustc_ast_lowering/src/block.rs
+++ b/compiler/rustc_ast_lowering/src/block.rs
@@ -152,6 +152,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
             let block = self.lower_block(els, false);
             self.arena.alloc(self.expr_block(block, AttrVec::new()))
         };
+        self.alias_attrs(let_expr.hir_id, local_hir_id);
         self.alias_attrs(else_expr.hir_id, local_hir_id);
         let if_expr = self.arena.alloc(hir::Expr {
             hir_id: stmt_hir_id,
diff --git a/src/test/ui/let-else/let-else-allow-unused.rs b/src/test/ui/let-else/let-else-allow-unused.rs
new file mode 100644
index 00000000000..bcd8c987628
--- /dev/null
+++ b/src/test/ui/let-else/let-else-allow-unused.rs
@@ -0,0 +1,14 @@
+// check-pass
+// issue #89807
+
+#![feature(let_else)]
+
+#[deny(unused_variables)]
+
+fn main() {
+    let value = Some(String::new());
+    #[allow(unused)]
+    let banana = 1;
+    #[allow(unused)]
+    let Some(chaenomeles) = value else { return }; // OK
+}