diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2023-01-31 23:38:52 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-31 23:38:52 +0100 |
| commit | 53bb6322dbc80d8a7da69e1ea4dbff98c4a70abb (patch) | |
| tree | cdfff407398d47f6a151da0c7dcf965c7c6f031c /compiler/rustc_parse/src/parser/ty.rs | |
| parent | c6a104f3e4266cb9f369b7edbc58520ca43f911e (diff) | |
| parent | 340414ed7bbcdd28a6a5baa0e3229c07029387b4 (diff) | |
| download | rust-53bb6322dbc80d8a7da69e1ea4dbff98c4a70abb.tar.gz rust-53bb6322dbc80d8a7da69e1ea4dbff98c4a70abb.zip | |
Rollup merge of #107467 - WaffleLapkin:uneq, r=oli-obk
Improve enum checks Some light refactoring.
Diffstat (limited to 'compiler/rustc_parse/src/parser/ty.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/ty.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index 82d9138c7a3..8b4f0ab8feb 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -323,13 +323,14 @@ impl<'a> Parser<'a> { } else if self.can_begin_bound() { self.parse_bare_trait_object(lo, allow_plus)? } else if self.eat(&token::DotDotDot) { - if allow_c_variadic == AllowCVariadic::Yes { - TyKind::CVarArgs - } else { - // FIXME(Centril): Should we just allow `...` syntactically - // anywhere in a type and use semantic restrictions instead? - self.error_illegal_c_varadic_ty(lo); - TyKind::Err + match allow_c_variadic { + AllowCVariadic::Yes => TyKind::CVarArgs, + AllowCVariadic::No => { + // FIXME(Centril): Should we just allow `...` syntactically + // anywhere in a type and use semantic restrictions instead? + self.error_illegal_c_varadic_ty(lo); + TyKind::Err + } } } else { let msg = format!("expected type, found {}", super::token_descr(&self.token)); @@ -343,10 +344,9 @@ impl<'a> Parser<'a> { let mut ty = self.mk_ty(span, kind); // Try to recover from use of `+` with incorrect priority. - if allow_plus == AllowPlus::Yes { - self.maybe_recover_from_bad_type_plus(&ty)?; - } else { - self.maybe_report_ambiguous_plus(impl_dyn_multi, &ty); + match allow_plus { + AllowPlus::Yes => self.maybe_recover_from_bad_type_plus(&ty)?, + AllowPlus::No => self.maybe_report_ambiguous_plus(impl_dyn_multi, &ty), } if RecoverQuestionMark::Yes == recover_question_mark { ty = self.maybe_recover_from_question_mark(ty); |
