Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #96847 #100307

Merged
merged 2 commits into from
Aug 12, 2022
Merged

Fix #96847 #100307

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1534,15 +1534,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.
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.
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");
}
}