mirror of
https://github.com/nushell/nushell.git
synced 2025-05-30 06:39:33 +02:00
Remove unsued types (#14916)
# Description `Type::Block` and `Type::Signature` do not correspond to any `Value` cases and should be able to be removed.
This commit is contained in:
parent
e3e2554b3d
commit
c783b07d58
@ -353,7 +353,6 @@ fn nu_value_to_sqlite_type(val: &Value) -> Result<&'static str, ShellError> {
|
|||||||
|
|
||||||
// intentionally enumerated so that any future types get handled
|
// intentionally enumerated so that any future types get handled
|
||||||
Type::Any
|
Type::Any
|
||||||
| Type::Block
|
|
||||||
| Type::CellPath
|
| Type::CellPath
|
||||||
| Type::Closure
|
| Type::Closure
|
||||||
| Type::Custom(_)
|
| Type::Custom(_)
|
||||||
@ -361,7 +360,6 @@ fn nu_value_to_sqlite_type(val: &Value) -> Result<&'static str, ShellError> {
|
|||||||
| Type::List(_)
|
| Type::List(_)
|
||||||
| Type::Range
|
| Type::Range
|
||||||
| Type::Record(_)
|
| Type::Record(_)
|
||||||
| Type::Signature
|
|
||||||
| Type::Glob
|
| Type::Glob
|
||||||
| Type::Table(_) => Err(ShellError::OnlySupportsThisInputType {
|
| Type::Table(_) => Err(ShellError::OnlySupportsThisInputType {
|
||||||
exp_input_type: "sql".into(),
|
exp_input_type: "sql".into(),
|
||||||
|
@ -2259,7 +2259,7 @@ pub fn parse_module(
|
|||||||
module_comments.extend(inner_comments);
|
module_comments.extend(inner_comments);
|
||||||
let module_id = working_set.add_module(&module_name, module, module_comments);
|
let module_id = working_set.add_module(&module_name, module, module_comments);
|
||||||
|
|
||||||
let block_expr = Expression::new(working_set, Expr::Block(block_id), block_span, Type::Block);
|
let block_expr = Expression::new(working_set, Expr::Block(block_id), block_span, Type::Any);
|
||||||
|
|
||||||
let module_decl_id = working_set
|
let module_decl_id = working_set
|
||||||
.find_decl(b"module")
|
.find_decl(b"module")
|
||||||
|
@ -3498,7 +3498,7 @@ pub fn parse_signature(working_set: &mut StateWorkingSet, span: Span) -> Express
|
|||||||
|
|
||||||
let sig = parse_signature_helper(working_set, Span::new(start, end));
|
let sig = parse_signature_helper(working_set, Span::new(start, end));
|
||||||
|
|
||||||
Expression::new(working_set, Expr::Signature(sig), span, Type::Signature)
|
Expression::new(working_set, Expr::Signature(sig), span, Type::Any)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_signature_helper(working_set: &mut StateWorkingSet, span: Span) -> Box<Signature> {
|
pub fn parse_signature_helper(working_set: &mut StateWorkingSet, span: Span) -> Box<Signature> {
|
||||||
@ -4471,7 +4471,7 @@ pub fn parse_block_expression(working_set: &mut StateWorkingSet, span: Span) ->
|
|||||||
|
|
||||||
let block_id = working_set.add_block(Arc::new(output));
|
let block_id = working_set.add_block(Arc::new(output));
|
||||||
|
|
||||||
Expression::new(working_set, Expr::Block(block_id), span, Type::Block)
|
Expression::new(working_set, Expr::Block(block_id), span, Type::Any)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_match_block_expression(working_set: &mut StateWorkingSet, span: Span) -> Expression {
|
pub fn parse_match_block_expression(working_set: &mut StateWorkingSet, span: Span) -> Expression {
|
||||||
|
@ -55,7 +55,6 @@ pub fn type_compatible(lhs: &Type, rhs: &Type) -> bool {
|
|||||||
(Type::Int, Type::Number) => true,
|
(Type::Int, Type::Number) => true,
|
||||||
(Type::Number, Type::Float) => true,
|
(Type::Number, Type::Float) => true,
|
||||||
(Type::Float, Type::Number) => true,
|
(Type::Float, Type::Number) => true,
|
||||||
(Type::Closure, Type::Block) => true,
|
|
||||||
(Type::Any, _) => true,
|
(Type::Any, _) => true,
|
||||||
(_, Type::Any) => true,
|
(_, Type::Any) => true,
|
||||||
(Type::Record(lhs), Type::Record(rhs)) | (Type::Table(lhs), Type::Table(rhs)) => {
|
(Type::Record(lhs), Type::Record(rhs)) | (Type::Table(lhs), Type::Table(rhs)) => {
|
||||||
|
@ -143,7 +143,7 @@ impl SyntaxShape {
|
|||||||
|
|
||||||
match self {
|
match self {
|
||||||
SyntaxShape::Any => Type::Any,
|
SyntaxShape::Any => Type::Any,
|
||||||
SyntaxShape::Block => Type::Block,
|
SyntaxShape::Block => Type::Any,
|
||||||
SyntaxShape::Closure(_) => Type::Closure,
|
SyntaxShape::Closure(_) => Type::Closure,
|
||||||
SyntaxShape::Binary => Type::Binary,
|
SyntaxShape::Binary => Type::Binary,
|
||||||
SyntaxShape::CellPath => Type::Any,
|
SyntaxShape::CellPath => Type::Any,
|
||||||
@ -176,7 +176,7 @@ impl SyntaxShape {
|
|||||||
SyntaxShape::Record(entries) => Type::Record(mk_ty(entries)),
|
SyntaxShape::Record(entries) => Type::Record(mk_ty(entries)),
|
||||||
SyntaxShape::RowCondition => Type::Bool,
|
SyntaxShape::RowCondition => Type::Bool,
|
||||||
SyntaxShape::Boolean => Type::Bool,
|
SyntaxShape::Boolean => Type::Bool,
|
||||||
SyntaxShape::Signature => Type::Signature,
|
SyntaxShape::Signature => Type::Any,
|
||||||
SyntaxShape::String => Type::String,
|
SyntaxShape::String => Type::String,
|
||||||
SyntaxShape::Table(columns) => Type::Table(mk_ty(columns)),
|
SyntaxShape::Table(columns) => Type::Table(mk_ty(columns)),
|
||||||
SyntaxShape::VarWithOptType => Type::Any,
|
SyntaxShape::VarWithOptType => Type::Any,
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
|
use crate::SyntaxShape;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::fmt::Display;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use strum_macros::EnumIter;
|
use strum_macros::EnumIter;
|
||||||
|
|
||||||
use std::fmt::Display;
|
|
||||||
|
|
||||||
use crate::SyntaxShape;
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Hash)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Hash)]
|
||||||
#[cfg_attr(test, derive(EnumIter))]
|
#[cfg_attr(test, derive(EnumIter))]
|
||||||
pub enum Type {
|
pub enum Type {
|
||||||
Any,
|
Any,
|
||||||
Binary,
|
Binary,
|
||||||
Block,
|
|
||||||
Bool,
|
Bool,
|
||||||
CellPath,
|
CellPath,
|
||||||
Closure,
|
Closure,
|
||||||
@ -28,7 +25,6 @@ pub enum Type {
|
|||||||
Number,
|
Number,
|
||||||
Range,
|
Range,
|
||||||
Record(Box<[(String, Type)]>),
|
Record(Box<[(String, Type)]>),
|
||||||
Signature,
|
|
||||||
String,
|
String,
|
||||||
Glob,
|
Glob,
|
||||||
Table(Box<[(String, Type)]>),
|
Table(Box<[(String, Type)]>),
|
||||||
@ -113,7 +109,6 @@ impl Type {
|
|||||||
Type::Range => SyntaxShape::Range,
|
Type::Range => SyntaxShape::Range,
|
||||||
Type::Bool => SyntaxShape::Boolean,
|
Type::Bool => SyntaxShape::Boolean,
|
||||||
Type::String => SyntaxShape::String,
|
Type::String => SyntaxShape::String,
|
||||||
Type::Block => SyntaxShape::Block, // FIXME needs more accuracy
|
|
||||||
Type::Closure => SyntaxShape::Closure(None), // FIXME needs more accuracy
|
Type::Closure => SyntaxShape::Closure(None), // FIXME needs more accuracy
|
||||||
Type::CellPath => SyntaxShape::CellPath,
|
Type::CellPath => SyntaxShape::CellPath,
|
||||||
Type::Duration => SyntaxShape::Duration,
|
Type::Duration => SyntaxShape::Duration,
|
||||||
@ -128,7 +123,6 @@ impl Type {
|
|||||||
Type::Error => SyntaxShape::Any,
|
Type::Error => SyntaxShape::Any,
|
||||||
Type::Binary => SyntaxShape::Binary,
|
Type::Binary => SyntaxShape::Binary,
|
||||||
Type::Custom(_) => SyntaxShape::Any,
|
Type::Custom(_) => SyntaxShape::Any,
|
||||||
Type::Signature => SyntaxShape::Signature,
|
|
||||||
Type::Glob => SyntaxShape::GlobPattern,
|
Type::Glob => SyntaxShape::GlobPattern,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,7 +131,6 @@ impl Type {
|
|||||||
/// tables and records (get `list` instead of `list<any>`
|
/// tables and records (get `list` instead of `list<any>`
|
||||||
pub fn get_non_specified_string(&self) -> String {
|
pub fn get_non_specified_string(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
Type::Block => String::from("block"),
|
|
||||||
Type::Closure => String::from("closure"),
|
Type::Closure => String::from("closure"),
|
||||||
Type::Bool => String::from("bool"),
|
Type::Bool => String::from("bool"),
|
||||||
Type::CellPath => String::from("cell-path"),
|
Type::CellPath => String::from("cell-path"),
|
||||||
@ -157,7 +150,6 @@ impl Type {
|
|||||||
Type::Error => String::from("error"),
|
Type::Error => String::from("error"),
|
||||||
Type::Binary => String::from("binary"),
|
Type::Binary => String::from("binary"),
|
||||||
Type::Custom(_) => String::from("custom"),
|
Type::Custom(_) => String::from("custom"),
|
||||||
Type::Signature => String::from("signature"),
|
|
||||||
Type::Glob => String::from("glob"),
|
Type::Glob => String::from("glob"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,7 +158,6 @@ impl Type {
|
|||||||
impl Display for Type {
|
impl Display for Type {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Type::Block => write!(f, "block"),
|
|
||||||
Type::Closure => write!(f, "closure"),
|
Type::Closure => write!(f, "closure"),
|
||||||
Type::Bool => write!(f, "bool"),
|
Type::Bool => write!(f, "bool"),
|
||||||
Type::CellPath => write!(f, "cell-path"),
|
Type::CellPath => write!(f, "cell-path"),
|
||||||
@ -214,7 +205,6 @@ impl Display for Type {
|
|||||||
Type::Error => write!(f, "error"),
|
Type::Error => write!(f, "error"),
|
||||||
Type::Binary => write!(f, "binary"),
|
Type::Binary => write!(f, "binary"),
|
||||||
Type::Custom(custom) => write!(f, "{custom}"),
|
Type::Custom(custom) => write!(f, "{custom}"),
|
||||||
Type::Signature => write!(f, "signature"),
|
|
||||||
Type::Glob => write!(f, "glob"),
|
Type::Glob => write!(f, "glob"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user