mirror of
https://github.com/nushell/nushell.git
synced 2025-08-15 02:02:35 +02:00
Rust 1.85, edition=2024 (#15741)
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
authors = ["The Nushell Project Developers"]
|
||||
description = "Nushell's evaluation engine"
|
||||
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-engine"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
name = "nu-engine"
|
||||
version = "0.104.1"
|
||||
@ -29,4 +29,4 @@ os = [
|
||||
plugin = [
|
||||
"nu-protocol/plugin",
|
||||
"os",
|
||||
]
|
||||
]
|
||||
|
@ -1,10 +1,10 @@
|
||||
use crate::eval_expression;
|
||||
use nu_protocol::{
|
||||
ast,
|
||||
FromValue, ShellError, Span, Value, ast,
|
||||
debugger::WithoutDebug,
|
||||
engine::{self, EngineState, Stack, StateWorkingSet},
|
||||
eval_const::eval_constant,
|
||||
ir, FromValue, ShellError, Span, Value,
|
||||
ir,
|
||||
};
|
||||
|
||||
pub trait CallExt {
|
||||
|
@ -1,11 +1,11 @@
|
||||
use crate::{
|
||||
eval_block_with_early_return, get_eval_block_with_early_return, EvalBlockWithEarlyReturnFn,
|
||||
EvalBlockWithEarlyReturnFn, eval_block_with_early_return, get_eval_block_with_early_return,
|
||||
};
|
||||
use nu_protocol::{
|
||||
IntoPipelineData, PipelineData, ShellError, Value,
|
||||
ast::Block,
|
||||
debugger::{WithDebug, WithoutDebug},
|
||||
engine::{Closure, EngineState, EnvVars, Stack},
|
||||
IntoPipelineData, PipelineData, ShellError, Value,
|
||||
};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
|
@ -1,10 +1,10 @@
|
||||
pub use crate::CallExt;
|
||||
pub use nu_protocol::{
|
||||
ByteStream, ByteStreamType, Category, ErrSpan, Example, IntoInterruptiblePipelineData,
|
||||
IntoPipelineData, IntoSpanned, IntoValue, PipelineData, Record, ShellError, Signature, Span,
|
||||
Spanned, SyntaxShape, Type, Value,
|
||||
ast::CellPath,
|
||||
engine::{Call, Command, EngineState, Stack, StateWorkingSet},
|
||||
record,
|
||||
shell_error::io::*,
|
||||
ByteStream, ByteStreamType, Category, ErrSpan, Example, IntoInterruptiblePipelineData,
|
||||
IntoPipelineData, IntoSpanned, IntoValue, PipelineData, Record, ShellError, Signature, Span,
|
||||
Spanned, SyntaxShape, Type, Value,
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
use nu_protocol::{
|
||||
CompileError, IntoSpanned, RegId, Span, Spanned,
|
||||
ast::Pattern,
|
||||
ir::{DataSlice, Instruction, IrAstRef, IrBlock, Literal},
|
||||
CompileError, IntoSpanned, RegId, Span, Spanned,
|
||||
};
|
||||
|
||||
/// A label identifier. Only exists while building code. Replaced with the actual target.
|
||||
|
@ -1,13 +1,13 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use nu_protocol::{
|
||||
IntoSpanned, RegId, Span, Spanned,
|
||||
ast::{Argument, Call, Expression, ExternalArgument},
|
||||
engine::StateWorkingSet,
|
||||
ir::{Instruction, IrAstRef, Literal},
|
||||
IntoSpanned, RegId, Span, Spanned,
|
||||
};
|
||||
|
||||
use super::{compile_expression, keyword::*, BlockBuilder, CompileError, RedirectModes};
|
||||
use super::{BlockBuilder, CompileError, RedirectModes, compile_expression, keyword::*};
|
||||
|
||||
pub(crate) fn compile_call(
|
||||
working_set: &StateWorkingSet,
|
||||
|
@ -1,13 +1,13 @@
|
||||
use super::{
|
||||
compile_binary_op, compile_block, compile_call, compile_external_call, compile_load_env,
|
||||
BlockBuilder, CompileError, RedirectModes,
|
||||
BlockBuilder, CompileError, RedirectModes, compile_binary_op, compile_block, compile_call,
|
||||
compile_external_call, compile_load_env,
|
||||
};
|
||||
|
||||
use nu_protocol::{
|
||||
ENV_VARIABLE_ID, IntoSpanned, RegId, Span, Value,
|
||||
ast::{CellPath, Expr, Expression, ListItem, RecordItem, ValueWithUnit},
|
||||
engine::StateWorkingSet,
|
||||
ir::{DataSlice, Instruction, Literal},
|
||||
IntoSpanned, RegId, Span, Value, ENV_VARIABLE_ID,
|
||||
};
|
||||
|
||||
pub(crate) fn compile_expression(
|
||||
|
@ -1,11 +1,11 @@
|
||||
use nu_protocol::{
|
||||
IntoSpanned, RegId, Type, VarId,
|
||||
ast::{Block, Call, Expr, Expression},
|
||||
engine::StateWorkingSet,
|
||||
ir::Instruction,
|
||||
IntoSpanned, RegId, Type, VarId,
|
||||
};
|
||||
|
||||
use super::{compile_block, compile_expression, BlockBuilder, CompileError, RedirectModes};
|
||||
use super::{BlockBuilder, CompileError, RedirectModes, compile_block, compile_expression};
|
||||
|
||||
/// Compile a call to `if` as a branch-if
|
||||
pub(crate) fn compile_if(
|
||||
|
@ -1,8 +1,8 @@
|
||||
use nu_protocol::{
|
||||
CompileError, IntoSpanned, RegId, Span,
|
||||
ast::{Block, Expr, Pipeline, PipelineRedirection, RedirectionSource, RedirectionTarget},
|
||||
engine::StateWorkingSet,
|
||||
ir::{Instruction, IrBlock, RedirectMode},
|
||||
CompileError, IntoSpanned, RegId, Span,
|
||||
};
|
||||
|
||||
mod builder;
|
||||
|
@ -1,12 +1,12 @@
|
||||
use nu_protocol::{
|
||||
ENV_VARIABLE_ID, IntoSpanned, RegId, Span, Spanned, Value,
|
||||
ast::{Assignment, Boolean, CellPath, Expr, Expression, Math, Operator, PathMember, Pattern},
|
||||
engine::StateWorkingSet,
|
||||
ir::{Instruction, Literal},
|
||||
IntoSpanned, RegId, Span, Spanned, Value, ENV_VARIABLE_ID,
|
||||
};
|
||||
use nu_utils::IgnoreCaseExt;
|
||||
|
||||
use super::{compile_expression, BlockBuilder, CompileError, RedirectModes};
|
||||
use super::{BlockBuilder, CompileError, RedirectModes, compile_expression};
|
||||
|
||||
pub(crate) fn compile_binary_op(
|
||||
working_set: &StateWorkingSet,
|
||||
@ -342,11 +342,14 @@ pub(crate) fn compile_load_env(
|
||||
.into_spanned(span),
|
||||
)?,
|
||||
[PathMember::Int { span, .. }, ..] => {
|
||||
return Err(CompileError::AccessEnvByInt { span: *span })
|
||||
return Err(CompileError::AccessEnvByInt { span: *span });
|
||||
}
|
||||
[PathMember::String {
|
||||
val: key, optional, ..
|
||||
}, tail @ ..] => {
|
||||
[
|
||||
PathMember::String {
|
||||
val: key, optional, ..
|
||||
},
|
||||
tail @ ..,
|
||||
] => {
|
||||
let key = builder.data(key)?;
|
||||
|
||||
builder.push(if *optional {
|
||||
|
@ -1,11 +1,11 @@
|
||||
use nu_protocol::{
|
||||
IntoSpanned, OutDest, RegId, Span, Spanned,
|
||||
ast::{Expression, RedirectionTarget},
|
||||
engine::StateWorkingSet,
|
||||
ir::{Instruction, RedirectMode},
|
||||
IntoSpanned, OutDest, RegId, Span, Spanned,
|
||||
};
|
||||
|
||||
use super::{compile_expression, BlockBuilder, CompileError};
|
||||
use super::{BlockBuilder, CompileError, compile_expression};
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
pub(crate) struct RedirectModes {
|
||||
|
@ -1,11 +1,12 @@
|
||||
use crate::eval_call;
|
||||
use nu_protocol::{
|
||||
Category, Config, Example, IntoPipelineData, PipelineData, PositionalArg, Signature, Span,
|
||||
SpanId, Spanned, SyntaxShape, Type, Value,
|
||||
ast::{Argument, Call, Expr, Expression, RecordItem},
|
||||
debugger::WithoutDebug,
|
||||
engine::CommandType,
|
||||
engine::{Command, EngineState, Stack, UNKNOWN_SPAN_ID},
|
||||
record, Category, Config, Example, IntoPipelineData, PipelineData, PositionalArg, Signature,
|
||||
Span, SpanId, Spanned, SyntaxShape, Type, Value,
|
||||
record,
|
||||
};
|
||||
use nu_utils::terminal_size;
|
||||
use std::{collections::HashMap, fmt::Write};
|
||||
|
@ -1,10 +1,10 @@
|
||||
use crate::ClosureEvalOnce;
|
||||
use nu_path::canonicalize_with;
|
||||
use nu_protocol::{
|
||||
ShellError, Span, Type, Value, VarId,
|
||||
ast::Expr,
|
||||
engine::{Call, EngineState, Stack, StateWorkingSet},
|
||||
shell_error::io::{ErrorKindExt, IoError, NotFound},
|
||||
ShellError, Span, Type, Value, VarId,
|
||||
};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
@ -307,11 +307,13 @@ pub fn find_in_dirs_env(
|
||||
cwd
|
||||
} else {
|
||||
return Err(ShellError::GenericError {
|
||||
error: "Invalid current directory".into(),
|
||||
msg: format!("The 'FILE_PWD' environment variable must be set to an absolute path. Found: '{cwd}'"),
|
||||
span: Some(pwd.span()),
|
||||
help: None,
|
||||
inner: vec![]
|
||||
error: "Invalid current directory".into(),
|
||||
msg: format!(
|
||||
"The 'FILE_PWD' environment variable must be set to an absolute path. Found: '{cwd}'"
|
||||
),
|
||||
span: Some(pwd.span()),
|
||||
help: None,
|
||||
inner: vec![],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
use crate::eval_ir_block;
|
||||
#[allow(deprecated)]
|
||||
use crate::get_full_help;
|
||||
use nu_path::{expand_path_with, AbsolutePathBuf};
|
||||
use nu_path::{AbsolutePathBuf, expand_path_with};
|
||||
use nu_protocol::{
|
||||
BlockId, Config, DataSource, ENV_VARIABLE_ID, IntoPipelineData, PipelineData, PipelineMetadata,
|
||||
ShellError, Span, Value, VarId,
|
||||
ast::{Assignment, Block, Call, Expr, Expression, ExternalArgument, PathMember},
|
||||
debugger::DebugContext,
|
||||
engine::{Closure, EngineState, Stack},
|
||||
eval_base::Eval,
|
||||
BlockId, Config, DataSource, IntoPipelineData, PipelineData, PipelineMetadata, ShellError,
|
||||
Span, Value, VarId, ENV_VARIABLE_ID,
|
||||
};
|
||||
use nu_utils::IgnoreCaseExt;
|
||||
use std::sync::Arc;
|
||||
|
@ -3,10 +3,10 @@ use crate::{
|
||||
eval_ir_block, eval_subexpression,
|
||||
};
|
||||
use nu_protocol::{
|
||||
PipelineData, ShellError, Value,
|
||||
ast::{Block, Expression},
|
||||
debugger::{WithDebug, WithoutDebug},
|
||||
engine::{EngineState, Stack},
|
||||
PipelineData, ShellError, Value,
|
||||
};
|
||||
|
||||
/// Type of eval_block() function
|
||||
|
@ -1,7 +1,10 @@
|
||||
use std::{borrow::Cow, fs::File, sync::Arc};
|
||||
|
||||
use nu_path::{expand_path_with, AbsolutePathBuf};
|
||||
use nu_path::{AbsolutePathBuf, expand_path_with};
|
||||
use nu_protocol::{
|
||||
DataSource, DeclId, ENV_VARIABLE_ID, Flag, IntoPipelineData, IntoSpanned, ListStream, OutDest,
|
||||
PipelineData, PipelineMetadata, PositionalArg, Range, Record, RegId, ShellError, Signals,
|
||||
Signature, Span, Spanned, Type, Value, VarId,
|
||||
ast::{Bits, Block, Boolean, CellPath, Comparison, Math, Operator},
|
||||
debugger::DebugContext,
|
||||
engine::{
|
||||
@ -9,14 +12,11 @@ use nu_protocol::{
|
||||
},
|
||||
ir::{Call, DataSlice, Instruction, IrAstRef, IrBlock, Literal, RedirectMode},
|
||||
shell_error::io::IoError,
|
||||
DataSource, DeclId, Flag, IntoPipelineData, IntoSpanned, ListStream, OutDest, PipelineData,
|
||||
PipelineMetadata, PositionalArg, Range, Record, RegId, ShellError, Signals, Signature, Span,
|
||||
Spanned, Type, Value, VarId, ENV_VARIABLE_ID,
|
||||
};
|
||||
use nu_utils::IgnoreCaseExt;
|
||||
|
||||
use crate::{
|
||||
convert_env_vars, eval::is_automatic_env_var, eval_block_with_early_return, ENV_CONVERSIONS,
|
||||
ENV_CONVERSIONS, convert_env_vars, eval::is_automatic_env_var, eval_block_with_early_return,
|
||||
};
|
||||
|
||||
/// Evaluate the compiled representation of a [`Block`].
|
||||
@ -994,7 +994,7 @@ fn binary_op(
|
||||
return Err(ShellError::IrEvalError {
|
||||
msg: "can't eval assignment with the `binary-op` instruction".into(),
|
||||
span: Some(span),
|
||||
})
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@ -1322,7 +1322,7 @@ fn check_input_types(
|
||||
return Err(ShellError::NushellFailed {
|
||||
msg: "Command input type strings is empty, despite being non-zero earlier"
|
||||
.to_string(),
|
||||
})
|
||||
});
|
||||
}
|
||||
1 => input_types.swap_remove(0),
|
||||
2 => input_types.join(" and "),
|
||||
|
@ -1,6 +1,6 @@
|
||||
use nu_glob::MatchOptions;
|
||||
use nu_path::{canonicalize_with, expand_path_with};
|
||||
use nu_protocol::{shell_error::io::IoError, NuGlob, ShellError, Signals, Span, Spanned};
|
||||
use nu_protocol::{NuGlob, ShellError, Signals, Span, Spanned, shell_error::io::IoError};
|
||||
use std::{
|
||||
fs,
|
||||
path::{Component, Path, PathBuf},
|
||||
|
@ -1,7 +1,8 @@
|
||||
use nu_protocol::{
|
||||
DeclId, ModuleId, Signature, Span, SyntaxShape, Type, Value, VarId,
|
||||
ast::Expr,
|
||||
engine::{Command, EngineState, Stack, Visibility},
|
||||
record, DeclId, ModuleId, Signature, Span, SyntaxShape, Type, Value, VarId,
|
||||
record,
|
||||
};
|
||||
use std::{cmp::Ordering, collections::HashMap};
|
||||
|
||||
|
Reference in New Issue
Block a user