Skip to content

Commit 4a21af6

Browse files
committed
Take a slice in stmt_let_pat.
1 parent 1fb257b commit 4a21af6

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10261026

10271027
// Introduce a `let` for destructuring: `let (lhs1, lhs2) = t`.
10281028
let destructure_let = self.stmt_let_pat(
1029-
ThinVec::new(),
1029+
&[],
10301030
whole_span,
10311031
Some(rhs),
10321032
pat,
@@ -1785,7 +1785,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
17851785

17861786
// `let mut __next`
17871787
let next_let = self.stmt_let_pat(
1788-
ThinVec::new(),
1788+
&[],
17891789
desugared_span,
17901790
None,
17911791
next_pat,
@@ -1795,7 +1795,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
17951795
// `let <pat> = __next`
17961796
let pat = self.lower_pat(pat);
17971797
let pat_let = self.stmt_let_pat(
1798-
ThinVec::new(),
1798+
&[],
17991799
desugared_span,
18001800
Some(next_expr),
18011801
pat,

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,8 +1177,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11771177
//
11781178
// If this is the simple case, this parameter will end up being the same as the
11791179
// original parameter, but with a different pattern id.
1180-
let mut stmt_attrs = AttrVec::new();
1181-
stmt_attrs.extend(parameter.attrs.iter().cloned());
1180+
let stmt_attrs = this.attrs[parameter.hir_id];
11821181
let (new_parameter_pat, new_parameter_id) = this.pat_ident(desugared_span, ident);
11831182
let new_parameter = hir::Param {
11841183
attrs: parameter.attrs,
@@ -1224,7 +1223,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12241223
);
12251224
let move_expr = this.expr_ident(desugared_span, ident, new_parameter_id);
12261225
let move_stmt = this.stmt_let_pat(
1227-
AttrVec::new(),
1226+
&[],
12281227
desugared_span,
12291228
Some(move_expr),
12301229
move_pat,

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,15 +2526,23 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
25262526

25272527
fn stmt_let_pat(
25282528
&mut self,
2529-
attrs: AttrVec,
2529+
attrs: &'hir [Attribute],
25302530
span: Span,
25312531
init: Option<&'hir hir::Expr<'hir>>,
25322532
pat: &'hir hir::Pat<'hir>,
25332533
source: hir::LocalSource,
25342534
) -> hir::Stmt<'hir> {
25352535
let hir_id = self.next_id();
2536-
self.attrs.push_sparse(hir_id, &*self.arena.alloc_from_iter(attrs.iter().cloned()));
2537-
let local = hir::Local { attrs, hir_id, init, pat, source, span, ty: None };
2536+
self.attrs.push_sparse(hir_id, attrs);
2537+
let local = hir::Local {
2538+
attrs: attrs.iter().cloned().collect::<Vec<_>>().into(),
2539+
hir_id,
2540+
init,
2541+
pat,
2542+
source,
2543+
span,
2544+
ty: None,
2545+
};
25382546
self.stmt(span, hir::StmtKind::Local(self.arena.alloc(local)))
25392547
}
25402548

0 commit comments

Comments
 (0)