diff options
| author | n-salim <53019816+n-salim@users.noreply.github.com> | 2019-09-23 14:12:26 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-23 14:12:26 -0700 |
| commit | cd88dae21174f37aa47a45e4b848c4a5ececf19e (patch) | |
| tree | 196ef2334e2f7787737af02f2e78ed53c10fb5a8 /src/libsyntax/parse/parser/expr.rs | |
| parent | 494d83c89279a955dfb559ded5d5ac2ac06fc255 (diff) | |
| parent | 66bf391c3aabfc77f5f7139fc9e6944f995d574e (diff) | |
| download | rust-cd88dae21174f37aa47a45e4b848c4a5ececf19e.tar.gz rust-cd88dae21174f37aa47a45e4b848c4a5ececf19e.zip | |
Merge pull request #26 from rust-lang/master
Sync to rust-lang/rust master
Diffstat (limited to 'src/libsyntax/parse/parser/expr.rs')
| -rw-r--r-- | src/libsyntax/parse/parser/expr.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser/expr.rs b/src/libsyntax/parse/parser/expr.rs index 31b28443abb..d0c865a7b8e 100644 --- a/src/libsyntax/parse/parser/expr.rs +++ b/src/libsyntax/parse/parser/expr.rs @@ -66,6 +66,10 @@ pub(super) enum LhsExpr { } impl From<Option<ThinVec<Attribute>>> for LhsExpr { + /// Converts `Some(attrs)` into `LhsExpr::AttributesParsed(attrs)` + /// and `None` into `LhsExpr::NotYetParsed`. + /// + /// This conversion does not allocate. fn from(o: Option<ThinVec<Attribute>>) -> Self { if let Some(attrs) = o { LhsExpr::AttributesParsed(attrs) @@ -76,6 +80,9 @@ impl From<Option<ThinVec<Attribute>>> for LhsExpr { } impl From<P<Expr>> for LhsExpr { + /// Converts the `expr: P<Expr>` into `LhsExpr::AlreadyParsed(expr)`. + /// + /// This conversion does not allocate. fn from(expr: P<Expr>) -> Self { LhsExpr::AlreadyParsed(expr) } @@ -770,7 +777,7 @@ impl<'a> Parser<'a> { ex = ExprKind::Lit(literal); } Err(mut err) => { - self.cancel(&mut err); + err.cancel(); return Err(self.expected_expression_found()); } } @@ -1176,7 +1183,7 @@ impl<'a> Parser<'a> { /// Parses a parameter in a closure header (e.g., `|arg, arg|`). fn parse_fn_block_param(&mut self) -> PResult<'a, Param> { let lo = self.token.span; - let attrs = self.parse_param_attributes()?; + let attrs = self.parse_outer_attributes()?; let pat = self.parse_pat(PARAM_EXPECTED)?; let t = if self.eat(&token::Colon) { self.parse_ty()? |
