MCPcopy Create free account
hub / github.com/astral-sh/ruff / parse_match_pattern_target

Method parse_match_pattern_target

crates/ruff_python_parser/src/parser/pattern.rs:292–303  ·  view source on GitHub ↗

Parses a binding target in an `as` or mapping pattern.

(&mut self)

Source from the content-addressed store, hash-verified

290
291 /// Parses a binding target in an `as` or mapping pattern.
292 fn parse_match_pattern_target(&mut self) -> ast::Identifier {
293 // test_err invalid_match_pattern_target
294 // match value:
295 // case 1 as _: ...
296 // case {**_}: ...
297 // after = 1
298 let identifier = self.parse_identifier();
299 if identifier.is_valid() && identifier.id == "_" {
300 self.add_error(ParseErrorType::InvalidMatchPatternTarget, &identifier);
301 }
302 identifier
303 }
304
305 /// Parses a parenthesized pattern or a sequence pattern.
306 ///

Callers 2

parse_match_patternMethod · 0.80

Calls 3

parse_identifierMethod · 0.80
is_validMethod · 0.80
add_errorMethod · 0.45

Tested by

no test coverage detected