Move condition out of maybe_recover_from_question_mark
.
This commit is contained in:
parent
1b422451ae
commit
a148a32fdc
@ -1,5 +1,5 @@
|
||||
use super::pat::Expected;
|
||||
use super::ty::{AllowPlus, RecoverQuestionMark};
|
||||
use super::ty::AllowPlus;
|
||||
use super::{
|
||||
BlockMode, CommaRecoveryMode, Parser, PathStyle, RecoverColon, RecoverComma, Restrictions,
|
||||
SemiColonMode, SeqSep, TokenExpectType, TokenType,
|
||||
@ -1248,14 +1248,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
|
||||
/// Swift lets users write `Ty?` to mean `Option<Ty>`. Parse the construct and recover from it.
|
||||
pub(super) fn maybe_recover_from_question_mark(
|
||||
&mut self,
|
||||
ty: P<Ty>,
|
||||
recover_question_mark: RecoverQuestionMark,
|
||||
) -> P<Ty> {
|
||||
if let RecoverQuestionMark::No = recover_question_mark {
|
||||
return ty;
|
||||
}
|
||||
pub(super) fn maybe_recover_from_question_mark(&mut self, ty: P<Ty>) -> P<Ty> {
|
||||
if self.token == token::Question {
|
||||
self.bump();
|
||||
self.struct_span_err(self.prev_token.span, "invalid `?` in type")
|
||||
|
@ -312,12 +312,14 @@ impl<'a> Parser<'a> {
|
||||
};
|
||||
|
||||
let span = lo.to(self.prev_token.span);
|
||||
let ty = self.mk_ty(span, kind);
|
||||
let mut ty = self.mk_ty(span, kind);
|
||||
|
||||
// Try to recover from use of `+` with incorrect priority.
|
||||
self.maybe_report_ambiguous_plus(allow_plus, impl_dyn_multi, &ty);
|
||||
self.maybe_recover_from_bad_type_plus(allow_plus, &ty)?;
|
||||
let ty = self.maybe_recover_from_question_mark(ty, recover_question_mark);
|
||||
if let RecoverQuestionMark::Yes = recover_question_mark {
|
||||
ty = self.maybe_recover_from_question_mark(ty);
|
||||
}
|
||||
if allow_qpath_recovery { self.maybe_recover_from_bad_qpath(ty) } else { Ok(ty) }
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user