Skip to content

Commit 32ac9d0

Browse files
committed
pass attr as param in new methods
1 parent 4e01b70 commit 32ac9d0

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/librustc_parse/parser/expr.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -845,20 +845,20 @@ impl<'a> Parser<'a> {
845845
// could be removed without changing functionality, but it's faster
846846
// to have it here, especially for programs with large constants.
847847
token::Literal(_) => parse_lit!(),
848-
token::OpenDelim(token::Paren) => return self.parse_tuple_parens_expr(),
848+
token::OpenDelim(token::Paren) => return self.parse_tuple_parens_expr(attrs),
849849
token::OpenDelim(token::Brace) => {
850850
return self.parse_block_expr(None, lo, BlockCheckMode::Default, attrs);
851851
}
852852
token::BinOp(token::Or) | token::OrOr => return self.parse_closure_expr(attrs),
853-
token::OpenDelim(token::Bracket) => return self.parse_array_or_repeat_expr(),
853+
token::OpenDelim(token::Bracket) => return self.parse_array_or_repeat_expr(attrs),
854854
_ => {
855855
if self.eat_lt() {
856856
let (qself, path) = self.parse_qpath(PathStyle::Expr)?;
857857
let hi = path.span;
858858
return Ok(self.mk_expr(lo.to(hi), ExprKind::Path(Some(qself), path), attrs));
859859
}
860860
if self.token.is_path_start() {
861-
return self.parse_path_start_expr();
861+
return self.parse_path_start_expr(attrs);
862862
}
863863
if self.check_keyword(kw::Move) || self.check_keyword(kw::Static) {
864864
return self.parse_closure_expr(attrs);
@@ -979,14 +979,13 @@ impl<'a> Parser<'a> {
979979
self.maybe_recover_from_bad_qpath(expr, true)
980980
}
981981

982-
fn parse_tuple_parens_expr(&mut self) -> PResult<'a, P<Expr>> {
982+
fn parse_tuple_parens_expr(&mut self, mut attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
983983
let lo = self.token.span;
984984
let mut first = true;
985-
let mut attrs = ThinVec::new();
986985
let parse_leading_attr_expr = |p: &mut Self| {
987986
if first {
988987
// `(#![foo] a, b, ...)` is OK...
989-
attrs = p.parse_inner_attributes()?.into();
988+
attrs.extend(p.parse_inner_attributes()?);
990989
// ...but not `(a, #![foo] b, ...)`.
991990
first = false;
992991
}
@@ -1007,11 +1006,14 @@ impl<'a> Parser<'a> {
10071006
self.maybe_recover_from_bad_qpath(expr, true)
10081007
}
10091008

1010-
fn parse_array_or_repeat_expr(&mut self) -> PResult<'a, P<Expr>> {
1009+
fn parse_array_or_repeat_expr(
1010+
&mut self,
1011+
mut attrs: ThinVec<Attribute>,
1012+
) -> PResult<'a, P<Expr>> {
10111013
let lo = self.token.span;
10121014
self.bump(); // `[`
10131015

1014-
let attrs = self.parse_inner_attributes()?.into();
1016+
attrs.extend(self.parse_inner_attributes()?);
10151017

10161018
let kind = if self.eat(&token::CloseDelim(token::Bracket)) {
10171019
// Empty vector
@@ -1047,8 +1049,7 @@ impl<'a> Parser<'a> {
10471049
self.maybe_recover_from_bad_qpath(expr, true)
10481050
}
10491051

1050-
fn parse_path_start_expr(&mut self) -> PResult<'a, P<Expr>> {
1051-
let attrs = ThinVec::new();
1052+
fn parse_path_start_expr(&mut self, attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> {
10521053
let lo = self.token.span;
10531054
let path = self.parse_path(PathStyle::Expr)?;
10541055

0 commit comments

Comments
 (0)