let-else: fix attribute aliasing + add test for issue 89807

This commit is contained in:
Cormac Relf 2021-10-13 18:08:43 +11:00
parent af2f0e6b7c
commit 9b45713b6c
2 changed files with 15 additions and 0 deletions

View file

@ -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,

View file

@ -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
}