From b2e191f8367413e057be803d6d5d32503f031cfa Mon Sep 17 00:00:00 2001 From: Stefan Holderbach Date: Wed, 26 Jul 2023 23:34:43 +0200 Subject: [PATCH] Remove `Signature.vectorizes_over_list` entirely (#9777) # Description With the current typechecking logic this property has no effect. It was only used in the example testing, and provided some indication of this vectorizing property. With #9742 all commands that previously declared it have explicit list signatures. If we want to get it back in the future we can reconstruct it from the signature. Simplifies the example testing a bit. # User-Facing Changes Causes a breaking change for plugins that previously declared it. While this causes a compile fail, this was already broken by our more stringent type checking. This will be a good reminder for plugin authors to update their signature as well to reflect the more stringent type checking. --- crates/nu-cmd-extra/src/example_test.rs | 1 - crates/nu-cmd-extra/src/extra/bits/and.rs | 1 - crates/nu-cmd-extra/src/extra/bits/not.rs | 1 - crates/nu-cmd-extra/src/extra/bits/or.rs | 1 - .../src/extra/bits/rotate_left.rs | 1 - .../src/extra/bits/rotate_right.rs | 1 - .../nu-cmd-extra/src/extra/bits/shift_left.rs | 1 - .../src/extra/bits/shift_right.rs | 1 - crates/nu-cmd-extra/src/extra/bits/xor.rs | 1 - crates/nu-cmd-extra/src/extra/bytes/add.rs | 1 - crates/nu-cmd-extra/src/extra/bytes/at.rs | 1 - crates/nu-cmd-extra/src/extra/bytes/length.rs | 1 - crates/nu-cmd-extra/src/extra/math/arccos.rs | 1 - crates/nu-cmd-extra/src/extra/math/arccosh.rs | 1 - crates/nu-cmd-extra/src/extra/math/arcsin.rs | 1 - crates/nu-cmd-extra/src/extra/math/arcsinh.rs | 1 - crates/nu-cmd-extra/src/extra/math/arctan.rs | 1 - crates/nu-cmd-extra/src/extra/math/arctanh.rs | 1 - crates/nu-cmd-extra/src/extra/math/cos.rs | 1 - crates/nu-cmd-extra/src/extra/math/cosh.rs | 1 - crates/nu-cmd-extra/src/extra/math/exp.rs | 1 - crates/nu-cmd-extra/src/extra/math/ln.rs | 1 - crates/nu-cmd-extra/src/extra/math/sin.rs | 1 - crates/nu-cmd-extra/src/extra/math/sinh.rs | 1 - crates/nu-cmd-extra/src/extra/math/tan.rs | 1 - crates/nu-cmd-extra/src/extra/math/tanh.rs | 1 - .../src/extra/platform/ansi/gradient.rs | 1 - .../src/extra/platform/ansi/link.rs | 1 - .../extra/strings/encode_decode/decode_hex.rs | 1 - .../extra/strings/encode_decode/encode_hex.rs | 1 - crates/nu-cmd-lang/src/example_support.rs | 63 +++++-------------- crates/nu-cmd-lang/src/example_test.rs | 1 - crates/nu-command/src/conversions/fill.rs | 1 - .../src/conversions/into/filesize.rs | 1 - crates/nu-command/src/conversions/into/int.rs | 1 - crates/nu-command/src/example_test.rs | 1 - crates/nu-command/src/math/abs.rs | 1 - crates/nu-command/src/math/ceil.rs | 1 - crates/nu-command/src/math/floor.rs | 1 - crates/nu-command/src/math/log.rs | 1 - crates/nu-command/src/math/round.rs | 1 - crates/nu-command/src/math/sqrt.rs | 1 - crates/nu-command/src/network/url/encode.rs | 1 - .../strings/encode_decode/decode_base64.rs | 1 - .../strings/encode_decode/encode_base64.rs | 1 - crates/nu-command/src/strings/split/row.rs | 1 - .../src/strings/str_/case/camel_case.rs | 1 - .../src/strings/str_/case/capitalize.rs | 1 - .../src/strings/str_/case/downcase.rs | 1 - .../src/strings/str_/case/kebab_case.rs | 1 - .../src/strings/str_/case/pascal_case.rs | 1 - .../strings/str_/case/screaming_snake_case.rs | 1 - .../src/strings/str_/case/snake_case.rs | 1 - .../src/strings/str_/case/title_case.rs | 1 - .../src/strings/str_/case/upcase.rs | 1 - .../nu-command/src/strings/str_/contains.rs | 1 - .../nu-command/src/strings/str_/ends_with.rs | 1 - crates/nu-command/src/strings/str_/expand.rs | 1 - .../nu-command/src/strings/str_/index_of.rs | 1 - crates/nu-command/src/strings/str_/length.rs | 1 - crates/nu-command/src/strings/str_/replace.rs | 1 - crates/nu-command/src/strings/str_/reverse.rs | 1 - .../src/strings/str_/starts_with.rs | 1 - .../nu-command/src/strings/str_/substring.rs | 1 - .../nu-command/src/strings/str_/trim/trim_.rs | 1 - crates/nu-protocol/src/plugin_signature.rs | 5 -- crates/nu-protocol/src/signature.rs | 7 --- 67 files changed, 14 insertions(+), 125 deletions(-) diff --git a/crates/nu-cmd-extra/src/example_test.rs b/crates/nu-cmd-extra/src/example_test.rs index af353520ca..8ee7f1b1bf 100644 --- a/crates/nu-cmd-extra/src/example_test.rs +++ b/crates/nu-cmd-extra/src/example_test.rs @@ -43,7 +43,6 @@ mod test_examples { &mut make_engine_state(cmd.clone_box()), &signature.input_output_types, signature.operates_on_cell_paths(), - signature.vectorizes_over_list, ), ); check_example_evaluates_to_expected_output(&example, cwd.as_path(), &mut engine_state); diff --git a/crates/nu-cmd-extra/src/extra/bits/and.rs b/crates/nu-cmd-extra/src/extra/bits/and.rs index 104cbe7de6..5a3e245bdf 100644 --- a/crates/nu-cmd-extra/src/extra/bits/and.rs +++ b/crates/nu-cmd-extra/src/extra/bits/and.rs @@ -22,7 +22,6 @@ impl Command for BitsAnd { Type::List(Box::new(Type::Int)), ), ]) - .vectorizes_over_list(true) .required( "target", SyntaxShape::Int, diff --git a/crates/nu-cmd-extra/src/extra/bits/not.rs b/crates/nu-cmd-extra/src/extra/bits/not.rs index 851458f95a..4d21a26986 100644 --- a/crates/nu-cmd-extra/src/extra/bits/not.rs +++ b/crates/nu-cmd-extra/src/extra/bits/not.rs @@ -23,7 +23,6 @@ impl Command for BitsNot { Type::List(Box::new(Type::Int)), ), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .switch( "signed", diff --git a/crates/nu-cmd-extra/src/extra/bits/or.rs b/crates/nu-cmd-extra/src/extra/bits/or.rs index 41110e17cd..037d9cd78b 100644 --- a/crates/nu-cmd-extra/src/extra/bits/or.rs +++ b/crates/nu-cmd-extra/src/extra/bits/or.rs @@ -22,7 +22,6 @@ impl Command for BitsOr { Type::List(Box::new(Type::Int)), ), ]) - .vectorizes_over_list(true) .required( "target", SyntaxShape::Int, diff --git a/crates/nu-cmd-extra/src/extra/bits/rotate_left.rs b/crates/nu-cmd-extra/src/extra/bits/rotate_left.rs index 363c010428..6e9fe7480b 100644 --- a/crates/nu-cmd-extra/src/extra/bits/rotate_left.rs +++ b/crates/nu-cmd-extra/src/extra/bits/rotate_left.rs @@ -25,7 +25,6 @@ impl Command for BitsRol { Type::List(Box::new(Type::Int)), ), ]) - .vectorizes_over_list(true) .required("bits", SyntaxShape::Int, "number of bits to rotate left") .switch( "signed", diff --git a/crates/nu-cmd-extra/src/extra/bits/rotate_right.rs b/crates/nu-cmd-extra/src/extra/bits/rotate_right.rs index c9f4f9ce9f..f7edded5ff 100644 --- a/crates/nu-cmd-extra/src/extra/bits/rotate_right.rs +++ b/crates/nu-cmd-extra/src/extra/bits/rotate_right.rs @@ -25,7 +25,6 @@ impl Command for BitsRor { Type::List(Box::new(Type::Int)), ), ]) - .vectorizes_over_list(true) .required("bits", SyntaxShape::Int, "number of bits to rotate right") .switch( "signed", diff --git a/crates/nu-cmd-extra/src/extra/bits/shift_left.rs b/crates/nu-cmd-extra/src/extra/bits/shift_left.rs index 05289b282f..983513f5d6 100644 --- a/crates/nu-cmd-extra/src/extra/bits/shift_left.rs +++ b/crates/nu-cmd-extra/src/extra/bits/shift_left.rs @@ -25,7 +25,6 @@ impl Command for BitsShl { Type::List(Box::new(Type::Int)), ), ]) - .vectorizes_over_list(true) .required("bits", SyntaxShape::Int, "number of bits to shift left") .switch( "signed", diff --git a/crates/nu-cmd-extra/src/extra/bits/shift_right.rs b/crates/nu-cmd-extra/src/extra/bits/shift_right.rs index f94d81829d..dcb0a563e8 100644 --- a/crates/nu-cmd-extra/src/extra/bits/shift_right.rs +++ b/crates/nu-cmd-extra/src/extra/bits/shift_right.rs @@ -25,7 +25,6 @@ impl Command for BitsShr { Type::List(Box::new(Type::Int)), ), ]) - .vectorizes_over_list(true) .required("bits", SyntaxShape::Int, "number of bits to shift right") .switch( "signed", diff --git a/crates/nu-cmd-extra/src/extra/bits/xor.rs b/crates/nu-cmd-extra/src/extra/bits/xor.rs index c40d5ea587..7819af4336 100644 --- a/crates/nu-cmd-extra/src/extra/bits/xor.rs +++ b/crates/nu-cmd-extra/src/extra/bits/xor.rs @@ -22,7 +22,6 @@ impl Command for BitsXor { Type::List(Box::new(Type::Int)), ), ]) - .vectorizes_over_list(true) .required( "target", SyntaxShape::Int, diff --git a/crates/nu-cmd-extra/src/extra/bytes/add.rs b/crates/nu-cmd-extra/src/extra/bytes/add.rs index 1a64762481..a3aba96914 100644 --- a/crates/nu-cmd-extra/src/extra/bytes/add.rs +++ b/crates/nu-cmd-extra/src/extra/bytes/add.rs @@ -39,7 +39,6 @@ impl Command for BytesAdd { (Type::Table(vec![]), Type::Table(vec![])), (Type::Record(vec![]), Type::Record(vec![])), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .required("data", SyntaxShape::Binary, "the binary to add") .named( diff --git a/crates/nu-cmd-extra/src/extra/bytes/at.rs b/crates/nu-cmd-extra/src/extra/bytes/at.rs index 180d319bc1..2e60c88a46 100644 --- a/crates/nu-cmd-extra/src/extra/bytes/at.rs +++ b/crates/nu-cmd-extra/src/extra/bytes/at.rs @@ -46,7 +46,6 @@ impl Command for BytesAt { (Type::Table(vec![]), Type::Table(vec![])), (Type::Record(vec![]), Type::Record(vec![])), ]) - .vectorizes_over_list(true) .required("range", SyntaxShape::Range, "the range to get bytes") .rest( "rest", diff --git a/crates/nu-cmd-extra/src/extra/bytes/length.rs b/crates/nu-cmd-extra/src/extra/bytes/length.rs index 11e22eb1c2..bfca8fd6df 100644 --- a/crates/nu-cmd-extra/src/extra/bytes/length.rs +++ b/crates/nu-cmd-extra/src/extra/bytes/length.rs @@ -26,7 +26,6 @@ impl Command for BytesLen { (Type::Record(vec![]), Type::Record(vec![])), ]) .allow_variants_without_examples(true) - .vectorizes_over_list(true) .rest( "rest", SyntaxShape::CellPath, diff --git a/crates/nu-cmd-extra/src/extra/math/arccos.rs b/crates/nu-cmd-extra/src/extra/math/arccos.rs index 7be63d6a52..3798cea754 100644 --- a/crates/nu-cmd-extra/src/extra/math/arccos.rs +++ b/crates/nu-cmd-extra/src/extra/math/arccos.rs @@ -21,7 +21,6 @@ impl Command for SubCommand { ), ]) .allow_variants_without_examples(true) - .vectorizes_over_list(true) .category(Category::Math) } diff --git a/crates/nu-cmd-extra/src/extra/math/arccosh.rs b/crates/nu-cmd-extra/src/extra/math/arccosh.rs index 277a76dcd7..70acfcb6ae 100644 --- a/crates/nu-cmd-extra/src/extra/math/arccosh.rs +++ b/crates/nu-cmd-extra/src/extra/math/arccosh.rs @@ -20,7 +20,6 @@ impl Command for SubCommand { ), ]) .allow_variants_without_examples(true) - .vectorizes_over_list(true) .category(Category::Math) } diff --git a/crates/nu-cmd-extra/src/extra/math/arcsin.rs b/crates/nu-cmd-extra/src/extra/math/arcsin.rs index 501793c63e..774a4e76b6 100644 --- a/crates/nu-cmd-extra/src/extra/math/arcsin.rs +++ b/crates/nu-cmd-extra/src/extra/math/arcsin.rs @@ -21,7 +21,6 @@ impl Command for SubCommand { ), ]) .allow_variants_without_examples(true) - .vectorizes_over_list(true) .category(Category::Math) } diff --git a/crates/nu-cmd-extra/src/extra/math/arcsinh.rs b/crates/nu-cmd-extra/src/extra/math/arcsinh.rs index 719671e48d..72665a4cf7 100644 --- a/crates/nu-cmd-extra/src/extra/math/arcsinh.rs +++ b/crates/nu-cmd-extra/src/extra/math/arcsinh.rs @@ -20,7 +20,6 @@ impl Command for SubCommand { ), ]) .allow_variants_without_examples(true) - .vectorizes_over_list(true) .category(Category::Math) } diff --git a/crates/nu-cmd-extra/src/extra/math/arctan.rs b/crates/nu-cmd-extra/src/extra/math/arctan.rs index 284a6b8a5f..40d7f8927a 100644 --- a/crates/nu-cmd-extra/src/extra/math/arctan.rs +++ b/crates/nu-cmd-extra/src/extra/math/arctan.rs @@ -21,7 +21,6 @@ impl Command for SubCommand { ), ]) .allow_variants_without_examples(true) - .vectorizes_over_list(true) .category(Category::Math) } diff --git a/crates/nu-cmd-extra/src/extra/math/arctanh.rs b/crates/nu-cmd-extra/src/extra/math/arctanh.rs index 716cf8e339..9082cd0518 100644 --- a/crates/nu-cmd-extra/src/extra/math/arctanh.rs +++ b/crates/nu-cmd-extra/src/extra/math/arctanh.rs @@ -20,7 +20,6 @@ impl Command for SubCommand { ), ]) .allow_variants_without_examples(true) - .vectorizes_over_list(true) .category(Category::Math) } diff --git a/crates/nu-cmd-extra/src/extra/math/cos.rs b/crates/nu-cmd-extra/src/extra/math/cos.rs index 96486431c8..a7d899e474 100644 --- a/crates/nu-cmd-extra/src/extra/math/cos.rs +++ b/crates/nu-cmd-extra/src/extra/math/cos.rs @@ -20,7 +20,6 @@ impl Command for SubCommand { Type::List(Box::new(Type::Float)), ), ]) - .vectorizes_over_list(true) .category(Category::Math) } diff --git a/crates/nu-cmd-extra/src/extra/math/cosh.rs b/crates/nu-cmd-extra/src/extra/math/cosh.rs index 23f4d72b87..dcfd854e41 100644 --- a/crates/nu-cmd-extra/src/extra/math/cosh.rs +++ b/crates/nu-cmd-extra/src/extra/math/cosh.rs @@ -20,7 +20,6 @@ impl Command for SubCommand { ), ]) .allow_variants_without_examples(true) - .vectorizes_over_list(true) .category(Category::Math) } diff --git a/crates/nu-cmd-extra/src/extra/math/exp.rs b/crates/nu-cmd-extra/src/extra/math/exp.rs index 75fb15646d..5b7aa0cb3a 100644 --- a/crates/nu-cmd-extra/src/extra/math/exp.rs +++ b/crates/nu-cmd-extra/src/extra/math/exp.rs @@ -20,7 +20,6 @@ impl Command for SubCommand { ), ]) .allow_variants_without_examples(true) - .vectorizes_over_list(true) .category(Category::Math) } diff --git a/crates/nu-cmd-extra/src/extra/math/ln.rs b/crates/nu-cmd-extra/src/extra/math/ln.rs index d93e94080d..b6ce3ba30c 100644 --- a/crates/nu-cmd-extra/src/extra/math/ln.rs +++ b/crates/nu-cmd-extra/src/extra/math/ln.rs @@ -20,7 +20,6 @@ impl Command for SubCommand { ), ]) .allow_variants_without_examples(true) - .vectorizes_over_list(true) .category(Category::Math) } diff --git a/crates/nu-cmd-extra/src/extra/math/sin.rs b/crates/nu-cmd-extra/src/extra/math/sin.rs index 276163eb06..95b7994932 100644 --- a/crates/nu-cmd-extra/src/extra/math/sin.rs +++ b/crates/nu-cmd-extra/src/extra/math/sin.rs @@ -20,7 +20,6 @@ impl Command for SubCommand { Type::List(Box::new(Type::Float)), ), ]) - .vectorizes_over_list(true) .category(Category::Math) } diff --git a/crates/nu-cmd-extra/src/extra/math/sinh.rs b/crates/nu-cmd-extra/src/extra/math/sinh.rs index 24a7551724..490ac39104 100644 --- a/crates/nu-cmd-extra/src/extra/math/sinh.rs +++ b/crates/nu-cmd-extra/src/extra/math/sinh.rs @@ -20,7 +20,6 @@ impl Command for SubCommand { ), ]) .allow_variants_without_examples(true) - .vectorizes_over_list(true) .category(Category::Math) } diff --git a/crates/nu-cmd-extra/src/extra/math/tan.rs b/crates/nu-cmd-extra/src/extra/math/tan.rs index 65b8b61388..7470ef3a73 100644 --- a/crates/nu-cmd-extra/src/extra/math/tan.rs +++ b/crates/nu-cmd-extra/src/extra/math/tan.rs @@ -20,7 +20,6 @@ impl Command for SubCommand { Type::List(Box::new(Type::Float)), ), ]) - .vectorizes_over_list(true) .category(Category::Math) } diff --git a/crates/nu-cmd-extra/src/extra/math/tanh.rs b/crates/nu-cmd-extra/src/extra/math/tanh.rs index 2f4f99cbfc..0dbf6413fd 100644 --- a/crates/nu-cmd-extra/src/extra/math/tanh.rs +++ b/crates/nu-cmd-extra/src/extra/math/tanh.rs @@ -20,7 +20,6 @@ impl Command for SubCommand { ), ]) .allow_variants_without_examples(true) - .vectorizes_over_list(true) .category(Category::Math) } diff --git a/crates/nu-cmd-extra/src/extra/platform/ansi/gradient.rs b/crates/nu-cmd-extra/src/extra/platform/ansi/gradient.rs index 2bf71eb89b..ba9cd34e5b 100644 --- a/crates/nu-cmd-extra/src/extra/platform/ansi/gradient.rs +++ b/crates/nu-cmd-extra/src/extra/platform/ansi/gradient.rs @@ -53,7 +53,6 @@ impl Command for SubCommand { (Type::Table(vec![]), Type::Table(vec![])), (Type::Record(vec![]), Type::Record(vec![])), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .category(Category::Platform) } diff --git a/crates/nu-cmd-extra/src/extra/platform/ansi/link.rs b/crates/nu-cmd-extra/src/extra/platform/ansi/link.rs index a5505d66be..8d577de51d 100644 --- a/crates/nu-cmd-extra/src/extra/platform/ansi/link.rs +++ b/crates/nu-cmd-extra/src/extra/platform/ansi/link.rs @@ -39,7 +39,6 @@ impl Command for SubCommand { SyntaxShape::CellPath, "for a data structure input, add links to all strings at the given cell paths", ) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .category(Category::Platform) } diff --git a/crates/nu-cmd-extra/src/extra/strings/encode_decode/decode_hex.rs b/crates/nu-cmd-extra/src/extra/strings/encode_decode/decode_hex.rs index 1bba8c65a1..47cad46274 100644 --- a/crates/nu-cmd-extra/src/extra/strings/encode_decode/decode_hex.rs +++ b/crates/nu-cmd-extra/src/extra/strings/encode_decode/decode_hex.rs @@ -25,7 +25,6 @@ impl Command for DecodeHex { (Type::Record(vec![]), Type::Record(vec![])), ]) .allow_variants_without_examples(true) - .vectorizes_over_list(true) .rest( "rest", SyntaxShape::CellPath, diff --git a/crates/nu-cmd-extra/src/extra/strings/encode_decode/encode_hex.rs b/crates/nu-cmd-extra/src/extra/strings/encode_decode/encode_hex.rs index e0629684d9..80681e30f4 100644 --- a/crates/nu-cmd-extra/src/extra/strings/encode_decode/encode_hex.rs +++ b/crates/nu-cmd-extra/src/extra/strings/encode_decode/encode_hex.rs @@ -25,7 +25,6 @@ impl Command for EncodeHex { (Type::Record(vec![]), Type::Record(vec![])), ]) .allow_variants_without_examples(true) - .vectorizes_over_list(true) .rest( "rest", SyntaxShape::CellPath, diff --git a/crates/nu-cmd-lang/src/example_support.rs b/crates/nu-cmd-lang/src/example_support.rs index aac09d98a8..5076ad6bbc 100644 --- a/crates/nu-cmd-lang/src/example_support.rs +++ b/crates/nu-cmd-lang/src/example_support.rs @@ -12,7 +12,6 @@ pub fn check_example_input_and_output_types_match_command_signature( engine_state: &mut Box, signature_input_output_types: &Vec<(Type, Type)>, signature_operates_on_cell_paths: bool, - signature_vectorizes_over_list: bool, ) -> HashSet<(Type, Type)> { let mut witnessed_type_transformations = HashSet::<(Type, Type)>::new(); @@ -37,40 +36,6 @@ pub fn check_example_input_and_output_types_match_command_signature( } }); - // The example type checks as vectorization over an input list if both: - // 1. The command is declared to vectorize over list input. - // 2. There exists an entry t -> u in the type map such that the - // example_input_type is a subtype of list and the - // example_output_type is a subtype of list. - let example_matches_signature_via_vectorization_over_list = - signature_vectorizes_over_list - && match &example_input_type { - Type::List(ex_in_type) => { - match signature_input_output_types.iter().find_map( - |(sig_in_type, sig_out_type)| { - if ex_in_type.is_subtype(sig_in_type) { - Some((sig_in_type, sig_out_type)) - } else { - None - } - }, - ) { - Some((sig_in_type, sig_out_type)) => match &example_output_type { - Type::List(ex_out_type) - if ex_out_type.is_subtype(sig_out_type) => - { - witnessed_type_transformations - .insert((sig_in_type.clone(), sig_out_type.clone())); - true - } - _ => false, - }, - None => false, - } - } - _ => false, - }; - // The example type checks as a cell path operation if both: // 1. The command is declared to operate on cell paths. // 2. The example_input_type is list or record or table, and the example @@ -80,22 +45,22 @@ pub fn check_example_input_and_output_types_match_command_signature( // TODO: This is too permissive; it should make use of the signature.input_output_types at least. && example_output_type.to_shape() == example_input_type.to_shape(); - if !(example_matches_signature - || example_matches_signature_via_vectorization_over_list - || example_matches_signature_via_cell_path_operation) - { + if !(example_matches_signature || example_matches_signature_via_cell_path_operation) { panic!( - "The example `{}` demonstrates a transformation of type {:?} -> {:?}. \ + "The example `{}` demonstrates a transformation of type {:?} -> {:?}. \ However, this does not match the declared signature: {:?}.{} \ - For this command, `vectorizes_over_list` is {} and `operates_on_cell_paths()` is {}.", - example.example, - example_input_type, - example_output_type, - signature_input_output_types, - if signature_input_output_types.is_empty() { " (Did you forget to declare the input and output types for the command?)" } else { "" }, - signature_vectorizes_over_list, - signature_operates_on_cell_paths - ); + For this command `operates_on_cell_paths()` is {}.", + example.example, + example_input_type, + example_output_type, + signature_input_output_types, + if signature_input_output_types.is_empty() { + " (Did you forget to declare the input and output types for the command?)" + } else { + "" + }, + signature_operates_on_cell_paths + ); }; }; } diff --git a/crates/nu-cmd-lang/src/example_test.rs b/crates/nu-cmd-lang/src/example_test.rs index 336cf38a1a..fa74059f90 100644 --- a/crates/nu-cmd-lang/src/example_test.rs +++ b/crates/nu-cmd-lang/src/example_test.rs @@ -43,7 +43,6 @@ mod test_examples { &mut make_engine_state(cmd.clone_box()), &signature.input_output_types, signature.operates_on_cell_paths(), - signature.vectorizes_over_list, ), ); check_example_evaluates_to_expected_output(&example, cwd.as_path(), &mut engine_state); diff --git a/crates/nu-command/src/conversions/fill.rs b/crates/nu-command/src/conversions/fill.rs index 4572621d42..94205ebb69 100644 --- a/crates/nu-command/src/conversions/fill.rs +++ b/crates/nu-command/src/conversions/fill.rs @@ -54,7 +54,6 @@ impl Command for Fill { // General case for heterogeneous lists (Type::List(Box::new(Type::Any)), Type::List(Box::new(Type::String))), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .named( "width", diff --git a/crates/nu-command/src/conversions/into/filesize.rs b/crates/nu-command/src/conversions/into/filesize.rs index 3f97e86256..92b911057c 100644 --- a/crates/nu-command/src/conversions/into/filesize.rs +++ b/crates/nu-command/src/conversions/into/filesize.rs @@ -46,7 +46,6 @@ impl Command for SubCommand { ), ]) .allow_variants_without_examples(true) - .vectorizes_over_list(true) .rest( "rest", SyntaxShape::CellPath, diff --git a/crates/nu-command/src/conversions/into/int.rs b/crates/nu-command/src/conversions/into/int.rs index bf4d9c1129..f03c8e36c1 100644 --- a/crates/nu-command/src/conversions/into/int.rs +++ b/crates/nu-command/src/conversions/into/int.rs @@ -70,7 +70,6 @@ impl Command for SubCommand { Type::List(Box::new(Type::Int)), ), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .named("radix", SyntaxShape::Number, "radix of integer", Some('r')) .switch("little-endian", "use little-endian byte decoding", None) diff --git a/crates/nu-command/src/example_test.rs b/crates/nu-command/src/example_test.rs index 121ee76790..5026d1a136 100644 --- a/crates/nu-command/src/example_test.rs +++ b/crates/nu-command/src/example_test.rs @@ -46,7 +46,6 @@ mod test_examples { &mut make_engine_state(cmd.clone_box()), &signature.input_output_types, signature.operates_on_cell_paths(), - signature.vectorizes_over_list, ), ); check_example_evaluates_to_expected_output(&example, cwd.as_path(), &mut engine_state); diff --git a/crates/nu-command/src/math/abs.rs b/crates/nu-command/src/math/abs.rs index 2eeecb30b5..574a6b3bf8 100644 --- a/crates/nu-command/src/math/abs.rs +++ b/crates/nu-command/src/math/abs.rs @@ -19,7 +19,6 @@ impl Command for SubCommand { Type::List(Box::new(Type::Number)), ), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .category(Category::Math) } diff --git a/crates/nu-command/src/math/ceil.rs b/crates/nu-command/src/math/ceil.rs index ae7f181739..2dd26f769f 100644 --- a/crates/nu-command/src/math/ceil.rs +++ b/crates/nu-command/src/math/ceil.rs @@ -19,7 +19,6 @@ impl Command for SubCommand { Type::List(Box::new(Type::Number)), ), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .category(Category::Math) } diff --git a/crates/nu-command/src/math/floor.rs b/crates/nu-command/src/math/floor.rs index 5625417bf1..beab1159e2 100644 --- a/crates/nu-command/src/math/floor.rs +++ b/crates/nu-command/src/math/floor.rs @@ -19,7 +19,6 @@ impl Command for SubCommand { Type::List(Box::new(Type::Number)), ), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .category(Category::Math) } diff --git a/crates/nu-command/src/math/log.rs b/crates/nu-command/src/math/log.rs index 1276b8d17d..dcc91e6943 100644 --- a/crates/nu-command/src/math/log.rs +++ b/crates/nu-command/src/math/log.rs @@ -29,7 +29,6 @@ impl Command for SubCommand { ), ]) .allow_variants_without_examples(true) - .vectorizes_over_list(true) .category(Category::Math) } diff --git a/crates/nu-command/src/math/round.rs b/crates/nu-command/src/math/round.rs index aee5f54c2f..ebe60b23dc 100644 --- a/crates/nu-command/src/math/round.rs +++ b/crates/nu-command/src/math/round.rs @@ -22,7 +22,6 @@ impl Command for SubCommand { Type::List(Box::new(Type::Number)), ), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .named( "precision", diff --git a/crates/nu-command/src/math/sqrt.rs b/crates/nu-command/src/math/sqrt.rs index f67f42b06c..85b3134ff6 100644 --- a/crates/nu-command/src/math/sqrt.rs +++ b/crates/nu-command/src/math/sqrt.rs @@ -19,7 +19,6 @@ impl Command for SubCommand { Type::List(Box::new(Type::Number)), ), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .category(Category::Math) } diff --git a/crates/nu-command/src/network/url/encode.rs b/crates/nu-command/src/network/url/encode.rs index 5fb8627d8f..df15969233 100644 --- a/crates/nu-command/src/network/url/encode.rs +++ b/crates/nu-command/src/network/url/encode.rs @@ -24,7 +24,6 @@ impl Command for SubCommand { (Type::Record(vec![]), Type::Record(vec![])), ]) .allow_variants_without_examples(true) - .vectorizes_over_list(true) .switch( "all", "encode all non-alphanumeric chars including `/`, `.`, `:`", diff --git a/crates/nu-command/src/strings/encode_decode/decode_base64.rs b/crates/nu-command/src/strings/encode_decode/decode_base64.rs index 27dcd72ad6..7ef209f3a0 100644 --- a/crates/nu-command/src/strings/encode_decode/decode_base64.rs +++ b/crates/nu-command/src/strings/encode_decode/decode_base64.rs @@ -29,7 +29,6 @@ impl Command for DecodeBase64 { (Type::Table(vec![]), Type::Table(vec![])), (Type::Record(vec![]), Type::Record(vec![])), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .named( "character-set", diff --git a/crates/nu-command/src/strings/encode_decode/encode_base64.rs b/crates/nu-command/src/strings/encode_decode/encode_base64.rs index 91adaf9a1c..b38476c659 100644 --- a/crates/nu-command/src/strings/encode_decode/encode_base64.rs +++ b/crates/nu-command/src/strings/encode_decode/encode_base64.rs @@ -35,7 +35,6 @@ impl Command for EncodeBase64 { (Type::Table(vec![]), Type::Table(vec![])), (Type::Record(vec![]), Type::Record(vec![])), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .named( "character-set", diff --git a/crates/nu-command/src/strings/split/row.rs b/crates/nu-command/src/strings/split/row.rs index 2ee5c83fb4..71cc0bc7c3 100644 --- a/crates/nu-command/src/strings/split/row.rs +++ b/crates/nu-command/src/strings/split/row.rs @@ -20,7 +20,6 @@ impl Command for SubCommand { (Type::String, Type::List(Box::new(Type::String))), (Type::List(Box::new(Type::String)), Type::Table(vec![])), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .required( "separator", diff --git a/crates/nu-command/src/strings/str_/case/camel_case.rs b/crates/nu-command/src/strings/str_/case/camel_case.rs index 982bdc08d0..725ee2ce8a 100644 --- a/crates/nu-command/src/strings/str_/case/camel_case.rs +++ b/crates/nu-command/src/strings/str_/case/camel_case.rs @@ -26,7 +26,6 @@ impl Command for SubCommand { (Type::Table(vec![]), Type::Table(vec![])), (Type::Record(vec![]), Type::Record(vec![])), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .rest( "rest", diff --git a/crates/nu-command/src/strings/str_/case/capitalize.rs b/crates/nu-command/src/strings/str_/case/capitalize.rs index 21411041bb..2f105a85e8 100644 --- a/crates/nu-command/src/strings/str_/case/capitalize.rs +++ b/crates/nu-command/src/strings/str_/case/capitalize.rs @@ -24,7 +24,6 @@ impl Command for SubCommand { (Type::Table(vec![]), Type::Table(vec![])), (Type::Record(vec![]), Type::Record(vec![])), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .rest( "rest", diff --git a/crates/nu-command/src/strings/str_/case/downcase.rs b/crates/nu-command/src/strings/str_/case/downcase.rs index 3405b4e532..4bfbe69682 100644 --- a/crates/nu-command/src/strings/str_/case/downcase.rs +++ b/crates/nu-command/src/strings/str_/case/downcase.rs @@ -24,7 +24,6 @@ impl Command for SubCommand { (Type::Table(vec![]), Type::Table(vec![])), (Type::Record(vec![]), Type::Record(vec![])), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .rest( "rest", diff --git a/crates/nu-command/src/strings/str_/case/kebab_case.rs b/crates/nu-command/src/strings/str_/case/kebab_case.rs index 613d1207d2..b33fe24143 100644 --- a/crates/nu-command/src/strings/str_/case/kebab_case.rs +++ b/crates/nu-command/src/strings/str_/case/kebab_case.rs @@ -26,7 +26,6 @@ impl Command for SubCommand { Type::List(Box::new(Type::String)), ), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .rest( "rest", diff --git a/crates/nu-command/src/strings/str_/case/pascal_case.rs b/crates/nu-command/src/strings/str_/case/pascal_case.rs index cdcf6b5e50..29bfa974b9 100644 --- a/crates/nu-command/src/strings/str_/case/pascal_case.rs +++ b/crates/nu-command/src/strings/str_/case/pascal_case.rs @@ -26,7 +26,6 @@ impl Command for SubCommand { Type::List(Box::new(Type::String)), ), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .rest( "rest", diff --git a/crates/nu-command/src/strings/str_/case/screaming_snake_case.rs b/crates/nu-command/src/strings/str_/case/screaming_snake_case.rs index 9423fe4460..97dea22778 100644 --- a/crates/nu-command/src/strings/str_/case/screaming_snake_case.rs +++ b/crates/nu-command/src/strings/str_/case/screaming_snake_case.rs @@ -25,7 +25,6 @@ impl Command for SubCommand { (Type::Table(vec![]), Type::Table(vec![])), (Type::Record(vec![]), Type::Record(vec![])), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .rest( "rest", diff --git a/crates/nu-command/src/strings/str_/case/snake_case.rs b/crates/nu-command/src/strings/str_/case/snake_case.rs index 00a5fd4032..16b3bd977e 100644 --- a/crates/nu-command/src/strings/str_/case/snake_case.rs +++ b/crates/nu-command/src/strings/str_/case/snake_case.rs @@ -25,7 +25,6 @@ impl Command for SubCommand { (Type::Table(vec![]), Type::Table(vec![])), (Type::Record(vec![]), Type::Record(vec![])), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .rest( "rest", diff --git a/crates/nu-command/src/strings/str_/case/title_case.rs b/crates/nu-command/src/strings/str_/case/title_case.rs index 4ed50f5b13..67968ae012 100644 --- a/crates/nu-command/src/strings/str_/case/title_case.rs +++ b/crates/nu-command/src/strings/str_/case/title_case.rs @@ -26,7 +26,6 @@ impl Command for SubCommand { (Type::Table(vec![]), Type::Table(vec![])), (Type::Record(vec![]), Type::Record(vec![])), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .rest( "rest", diff --git a/crates/nu-command/src/strings/str_/case/upcase.rs b/crates/nu-command/src/strings/str_/case/upcase.rs index 9154b0c280..a4d580502d 100644 --- a/crates/nu-command/src/strings/str_/case/upcase.rs +++ b/crates/nu-command/src/strings/str_/case/upcase.rs @@ -23,7 +23,6 @@ impl Command for SubCommand { (Type::Table(vec![]), Type::Table(vec![])), (Type::Record(vec![]), Type::Record(vec![])), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .rest( "rest", diff --git a/crates/nu-command/src/strings/str_/contains.rs b/crates/nu-command/src/strings/str_/contains.rs index eebb9cf959..e9ddf3eb83 100644 --- a/crates/nu-command/src/strings/str_/contains.rs +++ b/crates/nu-command/src/strings/str_/contains.rs @@ -36,7 +36,6 @@ impl Command for SubCommand { (Type::Record(vec![]), Type::Record(vec![])), (Type::List(Box::new(Type::String)), Type::List(Box::new(Type::Bool))) ]) - .vectorizes_over_list(true) .required("string", SyntaxShape::String, "the substring to find") .rest( "rest", diff --git a/crates/nu-command/src/strings/str_/ends_with.rs b/crates/nu-command/src/strings/str_/ends_with.rs index a93027a7e6..e3d8311bcc 100644 --- a/crates/nu-command/src/strings/str_/ends_with.rs +++ b/crates/nu-command/src/strings/str_/ends_with.rs @@ -35,7 +35,6 @@ impl Command for SubCommand { (Type::Record(vec![]), Type::Record(vec![])), ]) .allow_variants_without_examples(true) - .vectorizes_over_list(true) .required("string", SyntaxShape::String, "the string to match") .rest( "rest", diff --git a/crates/nu-command/src/strings/str_/expand.rs b/crates/nu-command/src/strings/str_/expand.rs index 15a6d2c731..de11f10c47 100644 --- a/crates/nu-command/src/strings/str_/expand.rs +++ b/crates/nu-command/src/strings/str_/expand.rs @@ -29,7 +29,6 @@ impl Command for SubCommand { Type::List(Box::new(Type::List(Box::new(Type::String)))), ), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .category(Category::Strings) } diff --git a/crates/nu-command/src/strings/str_/index_of.rs b/crates/nu-command/src/strings/str_/index_of.rs index 51179217a3..3b9f877b43 100644 --- a/crates/nu-command/src/strings/str_/index_of.rs +++ b/crates/nu-command/src/strings/str_/index_of.rs @@ -43,7 +43,6 @@ impl Command for SubCommand { (Type::Table(vec![]), Type::Table(vec![])), (Type::Record(vec![]), Type::Record(vec![])), ]) - .vectorizes_over_list(true) // TODO: no test coverage .allow_variants_without_examples(true) .required("string", SyntaxShape::String, "the string to find in the input") .switch( diff --git a/crates/nu-command/src/strings/str_/length.rs b/crates/nu-command/src/strings/str_/length.rs index 98a49aea02..5f08a7dd7f 100644 --- a/crates/nu-command/src/strings/str_/length.rs +++ b/crates/nu-command/src/strings/str_/length.rs @@ -36,7 +36,6 @@ impl Command for SubCommand { (Type::Record(vec![]), Type::Record(vec![])), ]) .allow_variants_without_examples(true) - .vectorizes_over_list(true) .switch( "grapheme-clusters", "count length using grapheme clusters (all visible chars have length 1)", diff --git a/crates/nu-command/src/strings/str_/replace.rs b/crates/nu-command/src/strings/str_/replace.rs index 22fa3b4674..80d4060eaa 100644 --- a/crates/nu-command/src/strings/str_/replace.rs +++ b/crates/nu-command/src/strings/str_/replace.rs @@ -44,7 +44,6 @@ impl Command for SubCommand { Type::List(Box::new(Type::String)), ), ]) - .vectorizes_over_list(true) .required("find", SyntaxShape::String, "the pattern to find") .required("replace", SyntaxShape::String, "the replacement string") .rest( diff --git a/crates/nu-command/src/strings/str_/reverse.rs b/crates/nu-command/src/strings/str_/reverse.rs index 18c9d59c07..f3fa11cb96 100644 --- a/crates/nu-command/src/strings/str_/reverse.rs +++ b/crates/nu-command/src/strings/str_/reverse.rs @@ -26,7 +26,6 @@ impl Command for SubCommand { (Type::Record(vec![]), Type::Record(vec![])), ]) .allow_variants_without_examples(true) - .vectorizes_over_list(true) .rest( "rest", SyntaxShape::CellPath, diff --git a/crates/nu-command/src/strings/str_/starts_with.rs b/crates/nu-command/src/strings/str_/starts_with.rs index 72541dc9f1..9a44551b99 100644 --- a/crates/nu-command/src/strings/str_/starts_with.rs +++ b/crates/nu-command/src/strings/str_/starts_with.rs @@ -36,7 +36,6 @@ impl Command for SubCommand { (Type::Table(vec![]), Type::Table(vec![])), (Type::Record(vec![]), Type::Record(vec![])), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .required("string", SyntaxShape::String, "the string to match") .rest( diff --git a/crates/nu-command/src/strings/str_/substring.rs b/crates/nu-command/src/strings/str_/substring.rs index 0058ff9468..44843e8311 100644 --- a/crates/nu-command/src/strings/str_/substring.rs +++ b/crates/nu-command/src/strings/str_/substring.rs @@ -48,7 +48,6 @@ impl Command for SubCommand { (Type::Table(vec![]), Type::Table(vec![])), (Type::Record(vec![]), Type::Record(vec![])), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .switch( "grapheme-clusters", diff --git a/crates/nu-command/src/strings/str_/trim/trim_.rs b/crates/nu-command/src/strings/str_/trim/trim_.rs index 3b06d2c9f9..9fb994a0e0 100644 --- a/crates/nu-command/src/strings/str_/trim/trim_.rs +++ b/crates/nu-command/src/strings/str_/trim/trim_.rs @@ -44,7 +44,6 @@ impl Command for SubCommand { (Type::Table(vec![]), Type::Table(vec![])), (Type::Record(vec![]), Type::Record(vec![])), ]) - .vectorizes_over_list(true) .allow_variants_without_examples(true) .rest( "rest", diff --git a/crates/nu-protocol/src/plugin_signature.rs b/crates/nu-protocol/src/plugin_signature.rs index 5c9dd06996..b4ac8deb48 100644 --- a/crates/nu-protocol/src/plugin_signature.rs +++ b/crates/nu-protocol/src/plugin_signature.rs @@ -143,11 +143,6 @@ impl PluginSignature { self } - pub fn vectorizes_over_list(mut self, vectorizes_over_list: bool) -> PluginSignature { - self.sig = self.sig.vectorizes_over_list(vectorizes_over_list); - self - } - /// Set the input-output type signature variants of the command pub fn input_output_types(mut self, input_output_types: Vec<(Type, Type)>) -> PluginSignature { self.sig = self.sig.input_output_types(input_output_types); diff --git a/crates/nu-protocol/src/signature.rs b/crates/nu-protocol/src/signature.rs index 99026397d9..ad2b65f7f0 100644 --- a/crates/nu-protocol/src/signature.rs +++ b/crates/nu-protocol/src/signature.rs @@ -112,7 +112,6 @@ pub struct Signature { pub required_positional: Vec, pub optional_positional: Vec, pub rest_positional: Option, - pub vectorizes_over_list: bool, pub named: Vec, pub input_output_types: Vec<(Type, Type)>, pub allow_variants_without_examples: bool, @@ -212,7 +211,6 @@ impl Signature { required_positional: vec![], optional_positional: vec![], rest_positional: None, - vectorizes_over_list: false, input_output_types: vec![], allow_variants_without_examples: false, named: vec![], @@ -464,11 +462,6 @@ impl Signature { self } - pub fn vectorizes_over_list(mut self, vectorizes_over_list: bool) -> Signature { - self.vectorizes_over_list = vectorizes_over_list; - self - } - /// Set the input-output type signature variants of the command pub fn input_output_types(mut self, input_output_types: Vec<(Type, Type)>) -> Signature { self.input_output_types = input_output_types;