forked from extern/nushell
Apply nightly clippy fixes (#11083)
<!-- if this PR closes one or more issues, you can automatically link the PR with them by using one of the [*linking keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword), e.g. - this PR should close #xxxx - fixes #xxxx you can also mention related issues, PRs or discussions! --> # Description <!-- Thank you for improving Nushell. Please, check our [contributing guide](../CONTRIBUTING.md) and talk to the core team before making major changes. Description of your pull request goes here. **Provide examples and/or screenshots** if your changes affect the user experience. --> Clippy fixes for rust 1.76.0-nightly # User-Facing Changes <!-- List of all changes that impact the user experience here. This helps us keep track of breaking changes. --> N/A # Tests + Formatting <!-- Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` --> # After Submitting <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. -->
This commit is contained in:
parent
5063e01c12
commit
f41c93b2d3
@ -67,7 +67,7 @@ impl NuCompleter {
|
|||||||
let mut callee_stack = stack.gather_captures(&self.engine_state, &block.captures);
|
let mut callee_stack = stack.gather_captures(&self.engine_state, &block.captures);
|
||||||
|
|
||||||
// Line
|
// Line
|
||||||
if let Some(pos_arg) = block.signature.required_positional.get(0) {
|
if let Some(pos_arg) = block.signature.required_positional.first() {
|
||||||
if let Some(var_id) = pos_arg.var_id {
|
if let Some(var_id) = pos_arg.var_id {
|
||||||
callee_stack.add_var(
|
callee_stack.add_var(
|
||||||
var_id,
|
var_id,
|
||||||
|
@ -111,7 +111,7 @@ fn gather_env_vars(
|
|||||||
let name = if let Some(Token {
|
let name = if let Some(Token {
|
||||||
contents: TokenContents::Item,
|
contents: TokenContents::Item,
|
||||||
span,
|
span,
|
||||||
}) = parts.get(0)
|
}) = parts.first()
|
||||||
{
|
{
|
||||||
let mut working_set = StateWorkingSet::new(engine_state);
|
let mut working_set = StateWorkingSet::new(engine_state);
|
||||||
let bytes = working_set.get_span_contents(*span);
|
let bytes = working_set.get_span_contents(*span);
|
||||||
|
@ -122,14 +122,14 @@ fn dotnu_completions() {
|
|||||||
let suggestions = completer.complete(&completion_str, completion_str.len());
|
let suggestions = completer.complete(&completion_str, completion_str.len());
|
||||||
|
|
||||||
assert_eq!(1, suggestions.len());
|
assert_eq!(1, suggestions.len());
|
||||||
assert_eq!("custom_completion.nu", suggestions.get(0).unwrap().value);
|
assert_eq!("custom_completion.nu", suggestions.first().unwrap().value);
|
||||||
|
|
||||||
// Test use completion
|
// Test use completion
|
||||||
let completion_str = "use ".to_string();
|
let completion_str = "use ".to_string();
|
||||||
let suggestions = completer.complete(&completion_str, completion_str.len());
|
let suggestions = completer.complete(&completion_str, completion_str.len());
|
||||||
|
|
||||||
assert_eq!(1, suggestions.len());
|
assert_eq!(1, suggestions.len());
|
||||||
assert_eq!("custom_completion.nu", suggestions.get(0).unwrap().value);
|
assert_eq!("custom_completion.nu", suggestions.first().unwrap().value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -141,7 +141,7 @@ fn external_completer_trailing_space() {
|
|||||||
|
|
||||||
let suggestions = run_external_completion(block, &input);
|
let suggestions = run_external_completion(block, &input);
|
||||||
assert_eq!(3, suggestions.len());
|
assert_eq!(3, suggestions.len());
|
||||||
assert_eq!("gh", suggestions.get(0).unwrap().value);
|
assert_eq!("gh", suggestions.first().unwrap().value);
|
||||||
assert_eq!("alias", suggestions.get(1).unwrap().value);
|
assert_eq!("alias", suggestions.get(1).unwrap().value);
|
||||||
assert_eq!("", suggestions.get(2).unwrap().value);
|
assert_eq!("", suggestions.get(2).unwrap().value);
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ fn external_completer_no_trailing_space() {
|
|||||||
|
|
||||||
let suggestions = run_external_completion(block, &input);
|
let suggestions = run_external_completion(block, &input);
|
||||||
assert_eq!(2, suggestions.len());
|
assert_eq!(2, suggestions.len());
|
||||||
assert_eq!("gh", suggestions.get(0).unwrap().value);
|
assert_eq!("gh", suggestions.first().unwrap().value);
|
||||||
assert_eq!("alias", suggestions.get(1).unwrap().value);
|
assert_eq!("alias", suggestions.get(1).unwrap().value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ fn external_completer_pass_flags() {
|
|||||||
|
|
||||||
let suggestions = run_external_completion(block, &input);
|
let suggestions = run_external_completion(block, &input);
|
||||||
assert_eq!(3, suggestions.len());
|
assert_eq!(3, suggestions.len());
|
||||||
assert_eq!("gh", suggestions.get(0).unwrap().value);
|
assert_eq!("gh", suggestions.first().unwrap().value);
|
||||||
assert_eq!("api", suggestions.get(1).unwrap().value);
|
assert_eq!("api", suggestions.get(1).unwrap().value);
|
||||||
assert_eq!("--", suggestions.get(2).unwrap().value);
|
assert_eq!("--", suggestions.get(2).unwrap().value);
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ fn command(
|
|||||||
let df = NuDataFrame::try_from_pipeline(input, call.head)?;
|
let df = NuDataFrame::try_from_pipeline(input, call.head)?;
|
||||||
|
|
||||||
let new_df = col_string
|
let new_df = col_string
|
||||||
.get(0)
|
.first()
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
ShellError::GenericError(
|
ShellError::GenericError(
|
||||||
"Empty names list".into(),
|
"Empty names list".into(),
|
||||||
|
@ -29,7 +29,7 @@ impl SQLContext {
|
|||||||
fn execute_select(&self, select_stmt: &Select) -> Result<LazyFrame, PolarsError> {
|
fn execute_select(&self, select_stmt: &Select) -> Result<LazyFrame, PolarsError> {
|
||||||
// Determine involved dataframe
|
// Determine involved dataframe
|
||||||
// Implicit join require some more work in query parsers, Explicit join are preferred for now.
|
// Implicit join require some more work in query parsers, Explicit join are preferred for now.
|
||||||
let tbl = select_stmt.from.get(0).ok_or_else(|| {
|
let tbl = select_stmt.from.first().ok_or_else(|| {
|
||||||
PolarsError::ComputeError(ErrString::from("No table found in select statement"))
|
PolarsError::ComputeError(ErrString::from("No table found in select statement"))
|
||||||
})?;
|
})?;
|
||||||
let mut alias_map = HashMap::new();
|
let mut alias_map = HashMap::new();
|
||||||
@ -37,7 +37,7 @@ impl SQLContext {
|
|||||||
TableFactor::Table { name, alias, .. } => {
|
TableFactor::Table { name, alias, .. } => {
|
||||||
let tbl_name = name
|
let tbl_name = name
|
||||||
.0
|
.0
|
||||||
.get(0)
|
.first()
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
PolarsError::ComputeError(ErrString::from(
|
PolarsError::ComputeError(ErrString::from(
|
||||||
"No table found in select statement",
|
"No table found in select statement",
|
||||||
@ -182,7 +182,7 @@ impl SQLContext {
|
|||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
let ast = ast
|
let ast = ast
|
||||||
.get(0)
|
.first()
|
||||||
.ok_or_else(|| PolarsError::ComputeError(ErrString::from("No statement found")))?;
|
.ok_or_else(|| PolarsError::ComputeError(ErrString::from("No statement found")))?;
|
||||||
Ok(match ast {
|
Ok(match ast {
|
||||||
Statement::Query(query) => {
|
Statement::Query(query) => {
|
||||||
|
@ -325,7 +325,7 @@ impl NuDataFrame {
|
|||||||
let series = self
|
let series = self
|
||||||
.df
|
.df
|
||||||
.get_columns()
|
.get_columns()
|
||||||
.get(0)
|
.first()
|
||||||
.expect("We have already checked that the width is 1");
|
.expect("We have already checked that the width is 1");
|
||||||
|
|
||||||
Ok(series.clone())
|
Ok(series.clone())
|
||||||
|
@ -11,7 +11,7 @@ pub(crate) fn convert_columns(
|
|||||||
) -> Result<(Vec<Spanned<String>>, Span), ShellError> {
|
) -> Result<(Vec<Spanned<String>>, Span), ShellError> {
|
||||||
// First column span
|
// First column span
|
||||||
let mut col_span = columns
|
let mut col_span = columns
|
||||||
.get(0)
|
.first()
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
ShellError::GenericError(
|
ShellError::GenericError(
|
||||||
"Empty column list".into(),
|
"Empty column list".into(),
|
||||||
@ -54,7 +54,7 @@ pub(crate) fn convert_columns_string(
|
|||||||
) -> Result<(Vec<String>, Span), ShellError> {
|
) -> Result<(Vec<String>, Span), ShellError> {
|
||||||
// First column span
|
// First column span
|
||||||
let mut col_span = columns
|
let mut col_span = columns
|
||||||
.get(0)
|
.first()
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
ShellError::GenericError(
|
ShellError::GenericError(
|
||||||
"Empty column list".into(),
|
"Empty column list".into(),
|
||||||
|
@ -271,7 +271,7 @@ fn group_closure(
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let value = match collection.get(0) {
|
let value = match collection.first() {
|
||||||
Some(Value::Error { .. }) | None => Value::string(error_key, span),
|
Some(Value::Error { .. }) | None => Value::string(error_key, span),
|
||||||
Some(return_value) => return_value.clone(),
|
Some(return_value) => return_value.clone(),
|
||||||
};
|
};
|
||||||
|
@ -171,7 +171,7 @@ fn insert(
|
|||||||
ctrlc,
|
ctrlc,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
if let Some(PathMember::Int { val, .. }) = cell_path.members.get(0) {
|
if let Some(PathMember::Int { val, .. }) = cell_path.members.first() {
|
||||||
let mut input = input.into_iter();
|
let mut input = input.into_iter();
|
||||||
let mut pre_elems = vec![];
|
let mut pre_elems = vec![];
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ fn reject(
|
|||||||
let mut new_rows = vec![];
|
let mut new_rows = vec![];
|
||||||
for column in cell_paths {
|
for column in cell_paths {
|
||||||
let CellPath { ref members } = column;
|
let CellPath { ref members } = column;
|
||||||
match members.get(0) {
|
match members.first() {
|
||||||
Some(PathMember::Int { val, span, .. }) => {
|
Some(PathMember::Int { val, span, .. }) => {
|
||||||
if members.len() > 1 {
|
if members.len() > 1 {
|
||||||
return Err(ShellError::GenericError(
|
return Err(ShellError::GenericError(
|
||||||
|
@ -212,7 +212,7 @@ fn select(
|
|||||||
|
|
||||||
for column in columns {
|
for column in columns {
|
||||||
let CellPath { ref members } = column;
|
let CellPath { ref members } = column;
|
||||||
match members.get(0) {
|
match members.first() {
|
||||||
Some(PathMember::Int { val, span, .. }) => {
|
Some(PathMember::Int { val, span, .. }) => {
|
||||||
if members.len() > 1 {
|
if members.len() > 1 {
|
||||||
return Err(ShellError::GenericError(
|
return Err(ShellError::GenericError(
|
||||||
|
@ -190,7 +190,7 @@ pub fn transpose(
|
|||||||
|
|
||||||
if args.header_row {
|
if args.header_row {
|
||||||
for i in input.iter() {
|
for i in input.iter() {
|
||||||
if let Some(desc) = descs.get(0) {
|
if let Some(desc) = descs.first() {
|
||||||
match &i.get_data_by_key(desc) {
|
match &i.get_data_by_key(desc) {
|
||||||
Some(x) => {
|
Some(x) => {
|
||||||
if let Ok(s) = x.as_string() {
|
if let Ok(s) = x.as_string() {
|
||||||
|
@ -171,7 +171,7 @@ fn update(
|
|||||||
)?
|
)?
|
||||||
.set_metadata(mdclone))
|
.set_metadata(mdclone))
|
||||||
} else {
|
} else {
|
||||||
if let Some(PathMember::Int { val, span, .. }) = cell_path.members.get(0) {
|
if let Some(PathMember::Int { val, span, .. }) = cell_path.members.first() {
|
||||||
let mut input = input.into_iter();
|
let mut input = input.into_iter();
|
||||||
let mut pre_elems = vec![];
|
let mut pre_elems = vec![];
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ fn upsert(
|
|||||||
ctrlc,
|
ctrlc,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
if let Some(PathMember::Int { val, span, .. }) = cell_path.members.get(0) {
|
if let Some(PathMember::Int { val, span, .. }) = cell_path.members.first() {
|
||||||
let mut input = input.into_iter();
|
let mut input = input.into_iter();
|
||||||
let mut pre_elems = vec![];
|
let mut pre_elems = vec![];
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ impl Command for FromNuon {
|
|||||||
let mut block = nu_parser::parse(&mut working_set, None, string_input.as_bytes(), false);
|
let mut block = nu_parser::parse(&mut working_set, None, string_input.as_bytes(), false);
|
||||||
|
|
||||||
if let Some(pipeline) = block.pipelines.get(1) {
|
if let Some(pipeline) = block.pipelines.get(1) {
|
||||||
if let Some(element) = pipeline.elements.get(0) {
|
if let Some(element) = pipeline.elements.first() {
|
||||||
return Err(ShellError::GenericError(
|
return Err(ShellError::GenericError(
|
||||||
"error when loading nuon text".into(),
|
"error when loading nuon text".into(),
|
||||||
"could not load nuon text".into(),
|
"could not load nuon text".into(),
|
||||||
|
@ -79,7 +79,7 @@ pub fn min(data: Vec<Value>, span: Span, head: Span) -> Result<Value, ShellError
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn sum(data: Vec<Value>, span: Span, head: Span) -> Result<Value, ShellError> {
|
pub fn sum(data: Vec<Value>, span: Span, head: Span) -> Result<Value, ShellError> {
|
||||||
let initial_value = data.get(0);
|
let initial_value = data.first();
|
||||||
|
|
||||||
let mut acc = match initial_value {
|
let mut acc = match initial_value {
|
||||||
Some(v) => {
|
Some(v) => {
|
||||||
@ -124,7 +124,7 @@ pub fn sum(data: Vec<Value>, span: Span, head: Span) -> Result<Value, ShellError
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn product(data: Vec<Value>, span: Span, head: Span) -> Result<Value, ShellError> {
|
pub fn product(data: Vec<Value>, span: Span, head: Span) -> Result<Value, ShellError> {
|
||||||
let initial_value = data.get(0);
|
let initial_value = data.first();
|
||||||
|
|
||||||
let mut acc = match initial_value {
|
let mut acc = match initial_value {
|
||||||
Some(v) => {
|
Some(v) => {
|
||||||
|
@ -15,7 +15,7 @@ pub use nu_protocol::{Config as NuConfig, Span as NuSpan};
|
|||||||
pub type NuText = (String, TextStyle);
|
pub type NuText = (String, TextStyle);
|
||||||
pub type CtrlC = Option<Arc<AtomicBool>>;
|
pub type CtrlC = Option<Arc<AtomicBool>>;
|
||||||
|
|
||||||
pub use command::{is_ignored_command, run_command_with_value, run_nu_command};
|
pub use command::run_command_with_value;
|
||||||
pub use lscolor::{create_lscolors, lscolorize};
|
pub use lscolor::{create_lscolors, lscolorize};
|
||||||
pub use string::{string_width, truncate_str};
|
pub use string::{string_width, truncate_str};
|
||||||
pub use table::try_build_table;
|
pub use table::try_build_table;
|
||||||
|
@ -721,7 +721,7 @@ fn build_table_as_record(v: &RecordView) -> Value {
|
|||||||
let layer = v.get_layer_last();
|
let layer = v.get_layer_last();
|
||||||
|
|
||||||
let cols = layer.columns.to_vec();
|
let cols = layer.columns.to_vec();
|
||||||
let vals = layer.records.get(0).map_or(Vec::new(), |row| row.clone());
|
let vals = layer.records.first().map_or(Vec::new(), |row| row.clone());
|
||||||
|
|
||||||
Value::record(Record::from_raw_cols_vals(cols, vals), NuSpan::unknown())
|
Value::record(Record::from_raw_cols_vals(cols, vals), NuSpan::unknown())
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ fn main() {
|
|||||||
|
|
||||||
// Extract the array
|
// Extract the array
|
||||||
let array : &mut Vec<Value> = sample.get_mut("array").unwrap().as_array_mut().unwrap();
|
let array : &mut Vec<Value> = sample.get_mut("array").unwrap().as_array_mut().unwrap();
|
||||||
println!("first: {}", array.get(0).unwrap());
|
println!("first: {}", array.first().unwrap());
|
||||||
|
|
||||||
// Add a value
|
// Add a value
|
||||||
array.push(Value::String("tak".to_string()));
|
array.push(Value::String("tak".to_string()));
|
||||||
|
@ -63,7 +63,7 @@ impl LanguageServer {
|
|||||||
engine_state: EngineState,
|
engine_state: EngineState,
|
||||||
ctrlc: Arc<AtomicBool>,
|
ctrlc: Arc<AtomicBool>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let server_capabilities = serde_json::to_value(&ServerCapabilities {
|
let server_capabilities = serde_json::to_value(ServerCapabilities {
|
||||||
text_document_sync: Some(lsp_types::TextDocumentSyncCapability::Kind(
|
text_document_sync: Some(lsp_types::TextDocumentSyncCapability::Kind(
|
||||||
TextDocumentSyncKind::INCREMENTAL,
|
TextDocumentSyncKind::INCREMENTAL,
|
||||||
)),
|
)),
|
||||||
|
@ -70,13 +70,13 @@ pub const UNALIASABLE_PARSER_KEYWORDS: &[&[u8]] = &[
|
|||||||
/// Check whether spans start with a parser keyword that can be aliased
|
/// Check whether spans start with a parser keyword that can be aliased
|
||||||
pub fn is_unaliasable_parser_keyword(working_set: &StateWorkingSet, spans: &[Span]) -> bool {
|
pub fn is_unaliasable_parser_keyword(working_set: &StateWorkingSet, spans: &[Span]) -> bool {
|
||||||
// try two words
|
// try two words
|
||||||
if let (Some(span1), Some(span2)) = (spans.get(0), spans.get(1)) {
|
if let (Some(span1), Some(span2)) = (spans.first(), spans.get(1)) {
|
||||||
let cmd_name = working_set.get_span_contents(span(&[*span1, *span2]));
|
let cmd_name = working_set.get_span_contents(span(&[*span1, *span2]));
|
||||||
return UNALIASABLE_PARSER_KEYWORDS.contains(&cmd_name);
|
return UNALIASABLE_PARSER_KEYWORDS.contains(&cmd_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// try one word
|
// try one word
|
||||||
if let Some(span1) = spans.get(0) {
|
if let Some(span1) = spans.first() {
|
||||||
let cmd_name = working_set.get_span_contents(*span1);
|
let cmd_name = working_set.get_span_contents(*span1);
|
||||||
UNALIASABLE_PARSER_KEYWORDS.contains(&cmd_name)
|
UNALIASABLE_PARSER_KEYWORDS.contains(&cmd_name)
|
||||||
} else {
|
} else {
|
||||||
@ -653,7 +653,7 @@ pub fn parse_extern(
|
|||||||
|
|
||||||
let (command_spans, rest_spans) = spans.split_at(split_id);
|
let (command_spans, rest_spans) = spans.split_at(split_id);
|
||||||
|
|
||||||
if let Some(name_span) = rest_spans.get(0) {
|
if let Some(name_span) = rest_spans.first() {
|
||||||
if let Some(err) = detect_params_in_name(
|
if let Some(err) = detect_params_in_name(
|
||||||
working_set,
|
working_set,
|
||||||
*name_span,
|
*name_span,
|
||||||
@ -1135,7 +1135,7 @@ pub fn parse_export_in_module(
|
|||||||
) -> (Pipeline, Vec<Exportable>) {
|
) -> (Pipeline, Vec<Exportable>) {
|
||||||
let spans = &lite_command.parts[..];
|
let spans = &lite_command.parts[..];
|
||||||
|
|
||||||
let export_span = if let Some(sp) = spans.get(0) {
|
let export_span = if let Some(sp) = spans.first() {
|
||||||
if working_set.get_span_contents(*sp) != b"export" {
|
if working_set.get_span_contents(*sp) != b"export" {
|
||||||
working_set.error(ParseError::UnknownState(
|
working_set.error(ParseError::UnknownState(
|
||||||
"expected export statement".into(),
|
"expected export statement".into(),
|
||||||
@ -1209,7 +1209,7 @@ pub fn parse_export_in_module(
|
|||||||
expr: Expr::Call(ref def_call),
|
expr: Expr::Call(ref def_call),
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
)) = pipeline.elements.get(0)
|
)) = pipeline.elements.first()
|
||||||
{
|
{
|
||||||
call = def_call.clone();
|
call = def_call.clone();
|
||||||
|
|
||||||
@ -1249,7 +1249,7 @@ pub fn parse_export_in_module(
|
|||||||
expr: Expr::Call(ref def_call),
|
expr: Expr::Call(ref def_call),
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
)) = pipeline.elements.get(0)
|
)) = pipeline.elements.first()
|
||||||
{
|
{
|
||||||
call = def_call.clone();
|
call = def_call.clone();
|
||||||
|
|
||||||
@ -1310,7 +1310,7 @@ pub fn parse_export_in_module(
|
|||||||
expr: Expr::Call(ref def_call),
|
expr: Expr::Call(ref def_call),
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
)) = pipeline.elements.get(0)
|
)) = pipeline.elements.first()
|
||||||
{
|
{
|
||||||
call = def_call.clone();
|
call = def_call.clone();
|
||||||
|
|
||||||
@ -1370,7 +1370,7 @@ pub fn parse_export_in_module(
|
|||||||
expr: Expr::Call(ref alias_call),
|
expr: Expr::Call(ref alias_call),
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
)) = pipeline.elements.get(0)
|
)) = pipeline.elements.first()
|
||||||
{
|
{
|
||||||
call = alias_call.clone();
|
call = alias_call.clone();
|
||||||
|
|
||||||
@ -1429,7 +1429,7 @@ pub fn parse_export_in_module(
|
|||||||
expr: Expr::Call(ref use_call),
|
expr: Expr::Call(ref use_call),
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
)) = pipeline.elements.get(0)
|
)) = pipeline.elements.first()
|
||||||
{
|
{
|
||||||
call = use_call.clone();
|
call = use_call.clone();
|
||||||
|
|
||||||
@ -1466,7 +1466,7 @@ pub fn parse_export_in_module(
|
|||||||
expr: Expr::Call(ref module_call),
|
expr: Expr::Call(ref module_call),
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
)) = pipeline.elements.get(0)
|
)) = pipeline.elements.first()
|
||||||
{
|
{
|
||||||
call = module_call.clone();
|
call = module_call.clone();
|
||||||
|
|
||||||
@ -1523,7 +1523,7 @@ pub fn parse_export_in_module(
|
|||||||
expr: Expr::Call(ref def_call),
|
expr: Expr::Call(ref def_call),
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
)) = pipeline.elements.get(0)
|
)) = pipeline.elements.first()
|
||||||
{
|
{
|
||||||
call = def_call.clone();
|
call = def_call.clone();
|
||||||
|
|
||||||
|
@ -1572,10 +1572,10 @@ pub fn parse_brace_expr(
|
|||||||
let (tokens, _) = lex(bytes, span.start + 1, &[b'\r', b'\n', b'\t'], &[b':'], true);
|
let (tokens, _) = lex(bytes, span.start + 1, &[b'\r', b'\n', b'\t'], &[b':'], true);
|
||||||
|
|
||||||
let second_token = tokens
|
let second_token = tokens
|
||||||
.get(0)
|
.first()
|
||||||
.map(|token| working_set.get_span_contents(token.span));
|
.map(|token| working_set.get_span_contents(token.span));
|
||||||
|
|
||||||
let second_token_contents = tokens.get(0).map(|token| token.contents);
|
let second_token_contents = tokens.first().map(|token| token.contents);
|
||||||
|
|
||||||
let third_token = tokens
|
let third_token = tokens
|
||||||
.get(1)
|
.get(1)
|
||||||
@ -2666,7 +2666,7 @@ pub fn parse_string_strict(working_set: &mut StateWorkingSet, span: Span) -> Exp
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_import_pattern(working_set: &mut StateWorkingSet, spans: &[Span]) -> Expression {
|
pub fn parse_import_pattern(working_set: &mut StateWorkingSet, spans: &[Span]) -> Expression {
|
||||||
let Some(head_span) = spans.get(0) else {
|
let Some(head_span) = spans.first() else {
|
||||||
working_set.error(ParseError::WrongImportPattern(
|
working_set.error(ParseError::WrongImportPattern(
|
||||||
"needs at least one component of import pattern".to_string(),
|
"needs at least one component of import pattern".to_string(),
|
||||||
span(spans),
|
span(spans),
|
||||||
|
@ -134,8 +134,8 @@ impl Expression {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(pipeline) = block.pipelines.get(0) {
|
if let Some(pipeline) = block.pipelines.first() {
|
||||||
match pipeline.elements.get(0) {
|
match pipeline.elements.first() {
|
||||||
Some(element) => element.has_in_variable(working_set),
|
Some(element) => element.has_in_variable(working_set),
|
||||||
None => false,
|
None => false,
|
||||||
}
|
}
|
||||||
@ -150,8 +150,8 @@ impl Expression {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(pipeline) = block.pipelines.get(0) {
|
if let Some(pipeline) = block.pipelines.first() {
|
||||||
match pipeline.elements.get(0) {
|
match pipeline.elements.first() {
|
||||||
Some(element) => element.has_in_variable(working_set),
|
Some(element) => element.has_in_variable(working_set),
|
||||||
None => false,
|
None => false,
|
||||||
}
|
}
|
||||||
@ -258,8 +258,8 @@ impl Expression {
|
|||||||
Expr::RowCondition(block_id) | Expr::Subexpression(block_id) => {
|
Expr::RowCondition(block_id) | Expr::Subexpression(block_id) => {
|
||||||
let block = working_set.get_block(*block_id);
|
let block = working_set.get_block(*block_id);
|
||||||
|
|
||||||
if let Some(pipeline) = block.pipelines.get(0) {
|
if let Some(pipeline) = block.pipelines.first() {
|
||||||
if let Some(expr) = pipeline.elements.get(0) {
|
if let Some(expr) = pipeline.elements.first() {
|
||||||
expr.has_in_variable(working_set)
|
expr.has_in_variable(working_set)
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
@ -304,8 +304,8 @@ impl Expression {
|
|||||||
Expr::Block(block_id) => {
|
Expr::Block(block_id) => {
|
||||||
let block = working_set.get_block(*block_id);
|
let block = working_set.get_block(*block_id);
|
||||||
|
|
||||||
let new_expr = if let Some(pipeline) = block.pipelines.get(0) {
|
let new_expr = if let Some(pipeline) = block.pipelines.first() {
|
||||||
if let Some(element) = pipeline.elements.get(0) {
|
if let Some(element) = pipeline.elements.first() {
|
||||||
let mut new_element = element.clone();
|
let mut new_element = element.clone();
|
||||||
new_element.replace_in_variable(working_set, new_var_id);
|
new_element.replace_in_variable(working_set, new_var_id);
|
||||||
Some(new_element)
|
Some(new_element)
|
||||||
@ -335,8 +335,8 @@ impl Expression {
|
|||||||
Expr::Closure(block_id) => {
|
Expr::Closure(block_id) => {
|
||||||
let block = working_set.get_block(*block_id);
|
let block = working_set.get_block(*block_id);
|
||||||
|
|
||||||
let new_element = if let Some(pipeline) = block.pipelines.get(0) {
|
let new_element = if let Some(pipeline) = block.pipelines.first() {
|
||||||
if let Some(element) = pipeline.elements.get(0) {
|
if let Some(element) = pipeline.elements.first() {
|
||||||
let mut new_element = element.clone();
|
let mut new_element = element.clone();
|
||||||
new_element.replace_in_variable(working_set, new_var_id);
|
new_element.replace_in_variable(working_set, new_var_id);
|
||||||
Some(new_element)
|
Some(new_element)
|
||||||
@ -433,8 +433,8 @@ impl Expression {
|
|||||||
Expr::RowCondition(block_id) | Expr::Subexpression(block_id) => {
|
Expr::RowCondition(block_id) | Expr::Subexpression(block_id) => {
|
||||||
let block = working_set.get_block(*block_id);
|
let block = working_set.get_block(*block_id);
|
||||||
|
|
||||||
let new_element = if let Some(pipeline) = block.pipelines.get(0) {
|
let new_element = if let Some(pipeline) = block.pipelines.first() {
|
||||||
if let Some(element) = pipeline.elements.get(0) {
|
if let Some(element) = pipeline.elements.first() {
|
||||||
let mut new_element = element.clone();
|
let mut new_element = element.clone();
|
||||||
new_element.replace_in_variable(working_set, new_var_id);
|
new_element.replace_in_variable(working_set, new_var_id);
|
||||||
Some(new_element)
|
Some(new_element)
|
||||||
|
@ -753,8 +753,7 @@ impl EngineState {
|
|||||||
decls_map.extend(new_decls);
|
decls_map.extend(new_decls);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut decls: Vec<(Vec<u8>, DeclId)> =
|
let mut decls: Vec<(Vec<u8>, DeclId)> = decls_map.into_iter().collect();
|
||||||
decls_map.into_iter().map(|(v, k)| (v, k)).collect();
|
|
||||||
|
|
||||||
decls.sort_by(|a, b| a.0.cmp(&b.0));
|
decls.sort_by(|a, b| a.0.cmp(&b.0));
|
||||||
decls.into_iter()
|
decls.into_iter()
|
||||||
|
@ -81,14 +81,14 @@ pub(crate) fn parse_commandline_args(
|
|||||||
let mut stack = Stack::new();
|
let mut stack = Stack::new();
|
||||||
|
|
||||||
// We should have a successful parse now
|
// We should have a successful parse now
|
||||||
if let Some(pipeline) = block.pipelines.get(0) {
|
if let Some(pipeline) = block.pipelines.first() {
|
||||||
if let Some(PipelineElement::Expression(
|
if let Some(PipelineElement::Expression(
|
||||||
_,
|
_,
|
||||||
Expression {
|
Expression {
|
||||||
expr: Expr::Call(call),
|
expr: Expr::Call(call),
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
)) = pipeline.elements.get(0)
|
)) = pipeline.elements.first()
|
||||||
{
|
{
|
||||||
let redirect_stdin = call.get_named_arg("stdin");
|
let redirect_stdin = call.get_named_arg("stdin");
|
||||||
let login_shell = call.get_named_arg("login");
|
let login_shell = call.get_named_arg("login");
|
||||||
|
Loading…
Reference in New Issue
Block a user