(self, p: &Parser)
| 1375 | #[expect(clippy::inline_always, reason = "reduces list-parser branch misses")] |
| 1376 | #[inline(always)] |
| 1377 | fn is_list_element(self, p: &Parser) -> bool { |
| 1378 | match self { |
| 1379 | RecoveryContextKind::ModuleStatements => p.at_stmt(), |
| 1380 | RecoveryContextKind::BlockStatements => p.at_stmt(), |
| 1381 | RecoveryContextKind::Elif => p.at(TokenKind::Elif), |
| 1382 | RecoveryContextKind::Except => p.at(TokenKind::Except), |
| 1383 | RecoveryContextKind::AssignmentTargets => p.at(TokenKind::Equal), |
| 1384 | RecoveryContextKind::TypeParams => p.at_type_param(), |
| 1385 | RecoveryContextKind::ImportNames => p.at_name_or_soft_keyword(), |
| 1386 | RecoveryContextKind::ImportFromAsNames(_) => { |
| 1387 | p.at(TokenKind::Star) || p.at_name_or_soft_keyword() |
| 1388 | } |
| 1389 | RecoveryContextKind::Slices => p.at(TokenKind::Colon) || p.at_expr(), |
| 1390 | RecoveryContextKind::ListElements |
| 1391 | | RecoveryContextKind::SetElements |
| 1392 | | RecoveryContextKind::TupleElements(_) => p.at_expr(), |
| 1393 | RecoveryContextKind::DictElements => p.at(TokenKind::DoubleStar) || p.at_expr(), |
| 1394 | RecoveryContextKind::SequenceMatchPattern(_) => { |
| 1395 | // `+` doesn't start any pattern but is here for better error recovery. |
| 1396 | p.at(TokenKind::Plus) || p.at_pattern_start() |
| 1397 | } |
| 1398 | RecoveryContextKind::MatchPatternMapping => { |
| 1399 | // A star pattern is invalid as a mapping key and is here only for |
| 1400 | // better error recovery. |
| 1401 | p.at(TokenKind::Star) || p.at_mapping_pattern_start() |
| 1402 | } |
| 1403 | RecoveryContextKind::MatchPatternClassArguments => p.at_pattern_start(), |
| 1404 | RecoveryContextKind::Arguments => p.at_expr(), |
| 1405 | RecoveryContextKind::DeleteTargets => p.at_expr(), |
| 1406 | RecoveryContextKind::Identifiers => p.at_name_or_soft_keyword(), |
| 1407 | RecoveryContextKind::Parameters(_) => { |
| 1408 | matches!( |
| 1409 | p.current_token_kind(), |
| 1410 | TokenKind::Star | TokenKind::DoubleStar | TokenKind::Slash |
| 1411 | ) || p.at_name_or_soft_keyword() |
| 1412 | } |
| 1413 | RecoveryContextKind::WithItems(_) => p.at_expr(), |
| 1414 | RecoveryContextKind::InterpolatedStringElements(elements_kind) => match elements_kind { |
| 1415 | InterpolatedStringElementsKind::Regular(interpolated_string_kind) |
| 1416 | | InterpolatedStringElementsKind::FormatSpec(interpolated_string_kind) => { |
| 1417 | p.current_token_kind() == interpolated_string_kind.middle_token() |
| 1418 | || p.current_token_kind() == TokenKind::Lbrace |
| 1419 | } |
| 1420 | }, |
| 1421 | } |
| 1422 | } |
| 1423 | |
| 1424 | fn create_error(self, p: &Parser) -> ParseErrorType { |
| 1425 | match self { |
no test coverage detected