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:
Ian Manske
2023-12-20 17:52:28 +00:00
committed by GitHub
parent 03ae01f11e
commit ff6a67d293
10 changed files with 3 additions and 47 deletions

View File

@ -44,7 +44,6 @@ pub enum Expr {
Overlay(Option<BlockId>), // block ID of the overlay's origin module
Signature(Box<Signature>),
StringInterpolation(Vec<Expression>),
MatchPattern(Box<MatchPattern>),
Spread(Box<Expression>),
Nothing,
Garbage,

View File

@ -221,7 +221,6 @@ impl Expression {
}
false
}
Expr::MatchPattern(_) => false,
Expr::Operator(_) => false,
Expr::MatchBlock(_) => false,
Expr::Range(left, middle, right, ..) => {
@ -407,7 +406,6 @@ impl Expression {
Expr::Nothing => {}
Expr::GlobPattern(_) => {}
Expr::Int(_) => {}
Expr::MatchPattern(_) => {}
Expr::MatchBlock(_) => {}
Expr::Keyword(_, _, expr) => expr.replace_in_variable(working_set, new_var_id),
Expr::List(list) => {
@ -576,7 +574,6 @@ impl Expression {
Expr::Garbage => {}
Expr::Nothing => {}
Expr::GlobPattern(_) => {}
Expr::MatchPattern(_) => {}
Expr::MatchBlock(_) => {}
Expr::Int(_) => {}
Expr::Keyword(_, _, expr) => expr.replace_span(working_set, replaced, new_span),

View File

@ -277,8 +277,7 @@ pub trait Eval {
Expr::GlobPattern(pattern) => {
Self::eval_glob_pattern(state, mut_state, pattern.clone(), expr.span)
}
Expr::MatchPattern(_) // match patterns are handled directly by commands
| Expr::MatchBlock(_) // match blocks are handled by `match`
Expr::MatchBlock(_) // match blocks are handled by `match`
| Expr::VarDecl(_)
| Expr::ImportPattern(_)
| Expr::Signature(_)

View File

@ -82,9 +82,6 @@ pub enum SyntaxShape {
/// A block of matches, used by `match`
MatchBlock,
/// A match pattern, eg `{a: $foo}`
MatchPattern,
/// Nothing
Nothing,
@ -163,7 +160,6 @@ impl SyntaxShape {
}
SyntaxShape::Keyword(_, expr) => expr.to_type(),
SyntaxShape::MatchBlock => Type::Any,
SyntaxShape::MatchPattern => Type::Any,
SyntaxShape::MathExpression => Type::Any,
SyntaxShape::Nothing => Type::Nothing,
SyntaxShape::Number => Type::Number,
@ -240,7 +236,6 @@ impl Display for SyntaxShape {
SyntaxShape::MathExpression => write!(f, "variable"),
SyntaxShape::VarWithOptType => write!(f, "vardecl"),
SyntaxShape::Signature => write!(f, "signature"),
SyntaxShape::MatchPattern => write!(f, "match-pattern"),
SyntaxShape::MatchBlock => write!(f, "match-block"),
SyntaxShape::Expression => write!(f, "expression"),
SyntaxShape::Boolean => write!(f, "bool"),

View File

@ -24,7 +24,6 @@ pub enum Type {
Int,
List(Box<Type>),
ListStream,
MatchPattern,
#[default]
Nothing,
Number,
@ -110,7 +109,6 @@ impl Type {
Type::Binary => SyntaxShape::Binary,
Type::Custom(_) => SyntaxShape::Any,
Type::Signature => SyntaxShape::Signature,
Type::MatchPattern => SyntaxShape::MatchPattern,
}
}
@ -131,7 +129,6 @@ impl Type {
Type::Record(_) => String::from("record"),
Type::Table(_) => String::from("table"),
Type::List(_) => String::from("list"),
Type::MatchPattern => String::from("match-pattern"),
Type::Nothing => String::from("nothing"),
Type::Number => String::from("number"),
Type::String => String::from("string"),
@ -198,7 +195,6 @@ impl Display for Type {
Type::Binary => write!(f, "binary"),
Type::Custom(custom) => write!(f, "{custom}"),
Type::Signature => write!(f, "signature"),
Type::MatchPattern => write!(f, "match-pattern"),
}
}
}