1
Fork 0

Take a slice in stmt_let_pat.

This commit is contained in:
Camille GILLOT 2021-01-04 21:50:45 +01:00
parent 1fb257b3b4
commit 4a21af67e3
3 changed files with 16 additions and 9 deletions

View file

@ -1026,7 +1026,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// Introduce a `let` for destructuring: `let (lhs1, lhs2) = t`.
let destructure_let = self.stmt_let_pat(
ThinVec::new(),
&[],
whole_span,
Some(rhs),
pat,
@ -1785,7 +1785,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// `let mut __next`
let next_let = self.stmt_let_pat(
ThinVec::new(),
&[],
desugared_span,
None,
next_pat,
@ -1795,7 +1795,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// `let <pat> = __next`
let pat = self.lower_pat(pat);
let pat_let = self.stmt_let_pat(
ThinVec::new(),
&[],
desugared_span,
Some(next_expr),
pat,

View file

@ -1177,8 +1177,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
//
// If this is the simple case, this parameter will end up being the same as the
// original parameter, but with a different pattern id.
let mut stmt_attrs = AttrVec::new();
stmt_attrs.extend(parameter.attrs.iter().cloned());
let stmt_attrs = this.attrs[parameter.hir_id];
let (new_parameter_pat, new_parameter_id) = this.pat_ident(desugared_span, ident);
let new_parameter = hir::Param {
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_stmt = this.stmt_let_pat(
AttrVec::new(),
&[],
desugared_span,
Some(move_expr),
move_pat,

View file

@ -2526,15 +2526,23 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
fn stmt_let_pat(
&mut self,
attrs: AttrVec,
attrs: &'hir [Attribute],
span: Span,
init: Option<&'hir hir::Expr<'hir>>,
pat: &'hir hir::Pat<'hir>,
source: hir::LocalSource,
) -> hir::Stmt<'hir> {
let hir_id = self.next_id();
self.attrs.push_sparse(hir_id, &*self.arena.alloc_from_iter(attrs.iter().cloned()));
let local = hir::Local { attrs, hir_id, init, pat, source, span, ty: None };
self.attrs.push_sparse(hir_id, attrs);
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)))
}