1
Fork 0

fix tests

This commit is contained in:
yukang 2023-03-15 07:10:59 +08:00
parent a4453c20ca
commit f54489978d
20 changed files with 76 additions and 135 deletions

View file

@ -238,7 +238,6 @@ impl<'a> DerefMut for SnapshotParser<'a> {
impl<'a> Parser<'a> {
#[rustc_lint_diagnostics]
#[track_caller]
pub fn struct_span_err<S: Into<MultiSpan>>(
&self,
sp: S,

View file

@ -294,17 +294,6 @@ impl<'a> Parser<'a> {
continue;
}
// Special cases:
if op.node == AssocOp::As {
lhs = self.parse_assoc_op_cast(lhs, lhs_span, ExprKind::Cast)?;
continue;
} else if op.node == AssocOp::DotDot || op.node == AssocOp::DotDotEq {
// If we didn't have to handle `x..`/`x..=`, it would be pretty easy to
// generalise it to the Fixity::None code.
lhs = self.parse_expr_range(prec, lhs, op.node, cur_op_span)?;
break;
}
let op = op.node;
// Special cases:
if op == AssocOp::As {
@ -619,9 +608,7 @@ impl<'a> Parser<'a> {
token::Ident(..) if this.may_recover() && this.is_mistaken_not_ident_negation() => {
make_it!(this, attrs, |this, _| this.recover_not_expr(lo))
}
_ => {
return this.parse_expr_dot_or_call(Some(attrs));
}
_ => return this.parse_expr_dot_or_call(Some(attrs)),
}
}

View file

@ -828,11 +828,10 @@ impl<'a> Parser<'a> {
}
fn expect_any_with_type(&mut self, kets: &[&TokenKind], expect: TokenExpectType) -> bool {
let res = kets.iter().any(|k| match expect {
kets.iter().any(|k| match expect {
TokenExpectType::Expect => self.check(k),
TokenExpectType::NoExpect => self.token == **k,
});
res
})
}
fn parse_seq_to_before_tokens<T>(
@ -960,6 +959,7 @@ impl<'a> Parser<'a> {
let t = f(self)?;
v.push(t);
}
Ok((v, trailing, recovered))
}
@ -1045,7 +1045,6 @@ impl<'a> Parser<'a> {
f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>,
) -> PResult<'a, (ThinVec<T>, bool /* trailing */)> {
let (val, trailing, recovered) = self.parse_seq_to_before_end(ket, sep, f)?;
if !recovered {
self.eat(ket);
}

View file

@ -17,7 +17,7 @@ use thin_vec::ThinVec;
use tracing::debug;
/// Specifies how to parse a path.
#[derive(Copy, Clone, PartialEq, Debug)]
#[derive(Copy, Clone, PartialEq)]
pub enum PathStyle {
/// In some contexts, notably in expressions, paths with generic arguments are ambiguous
/// with something else. For example, in expressions `segment < ....` can be interpreted