diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-09-30 02:36:08 +0200 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-09-30 04:36:57 +0200 |
| commit | 4306d0037e961825abc08bfa39af0b64d1ed52aa (patch) | |
| tree | 038c884c44afce24f5b1403516fbc35090efabf1 /src/libsyntax/parse/parser | |
| parent | ac454e9af9389bb41a06ab620599771dcb2e59b6 (diff) | |
| download | rust-4306d0037e961825abc08bfa39af0b64d1ed52aa.tar.gz rust-4306d0037e961825abc08bfa39af0b64d1ed52aa.zip | |
syntax refactor `parse_self_param` (4)
Diffstat (limited to 'src/libsyntax/parse/parser')
| -rw-r--r-- | src/libsyntax/parse/parser/ty.rs | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/libsyntax/parse/parser/ty.rs b/src/libsyntax/parse/parser/ty.rs index c52d3733b5e..41ee2a1599d 100644 --- a/src/libsyntax/parse/parser/ty.rs +++ b/src/libsyntax/parse/parser/ty.rs @@ -231,11 +231,7 @@ impl<'a> Parser<'a> { } fn parse_ptr(&mut self) -> PResult<'a, MutTy> { - let mutbl = if self.eat_keyword(kw::Mut) { - Mutability::Mutable - } else if self.eat_keyword(kw::Const) { - Mutability::Immutable - } else { + let mutbl = self.parse_const_or_mut().unwrap_or_else(|| { let span = self.prev_span; let msg = "expected mut or const in raw pointer type"; self.struct_span_err(span, msg) @@ -243,7 +239,7 @@ impl<'a> Parser<'a> { .help("use `*mut T` or `*const T` as appropriate") .emit(); Mutability::Immutable - }; + }); let t = self.parse_ty_no_plus()?; Ok(MutTy { ty: t, mutbl }) } |
