Skip to content

Commit e221aaf

Browse files
authored
Rollup merge of #100307 - nnethercote:fix-96847, r=cjgillot
Fix #96847 r? `@petrochenkov`
2 parents bd64d67 + ce78042 commit e221aaf

23 files changed

+17
-5
lines changed

compiler/rustc_ast_lowering/src/expr.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1536,15 +1536,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
15361536
hir::MatchSource::ForLoopDesugar,
15371537
));
15381538

1539-
let attrs: Vec<_> = e.attrs.iter().map(|a| self.lower_attr(a)).collect();
1540-
15411539
// This is effectively `{ let _result = ...; _result }`.
15421540
// The construct was introduced in #21984 and is necessary to make sure that
15431541
// temporaries in the `head` expression are dropped and do not leak to the
15441542
// surrounding scope of the `match` since the `match` is not a terminating scope.
15451543
//
15461544
// Also, add the attributes to the outer returned expr node.
1547-
self.expr_drop_temps_mut(for_span, match_expr, attrs.into())
1545+
self.expr_drop_temps_mut(for_span, match_expr, e.attrs.clone())
15481546
}
15491547

15501548
/// Desugar `ExprKind::Try` from: `<expr>?` into:

src/test/ui/json-multiple.stderr

-1
This file was deleted.

src/test/ui/json-options.stderr

-1
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/test/ui/json/json-multiple.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"artifact":"$TEST_BUILD_DIR/json/json-multiple/libjson_multiple.rlib","emit":"link"}
File renamed without changes.

src/test/ui/json/json-options.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"artifact":"$TEST_BUILD_DIR/json/json-options/libjson_options.rlib","emit":"link"}
File renamed without changes.
File renamed without changes.

src/test/ui/lowering/issue-96847.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
}

0 commit comments

Comments
 (0)