parent
c32969d8e6
commit
ce78042a42
2 changed files with 15 additions and 3 deletions
|
@ -1534,15 +1534,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
hir::MatchSource::ForLoopDesugar,
|
hir::MatchSource::ForLoopDesugar,
|
||||||
));
|
));
|
||||||
|
|
||||||
let attrs: Vec<_> = e.attrs.iter().map(|a| self.lower_attr(a)).collect();
|
|
||||||
|
|
||||||
// This is effectively `{ let _result = ...; _result }`.
|
// This is effectively `{ let _result = ...; _result }`.
|
||||||
// The construct was introduced in #21984 and is necessary to make sure that
|
// 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
|
// 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.
|
// surrounding scope of the `match` since the `match` is not a terminating scope.
|
||||||
//
|
//
|
||||||
// Also, add the attributes to the outer returned expr node.
|
// 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:
|
/// Desugar `ExprKind::Try` from: `<expr>?` into:
|
||||||
|
|
14
src/test/ui/lowering/issue-96847.rs
Normal file
14
src/test/ui/lowering/issue-96847.rs
Normal file
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue