File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
compiler/rustc_ast_lowering/src Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -1534,15 +1534,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
15341534 hir:: MatchSource :: ForLoopDesugar ,
15351535 ) ) ;
15361536
1537- let attrs: Vec < _ > = e. attrs . iter ( ) . map ( |a| self . lower_attr ( a) ) . collect ( ) ;
1538-
15391537 // This is effectively `{ let _result = ...; _result }`.
15401538 // The construct was introduced in #21984 and is necessary to make sure that
15411539 // temporaries in the `head` expression are dropped and do not leak to the
15421540 // surrounding scope of the `match` since the `match` is not a terminating scope.
15431541 //
15441542 // Also, add the attributes to the outer returned expr node.
1545- self . expr_drop_temps_mut ( for_span, match_expr, attrs. into ( ) )
1543+ self . expr_drop_temps_mut ( for_span, match_expr, e . attrs . clone ( ) )
15461544 }
15471545
15481546 /// Desugar `ExprKind::Try` from: `<expr>?` into:
Original file line number Diff line number Diff line change 1+ // run-pass
2+
3+ // Test that this doesn't abort during AST lowering. In #96847 it did abort
4+ // because the attribute was being lowered twice.
5+
6+ #![ feature( stmt_expr_attributes) ]
7+ #![ feature( lang_items) ]
8+
9+ fn main ( ) {
10+ for _ in [ 1 , 2 , 3 ] {
11+ #![ lang="foo" ]
12+ println ! ( "foo" ) ;
13+ }
14+ }
You can’t perform that action at this time.
0 commit comments