Take a slice in stmt_let_pat.
This commit is contained in:
parent
1fb257b3b4
commit
4a21af67e3
3 changed files with 16 additions and 9 deletions
|
@ -1026,7 +1026,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
|
|
||||||
// Introduce a `let` for destructuring: `let (lhs1, lhs2) = t`.
|
// Introduce a `let` for destructuring: `let (lhs1, lhs2) = t`.
|
||||||
let destructure_let = self.stmt_let_pat(
|
let destructure_let = self.stmt_let_pat(
|
||||||
ThinVec::new(),
|
&[],
|
||||||
whole_span,
|
whole_span,
|
||||||
Some(rhs),
|
Some(rhs),
|
||||||
pat,
|
pat,
|
||||||
|
@ -1785,7 +1785,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
|
|
||||||
// `let mut __next`
|
// `let mut __next`
|
||||||
let next_let = self.stmt_let_pat(
|
let next_let = self.stmt_let_pat(
|
||||||
ThinVec::new(),
|
&[],
|
||||||
desugared_span,
|
desugared_span,
|
||||||
None,
|
None,
|
||||||
next_pat,
|
next_pat,
|
||||||
|
@ -1795,7 +1795,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
// `let <pat> = __next`
|
// `let <pat> = __next`
|
||||||
let pat = self.lower_pat(pat);
|
let pat = self.lower_pat(pat);
|
||||||
let pat_let = self.stmt_let_pat(
|
let pat_let = self.stmt_let_pat(
|
||||||
ThinVec::new(),
|
&[],
|
||||||
desugared_span,
|
desugared_span,
|
||||||
Some(next_expr),
|
Some(next_expr),
|
||||||
pat,
|
pat,
|
||||||
|
|
|
@ -1177,8 +1177,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
//
|
//
|
||||||
// If this is the simple case, this parameter will end up being the same as the
|
// If this is the simple case, this parameter will end up being the same as the
|
||||||
// original parameter, but with a different pattern id.
|
// original parameter, but with a different pattern id.
|
||||||
let mut stmt_attrs = AttrVec::new();
|
let stmt_attrs = this.attrs[parameter.hir_id];
|
||||||
stmt_attrs.extend(parameter.attrs.iter().cloned());
|
|
||||||
let (new_parameter_pat, new_parameter_id) = this.pat_ident(desugared_span, ident);
|
let (new_parameter_pat, new_parameter_id) = this.pat_ident(desugared_span, ident);
|
||||||
let new_parameter = hir::Param {
|
let new_parameter = hir::Param {
|
||||||
attrs: parameter.attrs,
|
attrs: parameter.attrs,
|
||||||
|
@ -1224,7 +1223,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
);
|
);
|
||||||
let move_expr = this.expr_ident(desugared_span, ident, new_parameter_id);
|
let move_expr = this.expr_ident(desugared_span, ident, new_parameter_id);
|
||||||
let move_stmt = this.stmt_let_pat(
|
let move_stmt = this.stmt_let_pat(
|
||||||
AttrVec::new(),
|
&[],
|
||||||
desugared_span,
|
desugared_span,
|
||||||
Some(move_expr),
|
Some(move_expr),
|
||||||
move_pat,
|
move_pat,
|
||||||
|
|
|
@ -2526,15 +2526,23 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
|
|
||||||
fn stmt_let_pat(
|
fn stmt_let_pat(
|
||||||
&mut self,
|
&mut self,
|
||||||
attrs: AttrVec,
|
attrs: &'hir [Attribute],
|
||||||
span: Span,
|
span: Span,
|
||||||
init: Option<&'hir hir::Expr<'hir>>,
|
init: Option<&'hir hir::Expr<'hir>>,
|
||||||
pat: &'hir hir::Pat<'hir>,
|
pat: &'hir hir::Pat<'hir>,
|
||||||
source: hir::LocalSource,
|
source: hir::LocalSource,
|
||||||
) -> hir::Stmt<'hir> {
|
) -> hir::Stmt<'hir> {
|
||||||
let hir_id = self.next_id();
|
let hir_id = self.next_id();
|
||||||
self.attrs.push_sparse(hir_id, &*self.arena.alloc_from_iter(attrs.iter().cloned()));
|
self.attrs.push_sparse(hir_id, attrs);
|
||||||
let local = hir::Local { attrs, hir_id, init, pat, source, span, ty: None };
|
let local = hir::Local {
|
||||||
|
attrs: attrs.iter().cloned().collect::<Vec<_>>().into(),
|
||||||
|
hir_id,
|
||||||
|
init,
|
||||||
|
pat,
|
||||||
|
source,
|
||||||
|
span,
|
||||||
|
ty: None,
|
||||||
|
};
|
||||||
self.stmt(span, hir::StmtKind::Local(self.arena.alloc(local)))
|
self.stmt(span, hir::StmtKind::Local(self.arena.alloc(local)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue