mirror of
https://github.com/nushell/nushell.git
synced 2025-07-01 07:00:37 +02:00
Remove Expr::MatchPattern
(#11367)
# Description Following from #11356, it looks like `Expr::MatchPattern` is no longer used in any way. This PR removes `Expr::MatchPattern` alongside `Type::MatchPattern` and `SyntaxShape::MatchPattern`. # User-Facing Changes Breaking API change for `nu_protocol`.
This commit is contained in:
@ -264,10 +264,6 @@ pub fn flatten_expression(
|
||||
Expr::Float(_) => {
|
||||
vec![(expr.span, FlatShape::Float)]
|
||||
}
|
||||
Expr::MatchPattern(pattern) => {
|
||||
// FIXME: do nicer flattening later
|
||||
flatten_pattern(pattern)
|
||||
}
|
||||
Expr::MatchBlock(matches) => {
|
||||
let mut output = vec![];
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
use nu_protocol::{
|
||||
ast::{Expr, Expression, MatchPattern, Pattern},
|
||||
ast::{MatchPattern, Pattern},
|
||||
engine::StateWorkingSet,
|
||||
ParseError, Span, SyntaxShape, Type, VarId,
|
||||
};
|
||||
@ -18,19 +18,6 @@ pub fn garbage(span: Span) -> MatchPattern {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_match_pattern(working_set: &mut StateWorkingSet, span: Span) -> Expression {
|
||||
working_set.enter_scope();
|
||||
let output = parse_pattern(working_set, span);
|
||||
working_set.exit_scope();
|
||||
|
||||
Expression {
|
||||
expr: Expr::MatchPattern(Box::new(output)),
|
||||
span,
|
||||
ty: Type::Any,
|
||||
custom_completion: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_pattern(working_set: &mut StateWorkingSet, span: Span) -> MatchPattern {
|
||||
let bytes = working_set.get_span_contents(span);
|
||||
|
||||
|
@ -2,7 +2,7 @@ use crate::{
|
||||
lex::{lex, lex_signature},
|
||||
lite_parser::{lite_parse, LiteCommand, LiteElement, LitePipeline},
|
||||
parse_mut,
|
||||
parse_patterns::{parse_match_pattern, parse_pattern},
|
||||
parse_patterns::parse_pattern,
|
||||
parse_shape_specs::{parse_shape_name, parse_type, ShapeDescriptorUse},
|
||||
type_check::{self, math_result_type, type_compatible},
|
||||
Token, TokenContents,
|
||||
@ -4475,10 +4475,6 @@ pub fn parse_value(
|
||||
_ => {}
|
||||
}
|
||||
|
||||
if matches!(shape, SyntaxShape::MatchPattern) {
|
||||
return parse_match_pattern(working_set, span);
|
||||
}
|
||||
|
||||
match bytes[0] {
|
||||
b'$' => return parse_dollar_expr(working_set, span),
|
||||
b'(' => return parse_paren_expr(working_set, span, shape),
|
||||
@ -4516,7 +4512,6 @@ pub fn parse_value(
|
||||
SyntaxShape::GlobPattern => parse_glob_pattern(working_set, span),
|
||||
SyntaxShape::String => parse_string(working_set, span),
|
||||
SyntaxShape::Binary => parse_binary(working_set, span),
|
||||
SyntaxShape::MatchPattern => parse_match_pattern(working_set, span),
|
||||
SyntaxShape::Signature => {
|
||||
if bytes.starts_with(b"[") {
|
||||
parse_signature(working_set, span)
|
||||
@ -5960,7 +5955,6 @@ pub fn discover_captures_in_expr(
|
||||
discover_captures_in_expr(working_set, expr, seen, seen_blocks, output)?;
|
||||
}
|
||||
}
|
||||
Expr::MatchPattern(_) => {}
|
||||
Expr::MatchBlock(match_block) => {
|
||||
for match_ in match_block {
|
||||
discover_captures_in_pattern(&match_.0, seen);
|
||||
|
Reference in New Issue
Block a user