let-else: fix attribute aliasing + add test for issue 89807
This commit is contained in:
parent
af2f0e6b7c
commit
9b45713b6c
2 changed files with 15 additions and 0 deletions
|
@ -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,
|
||||
|
|
14
src/test/ui/let-else/let-else-allow-unused.rs
Normal file
14
src/test/ui/let-else/let-else-allow-unused.rs
Normal 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
|
||||
}
|
Loading…
Add table
Reference in a new issue