1
Fork 0

Rollup merge of #128376 - compiler-errors:finish-ur-vegetables, r=jieyouxu

Mark `Parser::eat`/`check` methods as `#[must_use]`

These methods return a `bool`, but we probably should either use these values or explicitly throw them away (e.g. when we just want to unconditionally eat a token if it exists).

I changed a few places from `eat` to `expect`, but otherwise I tried to leave a comment explaining why the `eat` was okay.

This also adds a test for the `pattern_type!` macro, which used to silently accept a missing `is` token.
This commit is contained in:
Matthias Krüger 2024-07-30 22:51:38 +02:00 committed by GitHub
commit 6f0b237c72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 51 additions and 18 deletions

View file

@ -24,7 +24,7 @@ fn parse_pat_ty<'a>(cx: &mut ExtCtxt<'a>, stream: TokenStream) -> PResult<'a, (P
let mut parser = cx.new_parser_from_tts(stream);
let ty = parser.parse_ty()?;
parser.eat_keyword(sym::is);
parser.expect_keyword(sym::is)?;
let pat = parser.parse_pat_no_top_alt(None, None)?;
Ok((ty, pat))