Skip to content

Commit

Permalink
let-else: fix attribute aliasing + add test for issue 89807
Browse files Browse the repository at this point in the history
  • Loading branch information
cormacrelf committed Dec 13, 2021
1 parent af2f0e6 commit 9b45713
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_ast_lowering/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 14 additions & 0 deletions src/test/ui/let-else/let-else-allow-unused.rs
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 9b45713

Please sign in to comment.