Skip to content

Commit

Permalink
Rollup merge of rust-lang#100307 - nnethercote:fix-96847, r=cjgillot
Browse files Browse the repository at this point in the history
Fix rust-lang#96847

r? `@petrochenkov`
  • Loading branch information
matthiaskrgr authored Aug 11, 2022
2 parents bd64d67 + ce78042 commit e221aaf
Show file tree
Hide file tree
Showing 23 changed files with 17 additions and 5 deletions.
4 changes: 1 addition & 3 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1536,15 +1536,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
hir::MatchSource::ForLoopDesugar,
));

let attrs: Vec<_> = e.attrs.iter().map(|a| self.lower_attr(a)).collect();

// This is effectively `{ let _result = ...; _result }`.
// The construct was introduced in #21984 and is necessary to make sure that
// temporaries in the `head` expression are dropped and do not leak to the
// surrounding scope of the `match` since the `match` is not a terminating scope.
//
// Also, add the attributes to the outer returned expr node.
self.expr_drop_temps_mut(for_span, match_expr, attrs.into())
self.expr_drop_temps_mut(for_span, match_expr, e.attrs.clone())
}

/// Desugar `ExprKind::Try` from: `<expr>?` into:
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/json-multiple.stderr

This file was deleted.

1 change: 0 additions & 1 deletion src/test/ui/json-options.stderr

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/test/ui/json/json-multiple.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"artifact":"$TEST_BUILD_DIR/json/json-multiple/libjson_multiple.rlib","emit":"link"}
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/test/ui/json/json-options.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"artifact":"$TEST_BUILD_DIR/json/json-options/libjson_options.rlib","emit":"link"}
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions src/test/ui/lowering/issue-96847.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// run-pass

// Test that this doesn't abort during AST lowering. In #96847 it did abort
// because the attribute was being lowered twice.

#![feature(stmt_expr_attributes)]
#![feature(lang_items)]

fn main() {
for _ in [1,2,3] {
#![lang="foo"]
println!("foo");
}
}

0 comments on commit e221aaf

Please sign in to comment.