diff --git a/src/librustc_parse/parser/ty.rs b/src/librustc_parse/parser/ty.rs index 716bdf7bb12..9ea5a88ddad 100644 --- a/src/librustc_parse/parser/ty.rs +++ b/src/librustc_parse/parser/ty.rs @@ -79,8 +79,7 @@ fn parse_ty_common( // Never type `!` TyKind::Never } else if self.eat(&token::BinOp(token::Star)) { - // Raw pointer - TyKind::Ptr(self.parse_ptr()?) + self.parse_ty_ptr()? } else if self.eat(&token::OpenDelim(token::Bracket)) { // Array or slice let t = self.parse_ty()?; @@ -251,7 +250,8 @@ fn parse_remaining_bounds(&mut self, generic_params: Vec, path: as Ok(TyKind::TraitObject(bounds, TraitObjectSyntax::None)) } - fn parse_ptr(&mut self) -> PResult<'a, MutTy> { + /// Parses a raw pointer type: `*[const | mut] $type`. + fn parse_ty_ptr(&mut self) -> PResult<'a, TyKind> { 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"; @@ -261,8 +261,8 @@ fn parse_ptr(&mut self) -> PResult<'a, MutTy> { .emit(); Mutability::Immutable }); - let t = self.parse_ty_no_plus()?; - Ok(MutTy { ty: t, mutbl }) + let ty = self.parse_ty_no_plus()?; + Ok(TyKind::Ptr(MutTy { ty, mutbl })) } fn maybe_parse_fixed_length_of_vec(&mut self) -> PResult<'a, Option>> {