From 634470b1b87e078efd755a187c0c5cce324f422e Mon Sep 17 00:00:00 2001 From: Damir Shamanaev Date: Fri, 28 Nov 2025 16:41:37 +0400 Subject: [PATCH 1/2] formats tests in sui_mode --- .../generic_and_generic_object_params.move | 2 +- .../generic_obj_mut_ref_vector.move | 4 +- .../generic_obj_mut_ref_vector.snap | 10 ++-- .../entry_points/generic_obj_ref_vector.move | 3 +- .../entry_points/generic_obj_ref_vector.snap | 10 ++-- .../generic_param_after_primitive.move | 3 +- .../generic_with_key_invalid.move | 5 +- .../generic_with_key_invalid.snap | 20 +++---- .../entry_points/generic_with_key_valid.move | 3 +- .../tests/sui_mode/entry_points/id.move | 7 +-- .../entry_points/immut_receiving_ref.move | 4 +- .../entry_points/mut_receiving_ref.move | 4 +- .../entry_points/non_key_struct_generic.move | 1 - .../entry_points/non_key_struct_vector.move | 1 - .../sui_mode/entry_points/obj_ref_vector.move | 1 - .../tests/sui_mode/entry_points/ok.move | 1 + .../tests/sui_mode/entry_points/option.move | 1 - .../entry_points/optional_txn_context.move | 1 + .../receiving_non_object_type.move | 2 +- .../receiving_with_object_type.move | 4 +- .../sui_mode/entry_points/return_values.move | 1 + .../entry_points/return_values_invalid.move | 9 ++- .../entry_points/return_values_invalid.snap | 22 +++---- .../entry_points/single_type_param.move | 1 - .../single_type_param_generic_object.move | 3 +- .../entry_points/single_type_param_key.move | 3 +- .../tests/sui_mode/entry_points/string.move | 2 +- .../id_leak/derived_object_no_leak.move | 40 ++++++------- .../id_leak/direct_leak_through_call.move | 1 - .../id_leak/indirect_leak_through_call.move | 3 - .../tests/sui_mode/id_leak/infinite_loop.move | 8 ++- .../tests/sui_mode/id_leak/loop.move | 8 ++- .../tests/sui_mode/id_leak/private_pack.move | 7 ++- .../tests/sui_mode/id_leak/private_pack.snap | 4 +- .../through_call_with_borrow_field.move | 1 - .../id_leak/through_indirect_return.move | 1 - .../tests/sui_mode/id_leak/through_pack.move | 8 +-- .../sui_mode/id_leak/through_reference.move | 1 - .../sui_mode/id_leak/through_reference.snap | 2 +- .../sui_mode/id_leak/through_vector.move | 1 - .../tests/sui_mode/id_leak/transmute.move | 4 +- .../tests/sui_mode/init/cannot_call_init.move | 1 + .../tests/sui_mode/init/cannot_call_init.snap | 12 ++-- .../tests/sui_mode/init/imm_tx_context.move | 1 + .../sui_mode/init/must_have_txn_context.move | 1 + .../sui_mode/init/must_have_txn_context.snap | 4 +- .../tests/sui_mode/init/not_generic.move | 1 + .../tests/sui_mode/init/not_generic.snap | 4 +- .../tests/sui_mode/init/not_private.move | 5 +- .../tests/sui_mode/init/not_private.snap | 12 ++-- .../tests/sui_mode/init/not_txn_context.move | 2 + .../tests/sui_mode/init/not_txn_context.snap | 8 +-- .../move-compiler/tests/sui_mode/init/ok.move | 4 +- .../tests/sui_mode/init/return_values.move | 1 + .../tests/sui_mode/init/return_values.snap | 4 +- .../tests/sui_mode/linter/coin_field.move | 6 +- .../sui_mode/linter/collection_equality.move | 31 +++++----- .../sui_mode/linter/collection_equality.snap | 34 +++++------ .../sui_mode/linter/custom_state_change.move | 6 +- .../linter/edge_case_lint_missing_key.move | 1 - .../linter/false_positive_share_owned.move | 17 ++++-- .../false_unnecessary_public_entry.move | 1 + .../tests/sui_mode/linter/freeze_wrapped.move | 11 ++-- .../tests/sui_mode/linter/freeze_wrapped.snap | 28 ++++----- .../freezing_capability_false_negatives.move | 9 +-- .../freezing_capability_false_positives.move | 9 +-- .../freezing_capability_suppression.move | 7 ++- .../freezing_capability_true_negatives.move | 15 ++--- .../freezing_capability_true_positives.move | 7 ++- .../linter/lint_all_syntax_missing.move | 1 + .../linter/public_random_invalid.move | 3 + .../linter/public_random_invalid.snap | 28 ++++----- .../sui_mode/linter/public_random_valid.move | 1 + .../tests/sui_mode/linter/self_transfer.move | 30 ++++++---- .../tests/sui_mode/linter/self_transfer.snap | 20 +++---- .../linter/suppress_lint_missing_key.move | 2 +- .../suppress_public_mut_tx_context.move | 9 +-- .../suppress_unnecessary_public_entry.move | 3 +- .../linter/trigger_lint_missing_key.move | 1 - .../true_negative_public_mut_tx_context.move | 11 +--- .../linter/true_negative_share_owned.move | 22 ++++--- .../true_positive_public_mut_tx_context.move | 8 +-- .../true_positive_public_mut_tx_context.snap | 14 ++--- .../linter/true_positive_share_owned.move | 15 +++-- .../linter/true_unnecessary_public_entry.move | 5 +- .../linter/true_unnecessary_public_entry.snap | 6 +- .../expansion/implicit_sui_aliases.move | 6 +- .../expansion/unnecessary_alias_default.move | 4 +- .../expansion/unnecessary_alias_default.snap | 48 +++++++-------- .../typing/deprecated_transitive.move | 26 ++++---- .../typing/deprecated_unused_field.move | 14 ++--- .../typing/enum_in_struct_position.move | 51 ++++++++-------- .../typing/enum_in_struct_position.snap | 50 ++++++++-------- .../init_many_wrong_parameters.move | 1 + .../init_many_wrong_parameters.snap | 8 +-- .../one_time_witness/init_unbound_type.move | 1 + .../one_time_witness/init_unbound_type.snap | 4 +- .../one_time_witness/instantiate.move | 3 +- .../one_time_witness/instantiate.snap | 4 +- .../one_time_witness/many_fields_invalid.move | 5 +- .../one_time_witness/many_fields_invalid.snap | 4 +- .../one_time_witness/many_fields_valid.move | 2 +- .../one_time_witness/more_abilities.move | 16 ++--- .../one_time_witness/more_abilities.snap | 18 +++--- .../sui_mode/one_time_witness/no_field.move | 4 +- .../one_time_witness/no_init_arg.move | 3 +- .../one_time_witness/no_init_arg.snap | 2 +- .../one_time_witness/other_mod_def.move | 5 +- .../one_time_witness/other_mod_def.snap | 2 +- .../sui_mode/one_time_witness/type_param.move | 6 +- .../sui_mode/one_time_witness/type_param.snap | 14 ++--- .../one_time_witness/wrong_field_type.move | 7 +-- .../wrong_field_type_and_extra_field.move | 4 +- ..._field_type_and_extra_field_with_init.move | 4 +- ..._field_type_and_extra_field_with_init.snap | 2 +- .../wrong_field_type_with_init.move | 3 +- .../wrong_field_type_with_init.snap | 2 +- .../one_time_witness/wrong_init_type.move | 3 +- .../one_time_witness/wrong_init_type.snap | 2 +- .../sui_mode/one_time_witness/wrong_name.move | 3 +- .../sui_mode/one_time_witness/wrong_name.snap | 2 +- .../one_time_witness/wrong_name_format.move | 3 +- .../one_time_witness/wrong_name_format.snap | 2 +- .../private_generics/new_currency.move | 60 +++++++++---------- .../private_generics/new_currency.snap | 12 ++-- .../private_generics/no_public_transfer.move | 4 +- .../no_public_transfer_generic.move | 4 +- .../no_public_transfer_store.move | 4 +- .../no_public_transfer_store_generic.move | 4 +- .../private_event_emit_authenticated.move | 3 +- .../public_transfer_with_store.move | 5 +- .../public_transfer_with_store_generic.move | 8 ++- .../key_struct_first_field_not_id.move | 2 +- .../key_struct_first_field_not_id.snap | 2 +- ...uct_id_field_incorrect_struct_address.move | 4 +- ...uct_id_field_incorrect_struct_address.snap | 4 +- ...struct_id_field_incorrect_struct_name.move | 3 +- ...struct_id_field_incorrect_struct_name.snap | 6 +- .../key_struct_id_field_incorrect_type.move | 2 +- .../key_struct_id_field_incorrect_type.snap | 2 +- .../key_struct_id_field_valid.move | 3 +- .../key_struct_second_field_id.move | 1 + .../key_struct_second_field_id.snap | 12 ++-- .../struct_with_key/key_struct_with_drop.move | 3 +- .../struct_with_key/key_struct_with_drop.snap | 6 +- .../struct_with_key/unused_id_field.move | 1 + 146 files changed, 578 insertions(+), 553 deletions(-) diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_and_generic_object_params.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_and_generic_object_params.move index 3bf0c80969db4..564aed07e8939 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_and_generic_object_params.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_and_generic_object_params.move @@ -1,5 +1,6 @@ module a::m { use sui::object; + struct Obj has key { id: object::UID, value: T, @@ -8,7 +9,6 @@ module a::m { public entry fun foo(_: T0, _: Obj) { abort 0 } - } module sui::object { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_obj_mut_ref_vector.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_obj_mut_ref_vector.move index 08757ebc94c6e..51a094393bf07 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_obj_mut_ref_vector.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_obj_mut_ref_vector.move @@ -1,9 +1,7 @@ // invalid, a mutable reference to vector of objects module a::m { - - public entry fun no(_: &mut vector) { + public entry fun no(_: &mut vector) { abort 0 } - } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_obj_mut_ref_vector.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_obj_mut_ref_vector.snap index 90ee85125696d..70fa511be31a5 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_obj_mut_ref_vector.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_obj_mut_ref_vector.snap @@ -6,10 +6,10 @@ info: lint: false --- error[Sui E02002]: invalid 'entry' function signature - ┌─ tests/sui_mode/entry_points/generic_obj_mut_ref_vector.move:5:32 + ┌─ tests/sui_mode/entry_points/generic_obj_mut_ref_vector.move:4:33 │ -5 │ public entry fun no(_: &mut vector) { - │ ----- ^ -------------- 'entry' parameters must be primitives (by-value), vectors of primitives, objects (by-reference or by-value), vectors of objects, or 'Receiving' arguments (by-reference or by-value) - │ │ │ - │ │ Invalid 'entry' parameter type for parameter '_' +4 │ public entry fun no(_: &mut vector) { + │ ----- ^ -------------- 'entry' parameters must be primitives (by-value), vectors of primitives, objects (by-reference or by-value), vectors of objects, or 'Receiving' arguments (by-reference or by-value) + │ │ │ + │ │ Invalid 'entry' parameter type for parameter '_' │ 'no' was declared 'entry' here diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_obj_ref_vector.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_obj_ref_vector.move index 941af53b5baaf..c500aacd8ffed 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_obj_ref_vector.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_obj_ref_vector.move @@ -1,8 +1,7 @@ // invalid, a mutable reference to vector of objects module a::m { - public entry fun no(_: &vector) { + public entry fun no(_: &vector) { abort 0 } - } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_obj_ref_vector.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_obj_ref_vector.snap index 7a96ea14b52f5..dcf665f6eaf70 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_obj_ref_vector.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_obj_ref_vector.snap @@ -6,10 +6,10 @@ info: lint: false --- error[Sui E02002]: invalid 'entry' function signature - ┌─ tests/sui_mode/entry_points/generic_obj_ref_vector.move:4:32 + ┌─ tests/sui_mode/entry_points/generic_obj_ref_vector.move:4:33 │ -4 │ public entry fun no(_: &vector) { - │ ----- ^ ---------- 'entry' parameters must be primitives (by-value), vectors of primitives, objects (by-reference or by-value), vectors of objects, or 'Receiving' arguments (by-reference or by-value) - │ │ │ - │ │ Invalid 'entry' parameter type for parameter '_' +4 │ public entry fun no(_: &vector) { + │ ----- ^ ---------- 'entry' parameters must be primitives (by-value), vectors of primitives, objects (by-reference or by-value), vectors of objects, or 'Receiving' arguments (by-reference or by-value) + │ │ │ + │ │ Invalid 'entry' parameter type for parameter '_' │ 'no' was declared 'entry' here diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_param_after_primitive.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_param_after_primitive.move index 3c34970a116a2..5db296dbf8176 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_param_after_primitive.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_param_after_primitive.move @@ -1,12 +1,13 @@ module a::m { use sui::object; + struct Obj has key { id: object::UID, } + public entry fun foo(_: Obj, _: u64, _: T) { abort 0 } - } module sui::object { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_with_key_invalid.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_with_key_invalid.move index 45154d5ba4ac3..3421e06145810 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_with_key_invalid.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_with_key_invalid.move @@ -3,12 +3,11 @@ module a::m { use std::option; - public entry fun t(_: option::Option) { + public entry fun t(_: option::Option) { abort 0 } - public entry fun t2(_: vector>) { + public entry fun t2(_: vector>) { abort 0 } - } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_with_key_invalid.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_with_key_invalid.snap index 03a0ae81e7368..9ede5182fc280 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_with_key_invalid.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_with_key_invalid.snap @@ -6,19 +6,19 @@ info: lint: false --- error[Sui E02002]: invalid 'entry' function signature - ┌─ tests/sui_mode/entry_points/generic_with_key_invalid.move:6:31 + ┌─ tests/sui_mode/entry_points/generic_with_key_invalid.move:6:32 │ -6 │ public entry fun t(_: option::Option) { - │ ----- ^ ----------------- 'entry' parameters must be primitives (by-value), vectors of primitives, objects (by-reference or by-value), vectors of objects, or 'Receiving' arguments (by-reference or by-value) - │ │ │ - │ │ Invalid 'entry' parameter type for parameter '_' +6 │ public entry fun t(_: option::Option) { + │ ----- ^ ----------------- 'entry' parameters must be primitives (by-value), vectors of primitives, objects (by-reference or by-value), vectors of objects, or 'Receiving' arguments (by-reference or by-value) + │ │ │ + │ │ Invalid 'entry' parameter type for parameter '_' │ 't' was declared 'entry' here error[Sui E02002]: invalid 'entry' function signature - ┌─ tests/sui_mode/entry_points/generic_with_key_invalid.move:10:32 + ┌─ tests/sui_mode/entry_points/generic_with_key_invalid.move:10:33 │ -10 │ public entry fun t2(_: vector>) { - │ ----- ^ ------------------------- 'entry' parameters must be primitives (by-value), vectors of primitives, objects (by-reference or by-value), vectors of objects, or 'Receiving' arguments (by-reference or by-value) - │ │ │ - │ │ Invalid 'entry' parameter type for parameter '_' +10 │ public entry fun t2(_: vector>) { + │ ----- ^ ------------------------- 'entry' parameters must be primitives (by-value), vectors of primitives, objects (by-reference or by-value), vectors of objects, or 'Receiving' arguments (by-reference or by-value) + │ │ │ + │ │ Invalid 'entry' parameter type for parameter '_' │ 't2' was declared 'entry' here diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_with_key_valid.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_with_key_valid.move index 66706ac5be2c7..869ba1157da64 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_with_key_valid.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/generic_with_key_valid.move @@ -1,8 +1,7 @@ // valid, type parameters with key are valid as long as they are not nested module a::m { - public entry fun yes(_: T, _: &T, _: &mut T) { + public entry fun yes(_: T, _: &T, _: &mut T) { abort 0 } - } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/id.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/id.move index 329a729f02636..e078940ccdac4 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/id.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/id.move @@ -3,14 +3,9 @@ module a::m { use sui::object; - public entry fun yes( - _: object::ID, - _: vector, - _: vector>, - ) { + public entry fun yes(_: object::ID, _: vector, _: vector>) { abort 0 } - } module sui::object { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/immut_receiving_ref.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/immut_receiving_ref.move index 3af390d56a3de..0622fc113f0af 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/immut_receiving_ref.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/immut_receiving_ref.move @@ -6,7 +6,7 @@ module a::m { struct S has key { id: object::UID } - public entry fun yes(_: &Receiving) { } + public entry fun yes(_: &Receiving) {} } module sui::object { @@ -17,6 +17,6 @@ module sui::object { module sui::transfer { struct Receiving has drop { - id: address + id: address, } } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/mut_receiving_ref.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/mut_receiving_ref.move index fbaead9a07fa7..86f332dad8431 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/mut_receiving_ref.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/mut_receiving_ref.move @@ -6,7 +6,7 @@ module a::m { struct S has key { id: object::UID } - public entry fun yes(_: &mut Receiving) { } + public entry fun yes(_: &mut Receiving) {} } module sui::object { @@ -17,6 +17,6 @@ module sui::object { module sui::transfer { struct Receiving has drop { - id: address + id: address, } } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/non_key_struct_generic.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/non_key_struct_generic.move index 193f66cebe85b..beb314fa1ee43 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/non_key_struct_generic.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/non_key_struct_generic.move @@ -14,7 +14,6 @@ module a::m { public entry fun t2(_: Obj) { abort 0 } - } module sui::object { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/non_key_struct_vector.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/non_key_struct_vector.move index 9c1772bf00166..dbd3a48d25455 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/non_key_struct_vector.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/non_key_struct_vector.move @@ -6,5 +6,4 @@ module a::m { public entry fun no(_: vector) { abort 0 } - } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/obj_ref_vector.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/obj_ref_vector.move index 0a99828f35527..584b0d11806e3 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/obj_ref_vector.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/obj_ref_vector.move @@ -8,7 +8,6 @@ module a::m { public entry fun no(_: &vector) { abort 0 } - } module sui::object { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/ok.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/ok.move index de87879a96e49..e3b6b6b5dcc16 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/ok.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/ok.move @@ -2,6 +2,7 @@ module a::m { use sui::tx_context; + public entry fun f(_: &tx_context::TxContext) { abort 0 } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/option.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/option.move index 001e7aaac1779..14ec64134fdd9 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/option.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/option.move @@ -12,5 +12,4 @@ module a::m { ) { abort 0 } - } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/optional_txn_context.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/optional_txn_context.move index 0731ce65441bc..f0bed89f7ac72 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/optional_txn_context.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/optional_txn_context.move @@ -6,6 +6,7 @@ module a::m { } struct Obj has key { id: sui::object::UID } + public entry fun t2(_: bool, _: &mut Obj) { abort 0 } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/receiving_non_object_type.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/receiving_non_object_type.move index 56aad03267cb6..d974b27bc3aed 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/receiving_non_object_type.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/receiving_non_object_type.move @@ -8,6 +8,6 @@ module a::m { module sui::transfer { struct Receiving has drop { - id: address + id: address, } } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/receiving_with_object_type.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/receiving_with_object_type.move index 9979bdc60761f..a88f2fb30dfb3 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/receiving_with_object_type.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/receiving_with_object_type.move @@ -6,7 +6,7 @@ module a::m { struct S has key { id: object::UID } - public entry fun yes(_: Receiving) { } + public entry fun yes(_: Receiving) {} } module sui::object { @@ -17,6 +17,6 @@ module sui::object { module sui::transfer { struct Receiving has drop { - id: address + id: address, } } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/return_values.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/return_values.move index 19d04c45d77c6..2d74aa38328ae 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/return_values.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/return_values.move @@ -14,6 +14,7 @@ module a::m { } struct Droppable has drop { flag: bool } + public entry fun t3(): Droppable { abort 0 } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/return_values_invalid.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/return_values_invalid.move index 14439f8f71645..13a602a3311b0 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/return_values_invalid.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/return_values_invalid.move @@ -4,20 +4,27 @@ module a::m { public entry fun t0(): &u8 { abort 0 } + public entry fun t1(): &mut u8 { abort 0 } - public entry fun t2(): (u64,&u8,u8) { + + public entry fun t2(): (u64, &u8, u8) { abort 0 } + struct Copyable has copy, store {} + public entry fun t3(): Copyable { abort 0 } + struct Obj has key, store { id: sui::object::UID } + public entry fun t4(): Obj { abort 0 } + public entry fun t5(): vector { abort 0 } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/return_values_invalid.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/return_values_invalid.snap index 9a547cc70ee74..e074ff08a6321 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/return_values_invalid.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/return_values_invalid.snap @@ -14,37 +14,39 @@ error[Sui E02002]: invalid 'entry' function signature │ Invalid return type for entry function 't0' error[Sui E02002]: invalid 'entry' function signature - ┌─ tests/sui_mode/entry_points/return_values_invalid.move:7:12 + ┌─ tests/sui_mode/entry_points/return_values_invalid.move:8:12 │ -7 │ public entry fun t1(): &mut u8 { +8 │ public entry fun t1(): &mut u8 { │ ^^^^^ ------- Expected a non-reference type │ │ │ Invalid return type for entry function 't1' error[Sui E02002]: invalid 'entry' function signature - ┌─ tests/sui_mode/entry_points/return_values_invalid.move:14:12 + ┌─ tests/sui_mode/entry_points/return_values_invalid.move:18:12 │ -13 │ struct Copyable has copy, store {} +16 │ struct Copyable has copy, store {} │ -------- To satisfy the constraint, the 'drop' ability would need to be added here -14 │ public entry fun t3(): Copyable { +17 │ +18 │ public entry fun t3(): Copyable { │ ^^^^^ -------- The type 'a::m::Copyable' does not have the ability 'drop' │ │ │ Invalid return type for entry function 't3' error[Sui E02002]: invalid 'entry' function signature - ┌─ tests/sui_mode/entry_points/return_values_invalid.move:18:12 + ┌─ tests/sui_mode/entry_points/return_values_invalid.move:24:12 │ -17 │ struct Obj has key, store { id: sui::object::UID } +22 │ struct Obj has key, store { id: sui::object::UID } │ --- To satisfy the constraint, the 'drop' ability would need to be added here -18 │ public entry fun t4(): Obj { +23 │ +24 │ public entry fun t4(): Obj { │ ^^^^^ --- The type 'a::m::Obj' does not have the ability 'drop' │ │ │ Invalid return type for entry function 't4' error[Sui E02002]: invalid 'entry' function signature - ┌─ tests/sui_mode/entry_points/return_values_invalid.move:21:12 + ┌─ tests/sui_mode/entry_points/return_values_invalid.move:28:12 │ -21 │ public entry fun t5(): vector { +28 │ public entry fun t5(): vector { │ ^^^^^ ----------- │ │ │ │ │ │ │ The type 'vector' can have the ability 'drop' but the type argument 'a::m::Obj' does not have the required ability 'drop' diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/single_type_param.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/single_type_param.move index 4d18a8a8c981e..ac4432f036e38 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/single_type_param.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/single_type_param.move @@ -4,7 +4,6 @@ module a::m { public entry fun foo(_: T, _: &mut tx_context::TxContext) { abort 0 } - } module sui::tx_context { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/single_type_param_generic_object.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/single_type_param_generic_object.move index af582ab0486ef..9358ff4c1af63 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/single_type_param_generic_object.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/single_type_param_generic_object.move @@ -1,14 +1,15 @@ module a::m { use sui::object; use sui::tx_context; + struct Obj has key { id: object::UID, value: T, } + public entry fun foo(_: Obj, _: &mut tx_context::TxContext) { abort 0 } - } module sui::object { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/single_type_param_key.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/single_type_param_key.move index 7a45891f10efc..0b558b2c99811 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/single_type_param_key.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/single_type_param_key.move @@ -5,13 +5,14 @@ module a::m { public entry fun t1(_: T, _: &mut tx_context::TxContext) { abort 0 } + public entry fun t2(_: &T, _: &mut tx_context::TxContext) { abort 0 } + public entry fun t3(_: &mut T, _: &mut tx_context::TxContext) { abort 0 } - } module sui::tx_context { struct TxContext has drop {} diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/string.move b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/string.move index c8df416e007c1..794cf3c65abe5 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/string.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/entry_points/string.move @@ -1,9 +1,9 @@ // valid, ASCII and UTF strings is allowed module a::m { - use sui::tx_context; use std::ascii; use std::string; + use sui::tx_context; public entry fun yes_ascii( _: ascii::String, diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/derived_object_no_leak.move b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/derived_object_no_leak.move index f8e7021a24d48..7a11451a2a929 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/derived_object_no_leak.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/derived_object_no_leak.move @@ -1,37 +1,37 @@ // valid because we can use `derived_object::claim` without triggering id leak module a::m { - use sui::derived_object; - use sui::object; + use sui::derived_object; + use sui::object; - struct A has key { - id: object::UID, - } + struct A has key { + id: object::UID, + } - public fun no_leak(ctx: &mut sui::tx_context::TxContext): A { - A { - id: derived_object::claim(object::new(ctx), 0), + public fun no_leak(ctx: &mut sui::tx_context::TxContext): A { + A { + id: derived_object::claim(object::new(ctx), 0), + } } - } } module sui::object { - struct UID has store { - id: address, - } + struct UID has store { + id: address, + } - public fun new(_: &mut sui::tx_context::TxContext): UID { - abort 0 - } + public fun new(_: &mut sui::tx_context::TxContext): UID { + abort 0 + } } module sui::tx_context { - struct TxContext has drop {} + struct TxContext has drop {} } module sui::derived_object { - use sui::object::UID; + use sui::object::UID; - public fun claim(_: UID, _: T): UID { - abort 0 - } + public fun claim(_: UID, _: T): UID { + abort 0 + } } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/direct_leak_through_call.move b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/direct_leak_through_call.move index 495a9b42b94bd..80c2ea39a1d2f 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/direct_leak_through_call.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/direct_leak_through_call.move @@ -15,7 +15,6 @@ module a::m { let Foo { id } = f; transfer(id); } - } module sui::object { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/indirect_leak_through_call.move b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/indirect_leak_through_call.move index bd21a01a66bdf..06ca3134a0e8b 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/indirect_leak_through_call.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/indirect_leak_through_call.move @@ -14,7 +14,6 @@ module a::m { let Foo { id } = f; transfer(Foo { id }); } - } // allowed since no packing occurs @@ -33,10 +32,8 @@ module k::m { let Foo { id } = f; transfer(id); } - } - module sui::object { struct UID has store { id: address, diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/infinite_loop.move b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/infinite_loop.move index a6669af7447c1..4462c13a1a7cd 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/infinite_loop.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/infinite_loop.move @@ -8,7 +8,7 @@ module a::m { } public entry fun loop_forever(ctx: &mut TxContext) { - let obj = Obj { id: object::new(ctx) }; + let obj = Obj { id: object::new(ctx) }; let Obj { id: uid } = obj; loop { object::delete(uid); @@ -17,7 +17,7 @@ module a::m { } public entry fun loop_forever_2(ctx: &mut TxContext) { - let obj = Obj { id: object::new(ctx) }; + let obj = Obj { id: object::new(ctx) }; let Obj { id: uid } = obj; loop { object::delete(uid); @@ -32,14 +32,15 @@ module a::m { } } - module sui::object { struct UID has store { id: address, } + public fun new(_: &mut sui::tx_context::TxContext): UID { abort 0 } + public fun delete(_: UID) { abort 0 } @@ -47,6 +48,7 @@ module sui::object { module sui::tx_context { struct TxContext has drop {} + public fun sender(_: &TxContext): address { @0 } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/loop.move b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/loop.move index 823bde59457e3..67d2703954a9e 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/loop.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/loop.move @@ -1,11 +1,11 @@ // allowed, even though a bit pointless module a::m { use sui::object::{Self, UID}; - use sui::tx_context::{Self, TxContext}; use sui::transfer::transfer; + use sui::tx_context::{Self, TxContext}; struct Obj has key { - id: UID + id: UID, } public entry fun transmute(ctx: &mut TxContext) { @@ -19,16 +19,17 @@ module a::m { let obj = Obj { id }; transfer(obj, tx_context::sender(ctx)) } - } module sui::object { struct UID has store { id: address, } + public fun new(_: &mut sui::tx_context::TxContext): UID { abort 0 } + public fun delete(_: UID) { abort 0 } @@ -36,6 +37,7 @@ module sui::object { module sui::tx_context { struct TxContext has drop {} + public fun sender(_: &TxContext): address { @0 } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/private_pack.move b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/private_pack.move index 1a9cf3fc9ebb3..980efff07e2f5 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/private_pack.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/private_pack.move @@ -3,17 +3,18 @@ module a::a { use sui::object::UID; struct A has key { - id: UID + id: UID, } } module b::b { - use sui::object::UID; use a::a::A; + use sui::object::UID; struct B has key { - id: UID + id: UID, } + public fun no(b: B): A { let B { id } = b; A { id } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/private_pack.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/private_pack.snap index 8ce52153e26c1..85f7291b5e57f 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/private_pack.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/private_pack.snap @@ -6,10 +6,10 @@ info: lint: false --- error[E04001]: restricted visibility - ┌─ tests/sui_mode/id_leak/private_pack.move:19:9 + ┌─ tests/sui_mode/id_leak/private_pack.move:20:9 │ 5 │ struct A has key { │ - Struct defined in module 'a::a' · -19 │ A { id } +20 │ A { id } │ ^^^^^^^^ Struct 'a::a::A' can only be instantiated within its defining module 'a::a' diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_call_with_borrow_field.move b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_call_with_borrow_field.move index 816bb2bc4d017..5abe785c4abb9 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_call_with_borrow_field.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_call_with_borrow_field.move @@ -17,7 +17,6 @@ module a::m { _ = &s.f; transfer(new(id), @42); } - } module sui::object { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_indirect_return.move b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_indirect_return.move index 3e848b918e65c..957cdf88bc704 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_indirect_return.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_indirect_return.move @@ -10,7 +10,6 @@ module a::m { let Foo { id } = f; Foo { id } } - } module sui::object { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_pack.move b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_pack.move index 8d834db309122..0bbbf800b9899 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_pack.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_pack.move @@ -4,15 +4,15 @@ module b::test { use sui::transfer::transfer; struct A has key { - id: UID + id: UID, } struct C has key { - id: UID + id: UID, } struct B { - id: UID + id: UID, } public entry fun test(x: A) { @@ -42,7 +42,6 @@ module a::m { let _b = Bar { id, v: 0 }; abort 0 } - } module sui::object { @@ -53,6 +52,7 @@ module sui::object { module sui::tx_context { struct TxContext has drop {} + public fun sender(_: &TxContext): address { @0 } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_reference.move b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_reference.move index 5752d2be21cc9..5a9cbda45eec7 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_reference.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_reference.move @@ -10,7 +10,6 @@ module a::m { let Foo { id } = f; *ref = id; } - } module sui::object { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_reference.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_reference.snap index 7bc3ca33c2847..239de9f11a663 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_reference.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_reference.snap @@ -14,5 +14,5 @@ error[E05001]: ability constraint not satisfied 11 │ *ref = id; │ ^^^ Invalid mutation. Mutation requires the 'drop' ability as the old value is destroyed · -17 │ struct UID has store { +16 │ struct UID has store { │ --- To satisfy the constraint, the 'drop' ability would need to be added here diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_vector.move b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_vector.move index 849584de22443..78162e98e7de8 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_vector.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/through_vector.move @@ -10,7 +10,6 @@ module a::m { let Foo { id } = f; std::vector::push_back(v, id) } - } module sui::object { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/transmute.move b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/transmute.move index 0f2ce8c325dff..86c293dd7b8e7 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/transmute.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/id_leak/transmute.move @@ -1,8 +1,8 @@ // not allowed, it re-uses an ID in a new object module a::m { use sui::object::UID; - use sui::tx_context::{Self, TxContext}; use sui::transfer::transfer; + use sui::tx_context::{Self, TxContext}; struct Cat has key { id: UID, @@ -17,7 +17,6 @@ module a::m { let dog = Dog { id }; transfer(dog, tx_context::sender(ctx)); } - } module sui::object { @@ -28,6 +27,7 @@ module sui::object { module sui::tx_context { struct TxContext has drop {} + public fun sender(_: &TxContext): address { @0 } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/init/cannot_call_init.move b/external-crates/move/crates/move-compiler/tests/sui_mode/init/cannot_call_init.move index 1874cff2f1f80..2db865c7c1617 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/init/cannot_call_init.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/init/cannot_call_init.move @@ -1,6 +1,7 @@ // cannot directly call init module a::m { use sui::tx_context; + fun init(_ctx: &mut tx_context::TxContext) { abort 0 } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/init/cannot_call_init.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/init/cannot_call_init.snap index 9c0524ebbc8c1..a5391444b79ab 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/init/cannot_call_init.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/init/cannot_call_init.snap @@ -6,9 +6,9 @@ info: lint: false --- error[Sui E02006]: invalid 'init' call - ┌─ tests/sui_mode/init/cannot_call_init.move:9:9 - │ -9 │ init(ctx) - │ ^^^^^^^^^ Invalid call to 'a::m::init'. Module initializers cannot be called directly - │ - = Module initializers are called implicitly upon publishing. If you need to reuse this function (or want to call it from a test), consider extracting the logic into a new function and calling that instead. + ┌─ tests/sui_mode/init/cannot_call_init.move:10:9 + │ +10 │ init(ctx) + │ ^^^^^^^^^ Invalid call to 'a::m::init'. Module initializers cannot be called directly + │ + = Module initializers are called implicitly upon publishing. If you need to reuse this function (or want to call it from a test), consider extracting the logic into a new function and calling that instead. diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/init/imm_tx_context.move b/external-crates/move/crates/move-compiler/tests/sui_mode/init/imm_tx_context.move index fcbf1f9a39589..6941090c82f55 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/init/imm_tx_context.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/init/imm_tx_context.move @@ -1,6 +1,7 @@ // TxContext can be immutable, even for init module a::m { use sui::tx_context; + fun init(_ctx: &tx_context::TxContext) { abort 0 } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/init/must_have_txn_context.move b/external-crates/move/crates/move-compiler/tests/sui_mode/init/must_have_txn_context.move index 201290071787a..4993473f48273 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/init/must_have_txn_context.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/init/must_have_txn_context.move @@ -8,6 +8,7 @@ module a::m { // cannot have mroe than one TxContext module a::n { use sui::tx_context; + fun init(_ctx: &mut tx_context::TxContext, _ctx2: &mut tx_context::TxContext) { abort 0 } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/init/must_have_txn_context.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/init/must_have_txn_context.snap index 2aef01a7a05ca..9552870c8a48a 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/init/must_have_txn_context.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/init/must_have_txn_context.snap @@ -15,9 +15,9 @@ error[Sui E02003]: invalid 'init' function │ 'init' functions must have their last parameter as '&sui::tx_context::TxContext' or '&mut sui::tx_context::TxContext' error[Sui E02003]: invalid 'init' function - ┌─ tests/sui_mode/init/must_have_txn_context.move:11:9 + ┌─ tests/sui_mode/init/must_have_txn_context.move:12:9 │ -11 │ fun init(_ctx: &mut tx_context::TxContext, _ctx2: &mut tx_context::TxContext) { +12 │ fun init(_ctx: &mut tx_context::TxContext, _ctx2: &mut tx_context::TxContext) { │ ^^^^ -------------------------- Invalid parameter '_ctx' of type '&mut sui::tx_context::TxContext'. Expected a one-time witness type, 'a::n::N │ │ │ Invalid 'init' function declaration diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_generic.move b/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_generic.move index eedf270a69ee1..f0a8e0c32b154 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_generic.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_generic.move @@ -1,6 +1,7 @@ // init functions cannot have generics module a::m { use sui::tx_context; + fun init(_ctx: &mut tx_context::TxContext) { abort 0 } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_generic.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_generic.snap index 80587c861a3fc..b84050478077a 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_generic.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_generic.snap @@ -6,9 +6,9 @@ info: lint: false --- error[Sui E02003]: invalid 'init' function - ┌─ tests/sui_mode/init/not_generic.move:4:9 + ┌─ tests/sui_mode/init/not_generic.move:5:9 │ -4 │ fun init(_ctx: &mut tx_context::TxContext) { +5 │ fun init(_ctx: &mut tx_context::TxContext) { │ ^^^^ - 'init' functions cannot have type parameters │ │ │ Invalid 'init' function declaration diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_private.move b/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_private.move index 26820c100577f..d5a390f68a368 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_private.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_private.move @@ -1,13 +1,15 @@ // init functions cannot be public, cannot have entry, cannot be public(friend) module a::m0 { use sui::tx_context; - public fun init(_ctxctx: &mut tx_context::TxContext) { + + public fun init(_ctx: &mut tx_context::TxContext) { abort 0 } } module a::m1 { use sui::tx_context; + entry fun init(_ctx: &mut tx_context::TxContext) { abort 0 } @@ -15,6 +17,7 @@ module a::m1 { module a::m2 { use sui::tx_context; + public(friend) fun init(_ctx: &mut tx_context::TxContext) { abort 0 } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_private.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_private.snap index e9e16718fd0fd..4a9583b409231 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_private.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_private.snap @@ -6,25 +6,25 @@ info: lint: false --- error[Sui E02003]: invalid 'init' function - ┌─ tests/sui_mode/init/not_private.move:4:16 + ┌─ tests/sui_mode/init/not_private.move:5:16 │ -4 │ public fun init(_ctxctx: &mut tx_context::TxContext) { +5 │ public fun init(_ctx: &mut tx_context::TxContext) { │ ------ ^^^^ Invalid 'init' function declaration │ │ │ 'init' functions must be internal to their module error[Sui E02003]: invalid 'init' function - ┌─ tests/sui_mode/init/not_private.move:11:15 + ┌─ tests/sui_mode/init/not_private.move:13:15 │ -11 │ entry fun init(_ctx: &mut tx_context::TxContext) { +13 │ entry fun init(_ctx: &mut tx_context::TxContext) { │ ----- ^^^^ Invalid 'init' function declaration │ │ │ 'init' functions cannot be 'entry' functions error[Sui E02003]: invalid 'init' function - ┌─ tests/sui_mode/init/not_private.move:18:24 + ┌─ tests/sui_mode/init/not_private.move:21:24 │ -18 │ public(friend) fun init(_ctx: &mut tx_context::TxContext) { +21 │ public(friend) fun init(_ctx: &mut tx_context::TxContext) { │ -------------- ^^^^ Invalid 'init' function declaration │ │ │ 'init' functions must be internal to their module diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_txn_context.move b/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_txn_context.move index e50ed46108b44..c31f65a5cec0c 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_txn_context.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_txn_context.move @@ -7,6 +7,7 @@ module a::m1 { module a::tx_context { struct TxContext { value: u64 } + fun init(_: TxContext) { abort 0 } @@ -14,6 +15,7 @@ module a::tx_context { module a::m2 { use sui::tx_context; + fun init(_: tx_context::TxContext) { abort 0 } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_txn_context.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_txn_context.snap index 04b58d1123b1e..cd8f55d15fbfc 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_txn_context.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/init/not_txn_context.snap @@ -14,17 +14,17 @@ error[Sui E02003]: invalid 'init' function │ Invalid 'init' function declaration error[Sui E02003]: invalid 'init' function - ┌─ tests/sui_mode/init/not_txn_context.move:10:9 + ┌─ tests/sui_mode/init/not_txn_context.move:11:9 │ -10 │ fun init(_: TxContext) { +11 │ fun init(_: TxContext) { │ ^^^^ --------- 'init' functions must have their last parameter as '&sui::tx_context::TxContext' or '&mut sui::tx_context::TxContext' │ │ │ Invalid 'init' function declaration error[Sui E02003]: invalid 'init' function - ┌─ tests/sui_mode/init/not_txn_context.move:17:9 + ┌─ tests/sui_mode/init/not_txn_context.move:19:9 │ -17 │ fun init(_: tx_context::TxContext) { +19 │ fun init(_: tx_context::TxContext) { │ ^^^^ --------------------- 'init' functions must have their last parameter as '&sui::tx_context::TxContext' or '&mut sui::tx_context::TxContext' │ │ │ Invalid 'init' function declaration diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/init/ok.move b/external-crates/move/crates/move-compiler/tests/sui_mode/init/ok.move index d27a662f99301..135480dbbc2ea 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/init/ok.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/init/ok.move @@ -1,8 +1,8 @@ // valid init function module a::m { use sui::tx_context; - fun init(_: &mut tx_context::TxContext) { - } + + fun init(_: &mut tx_context::TxContext) {} } module sui::tx_context { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/init/return_values.move b/external-crates/move/crates/move-compiler/tests/sui_mode/init/return_values.move index cb7d7cb7c0b9d..757080e226d0d 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/init/return_values.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/init/return_values.move @@ -1,6 +1,7 @@ // init cannot have return values module a::m { use sui::tx_context; + fun init(_: &mut tx_context::TxContext): u64 { 0 } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/init/return_values.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/init/return_values.snap index f64932eaf9f1d..3a57bae5c1860 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/init/return_values.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/init/return_values.snap @@ -6,9 +6,9 @@ info: lint: false --- error[Sui E02003]: invalid 'init' function - ┌─ tests/sui_mode/init/return_values.move:4:9 + ┌─ tests/sui_mode/init/return_values.move:5:9 │ -4 │ fun init(_: &mut tx_context::TxContext): u64 { +5 │ fun init(_: &mut tx_context::TxContext): u64 { │ ^^^^ --- 'init' functions must have a return type of '()' │ │ │ Invalid 'init' function declaration diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/coin_field.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/coin_field.move index 5cea0bcee7087..2a6450aaea851 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/coin_field.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/coin_field.move @@ -51,12 +51,12 @@ module sui::object { module sui::coin { use sui::object::UID; + struct Coin has key, store { - id: UID + id: UID, } struct TreasuryCap has key, store { - id: UID + id: UID, } - } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/collection_equality.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/collection_equality.move index 848bbaff3ebe9..ab5f9125a3c79 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/collection_equality.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/collection_equality.move @@ -3,16 +3,14 @@ module a::test { use sui::bag::Bag; + use sui::linked_table::LinkedTable; use sui::object_bag::ObjectBag; - use sui::table::Table; use sui::object_table::ObjectTable; - use sui::linked_table::LinkedTable; + use sui::table::Table; use sui::table_vec::TableVec; use sui::vec_map::VecMap; use sui::vec_set::VecSet; - - public fun bag_eq(bag1: &Bag, bag2: &Bag): bool { bag1 == bag2 } @@ -27,12 +25,15 @@ module a::test { public fun obj_table_eq( table1: &ObjectTable, - table2: &ObjectTable + table2: &ObjectTable, ): bool { - table1 == table2 + table1 == table2 } - public fun linked_table_neq(table1: &LinkedTable, table2: &LinkedTable): bool { + public fun linked_table_neq( + table1: &LinkedTable, + table2: &LinkedTable, + ): bool { table1 == table2 } @@ -59,7 +60,7 @@ module sui::bag { use sui::object::UID; struct Bag has key, store { - id: UID + id: UID, } } @@ -67,7 +68,7 @@ module sui::object_bag { use sui::object::UID; struct ObjectBag has key, store { - id: UID + id: UID, } } @@ -75,7 +76,7 @@ module sui::table { use sui::object::UID; struct Table has key, store { - id: UID + id: UID, } } @@ -83,7 +84,7 @@ module sui::object_table { use sui::object::UID; struct ObjectTable has key, store { - id: UID + id: UID, } } @@ -91,7 +92,7 @@ module sui::linked_table { use sui::object::UID; struct LinkedTable has key, store { - id: UID + id: UID, } } @@ -99,7 +100,7 @@ module sui::table_vec { use sui::object::UID; struct TableVec has key, store { - id: UID + id: UID, } } @@ -107,7 +108,7 @@ module sui::vec_map { use sui::object::UID; struct VecMap has key, store { - id: UID + id: UID, } } @@ -115,6 +116,6 @@ module sui::vec_set { use sui::object::UID; struct VecSet has key, store { - id: UID + id: UID, } } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/collection_equality.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/collection_equality.snap index d3373072a8107..81b8db4626375 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/collection_equality.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/collection_equality.snap @@ -6,72 +6,72 @@ info: lint: true --- warning[Lint W99005]: possibly useless collections compare - ┌─ tests/sui_mode/linter/collection_equality.move:17:14 + ┌─ tests/sui_mode/linter/collection_equality.move:15:14 │ -17 │ bag1 == bag2 +15 │ bag1 == bag2 │ ^^ Comparing collections of type 'sui::bag::Bag' may yield unexpected result. │ = Equality for collections of type 'sui::bag::Bag' IS NOT a structural check based on content = This warning can be suppressed with '#[allow(lint(collection_equality))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99005]: possibly useless collections compare - ┌─ tests/sui_mode/linter/collection_equality.move:21:14 + ┌─ tests/sui_mode/linter/collection_equality.move:19:14 │ -21 │ bag1 != bag2 +19 │ bag1 != bag2 │ ^^ Comparing collections of type 'sui::object_bag::ObjectBag' may yield unexpected result. │ = Equality for collections of type 'sui::object_bag::ObjectBag' IS NOT a structural check based on content = This warning can be suppressed with '#[allow(lint(collection_equality))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99005]: possibly useless collections compare - ┌─ tests/sui_mode/linter/collection_equality.move:25:16 + ┌─ tests/sui_mode/linter/collection_equality.move:23:16 │ -25 │ table1 == table2 +23 │ table1 == table2 │ ^^ Comparing collections of type 'sui::table::Table' may yield unexpected result. │ = Equality for collections of type 'sui::table::Table' IS NOT a structural check based on content = This warning can be suppressed with '#[allow(lint(collection_equality))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99005]: possibly useless collections compare - ┌─ tests/sui_mode/linter/collection_equality.move:32:20 + ┌─ tests/sui_mode/linter/collection_equality.move:30:16 │ -32 │ table1 == table2 - │ ^^ Comparing collections of type 'sui::object_table::ObjectTable' may yield unexpected result. +30 │ table1 == table2 + │ ^^ Comparing collections of type 'sui::object_table::ObjectTable' may yield unexpected result. │ = Equality for collections of type 'sui::object_table::ObjectTable' IS NOT a structural check based on content = This warning can be suppressed with '#[allow(lint(collection_equality))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99005]: possibly useless collections compare - ┌─ tests/sui_mode/linter/collection_equality.move:36:16 + ┌─ tests/sui_mode/linter/collection_equality.move:37:16 │ -36 │ table1 == table2 +37 │ table1 == table2 │ ^^ Comparing collections of type 'sui::linked_table::LinkedTable' may yield unexpected result. │ = Equality for collections of type 'sui::linked_table::LinkedTable' IS NOT a structural check based on content = This warning can be suppressed with '#[allow(lint(collection_equality))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99005]: possibly useless collections compare - ┌─ tests/sui_mode/linter/collection_equality.move:40:16 + ┌─ tests/sui_mode/linter/collection_equality.move:41:16 │ -40 │ table1 == table2 +41 │ table1 == table2 │ ^^ Comparing collections of type 'sui::table_vec::TableVec' may yield unexpected result. │ = Equality for collections of type 'sui::table_vec::TableVec' IS NOT a structural check based on content = This warning can be suppressed with '#[allow(lint(collection_equality))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99005]: possibly useless collections compare - ┌─ tests/sui_mode/linter/collection_equality.move:44:14 + ┌─ tests/sui_mode/linter/collection_equality.move:45:14 │ -44 │ vec1 == vec2 +45 │ vec1 == vec2 │ ^^ Comparing collections of type 'sui::vec_map::VecMap' may yield unexpected result. │ = Equality for collections of type 'sui::vec_map::VecMap' IS NOT a structural check based on content = This warning can be suppressed with '#[allow(lint(collection_equality))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99005]: possibly useless collections compare - ┌─ tests/sui_mode/linter/collection_equality.move:48:14 + ┌─ tests/sui_mode/linter/collection_equality.move:49:14 │ -48 │ vec1 == vec2 +49 │ vec1 == vec2 │ ^^ Comparing collections of type 'sui::vec_set::VecSet' may yield unexpected result. │ = Equality for collections of type 'sui::vec_set::VecSet' IS NOT a structural check based on content diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/custom_state_change.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/custom_state_change.move index 128df86c2c3eb..95dddd9e77025 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/custom_state_change.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/custom_state_change.move @@ -8,7 +8,7 @@ module a::test { #[allow(unused_field)] struct S1 has key, store { - id: UID + id: UID, } #[allow(lint(self_transfer, prefer_mut_tx_context))] @@ -28,9 +28,11 @@ module a::test { module sui::object { const ZERO: u64 = 0; + struct UID has store { id: address, } + public fun new(_: &mut sui::tx_context::TxContext): UID { abort ZERO } @@ -38,6 +40,7 @@ module sui::object { module sui::tx_context { struct TxContext has drop {} + public fun sender(_: &TxContext): address { @0 } @@ -45,6 +48,7 @@ module sui::tx_context { module sui::transfer { const ZERO: u64 = 0; + public fun transfer(_: T, _: address) { abort ZERO } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/edge_case_lint_missing_key.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/edge_case_lint_missing_key.move index 270976888885f..fbf9e00c6737d 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/edge_case_lint_missing_key.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/edge_case_lint_missing_key.move @@ -8,7 +8,6 @@ module a::edge_cases { struct NotAnObject { id: UID, } - } module sui::object { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/false_positive_share_owned.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/false_positive_share_owned.move index 76484a8fbb616..17ac48e7be6fd 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/false_positive_share_owned.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/false_positive_share_owned.move @@ -1,10 +1,10 @@ // object has store but is never created externally module a::has_store { - use sui::transfer; use sui::object::UID; + use sui::transfer; struct Obj has key, store { - id: UID + id: UID, } public fun arg_object(o: Obj) { @@ -15,15 +15,15 @@ module a::has_store { // object is created locally, but the analysis cannot determine that currently module a::cannot_determine_to_be_new { - use sui::transfer; use sui::object::UID; + use sui::transfer; struct Obj has key { - id: UID + id: UID, } struct Obj2 has key { - id: UID + id: UID, } // we do not do interprodedural analysis here @@ -45,6 +45,7 @@ module a::cannot_determine_to_be_new { module sui::tx_context { struct TxContext has drop {} + public fun sender(_: &TxContext): address { @0 } @@ -52,12 +53,15 @@ module sui::tx_context { module sui::object { const ZERO: u64 = 0; + struct UID has store { id: address, } + public fun delete(_: UID) { abort ZERO } + public fun new(_: &mut sui::tx_context::TxContext): UID { abort ZERO } @@ -65,12 +69,15 @@ module sui::object { module sui::transfer { const ZERO: u64 = 0; + public fun transfer(_: T, _: address) { abort ZERO } + public fun share_object(_: T) { abort ZERO } + public fun public_share_object(_: T) { abort ZERO } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/false_unnecessary_public_entry.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/false_unnecessary_public_entry.move index 2bf1ac6c566c6..2bd8dab81b337 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/false_unnecessary_public_entry.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/false_unnecessary_public_entry.move @@ -1,4 +1,5 @@ module a::m { entry fun false_unnecessary_public_entry() {} + public fun false_unnecessary_public_entry_2() {} } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freeze_wrapped.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freeze_wrapped.move index a4c7fe9aaff83..9062bfd6b9241 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freeze_wrapped.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freeze_wrapped.move @@ -7,7 +7,7 @@ module a::test { use sui::transfer; struct Inner has key, store { - id: UID + id: UID, } struct Wrapper has key, store { @@ -16,7 +16,7 @@ module a::test { } struct S has store { - inner: Inner + inner: Inner, } struct IndirectWrapper has key, store { @@ -30,7 +30,7 @@ module a::test { } struct S2 has store { - inner: T + inner: T, } struct IndirectGenWrapper has key, store { @@ -38,7 +38,6 @@ module a::test { inner: S2, } - public fun freeze_direct(w: Wrapper) { transfer::public_freeze_object(w); } @@ -61,9 +60,8 @@ module a::test { } public fun freeze_arg(w1: Wrapper, w2: Wrapper) { - transfer::public_freeze_object({ transfer::public_freeze_object(w1) ; w2}); + transfer::public_freeze_object({ transfer::public_freeze_object(w1); w2 }); } - } module sui::object { @@ -74,6 +72,7 @@ module sui::object { module sui::transfer { const ZERO: u64 = 0; + public fun public_freeze_object(_: T) { abort ZERO } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freeze_wrapped.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freeze_wrapped.snap index 89d28313b29be..9007c5cdc6d71 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freeze_wrapped.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freeze_wrapped.snap @@ -6,18 +6,18 @@ info: lint: true --- warning[Lint W99004]: attempting to freeze wrapped objects - ┌─ tests/sui_mode/linter/freeze_wrapped.move:43:40 + ┌─ tests/sui_mode/linter/freeze_wrapped.move:42:40 │ 15 │ inner: Inner, │ ----- The field of this type is a wrapped object · -43 │ transfer::public_freeze_object(w); +42 │ transfer::public_freeze_object(w); │ ^ Freezing an object of type 'Wrapper' also freezes all objects wrapped in its field 'inner'. │ = This warning can be suppressed with '#[allow(lint(freeze_wrapped))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99004]: attempting to freeze wrapped objects - ┌─ tests/sui_mode/linter/freeze_wrapped.move:47:40 + ┌─ tests/sui_mode/linter/freeze_wrapped.move:46:40 │ 9 │ struct Inner has key, store { │ ----- Indirectly wrapped object is of this type @@ -25,35 +25,35 @@ warning[Lint W99004]: attempting to freeze wrapped objects 24 │ s: S, │ - The field of this type indirectly contains a wrapped object · -47 │ transfer::public_freeze_object(w); +46 │ transfer::public_freeze_object(w); │ ^ Freezing an object of type 'IndirectWrapper' also freezes all objects wrapped in its field 's'. │ = This warning can be suppressed with '#[allow(lint(freeze_wrapped))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99004]: attempting to freeze wrapped objects - ┌─ tests/sui_mode/linter/freeze_wrapped.move:52:40 + ┌─ tests/sui_mode/linter/freeze_wrapped.move:51:40 │ 15 │ inner: Inner, │ ----- The field of this type is a wrapped object · -52 │ transfer::public_freeze_object(v); +51 │ transfer::public_freeze_object(v); │ ^ Freezing an object of type 'Wrapper' also freezes all objects wrapped in its field 'inner'. │ = This warning can be suppressed with '#[allow(lint(freeze_wrapped))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99004]: attempting to freeze wrapped objects - ┌─ tests/sui_mode/linter/freeze_wrapped.move:56:40 + ┌─ tests/sui_mode/linter/freeze_wrapped.move:55:40 │ 29 │ inner: T, │ - The field of this type is a wrapped object · -56 │ transfer::public_freeze_object(w); +55 │ transfer::public_freeze_object(w); │ ^ Freezing an object of type 'GenWrapper' also freezes all objects wrapped in its field 'inner'. │ = This warning can be suppressed with '#[allow(lint(freeze_wrapped))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99004]: attempting to freeze wrapped objects - ┌─ tests/sui_mode/linter/freeze_wrapped.move:60:40 + ┌─ tests/sui_mode/linter/freeze_wrapped.move:59:40 │ 32 │ struct S2 has store { │ - Indirectly wrapped object is of this type @@ -61,29 +61,29 @@ warning[Lint W99004]: attempting to freeze wrapped objects 38 │ inner: S2, │ ----- The field of this type indirectly contains a wrapped object · -60 │ transfer::public_freeze_object(w); +59 │ transfer::public_freeze_object(w); │ ^ Freezing an object of type 'IndirectGenWrapper' also freezes all objects wrapped in its field 'inner'. │ = This warning can be suppressed with '#[allow(lint(freeze_wrapped))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99004]: attempting to freeze wrapped objects - ┌─ tests/sui_mode/linter/freeze_wrapped.move:64:40 + ┌─ tests/sui_mode/linter/freeze_wrapped.move:63:40 │ 15 │ inner: Inner, │ ----- The field of this type is a wrapped object · -64 │ transfer::public_freeze_object({ transfer::public_freeze_object(w1) ; w2}); +63 │ transfer::public_freeze_object({ transfer::public_freeze_object(w1); w2 }); │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Freezing an object of type 'Wrapper' also freezes all objects wrapped in its field 'inner'. │ = This warning can be suppressed with '#[allow(lint(freeze_wrapped))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99004]: attempting to freeze wrapped objects - ┌─ tests/sui_mode/linter/freeze_wrapped.move:64:73 + ┌─ tests/sui_mode/linter/freeze_wrapped.move:63:73 │ 15 │ inner: Inner, │ ----- The field of this type is a wrapped object · -64 │ transfer::public_freeze_object({ transfer::public_freeze_object(w1) ; w2}); +63 │ transfer::public_freeze_object({ transfer::public_freeze_object(w1); w2 }); │ ^^ Freezing an object of type 'Wrapper' also freezes all objects wrapped in its field 'inner'. │ = This warning can be suppressed with '#[allow(lint(freeze_wrapped))]' applied to the 'module' or module member ('const', 'fun', or 'struct') diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freezing_capability_false_negatives.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freezing_capability_false_negatives.move index 1718f47d10abd..849d4909d0dc6 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freezing_capability_false_negatives.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freezing_capability_false_negatives.move @@ -6,19 +6,19 @@ module a::test_false_negatives { use sui::transfer; struct AdminRights has key { - id: UID + id: UID, } struct PrivilegeToken has key { - id: UID + id: UID, } struct AccessControl has key { - id: UID + id: UID, } struct Capv0 has key { - id: UID + id: UID, } public fun freeze_admin_rights(w: AdminRights) { @@ -46,6 +46,7 @@ module sui::object { module sui::transfer { const ZERO: u64 = 0; + public fun public_freeze_object(_: T) { abort ZERO } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freezing_capability_false_positives.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freezing_capability_false_positives.move index 53351de70e394..703ad6e722629 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freezing_capability_false_positives.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freezing_capability_false_positives.move @@ -6,19 +6,19 @@ module a::test_false_positives { use sui::transfer; struct NoCap has key { - id: UID + id: UID, } struct CapAndHat has key { - id: UID + id: UID, } struct Recap has key { - id: UID + id: UID, } struct MyCapybara has key { - id: UID + id: UID, } public fun freeze_capture(w: NoCap) { @@ -46,6 +46,7 @@ module sui::object { module sui::transfer { const ZERO: u64 = 0; + public fun public_freeze_object(_: T) { abort ZERO } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freezing_capability_suppression.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freezing_capability_suppression.move index 1cb772808cff7..5460974cd6060 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freezing_capability_suppression.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freezing_capability_suppression.move @@ -6,15 +6,15 @@ module a::test_suppression { use sui::transfer; struct SuperAdminCap has key { - id: UID + id: UID, } struct MasterCapability has key { - id: UID + id: UID, } struct RootCapV3 has key { - id: UID + id: UID, } #[allow(lint(freezing_capability))] @@ -41,6 +41,7 @@ module sui::object { module sui::transfer { const ZERO: u64 = 0; + public fun public_freeze_object(_: T) { abort ZERO } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freezing_capability_true_negatives.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freezing_capability_true_negatives.move index 75b04d2834c16..fe2f3655f1ccf 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freezing_capability_true_negatives.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freezing_capability_true_negatives.move @@ -6,31 +6,31 @@ module a::test_true_negatives { use sui::transfer; struct NormalStruct has key { - id: UID + id: UID, } struct Data has key { - id: UID + id: UID, } struct Token has key { - id: UID + id: UID, } struct Capture has key { - id: UID + id: UID, } struct Handicap has key { - id: UID + id: UID, } struct Recap has key { - id: UID + id: UID, } struct MyCapybara has key { - id: UID + id: UID, } public fun freeze_normal(w: NormalStruct) { @@ -70,6 +70,7 @@ module sui::object { module sui::transfer { const ZERO: u64 = 0; + public fun public_freeze_object(_: T) { abort ZERO } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freezing_capability_true_positives.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freezing_capability_true_positives.move index 92c01d23871b1..120db1e99a240 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freezing_capability_true_positives.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/freezing_capability_true_positives.move @@ -6,15 +6,15 @@ module a::test_true_positives { use sui::transfer; struct AdminCap has key { - id: UID + id: UID, } struct UserCapability has key { - id: UID + id: UID, } struct OwnerCapV2 has key { - id: UID + id: UID, } public fun freeze_cap1(w: AdminCap) { @@ -38,6 +38,7 @@ module sui::object { module sui::transfer { const ZERO: u64 = 0; + public fun public_freeze_object(_: T) { abort ZERO } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/lint_all_syntax_missing.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/lint_all_syntax_missing.move index 166109f529dd8..21954253736b6 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/lint_all_syntax_missing.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/lint_all_syntax_missing.move @@ -1,4 +1,5 @@ // lint_allow syntax is also valid and should report unknown warnings #[lint_allow(x)] module a::m { + } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/public_random_invalid.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/public_random_invalid.move index cadff368cceca..737c05b433d1d 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/public_random_invalid.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/public_random_invalid.move @@ -6,8 +6,11 @@ module a::test { use sui::random::{Random, RandomGenerator}; public fun not_allowed1(_x: u64, _r: &Random) {} + public fun not_allowed2(_rg: &RandomGenerator, _x: u64) {} + public fun not_allowed3(_r: &Random, _rg: &RandomGenerator, _x: u64) {} + public entry fun not_allowed4(_x: u64, _r: &Random, _y: u64) {} } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/public_random_invalid.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/public_random_invalid.snap index d3943cf74468d..bc30c537d808c 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/public_random_invalid.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/public_random_invalid.snap @@ -16,19 +16,19 @@ warning[Lint W99006]: Risky use of 'sui::random' = This warning can be suppressed with '#[allow(lint(public_random))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99006]: Risky use of 'sui::random' - ┌─ tests/sui_mode/linter/public_random_invalid.move:9:34 - │ -9 │ public fun not_allowed2(_rg: &RandomGenerator, _x: u64) {} - │ ^^^^^^^^^^^^^^^^ 'public' function 'not_allowed2' accepts 'RandomGenerator' as a parameter - │ - = Functions that accept 'sui::random::RandomGenerator' as a parameter might be abused by attackers by inspecting the results of randomness - = Non-public functions are preferred - = This warning can be suppressed with '#[allow(lint(public_random))]' applied to the 'module' or module member ('const', 'fun', or 'struct') + ┌─ tests/sui_mode/linter/public_random_invalid.move:10:34 + │ +10 │ public fun not_allowed2(_rg: &RandomGenerator, _x: u64) {} + │ ^^^^^^^^^^^^^^^^ 'public' function 'not_allowed2' accepts 'RandomGenerator' as a parameter + │ + = Functions that accept 'sui::random::RandomGenerator' as a parameter might be abused by attackers by inspecting the results of randomness + = Non-public functions are preferred + = This warning can be suppressed with '#[allow(lint(public_random))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99006]: Risky use of 'sui::random' - ┌─ tests/sui_mode/linter/public_random_invalid.move:10:33 + ┌─ tests/sui_mode/linter/public_random_invalid.move:12:33 │ -10 │ public fun not_allowed3(_r: &Random, _rg: &RandomGenerator, _x: u64) {} +12 │ public fun not_allowed3(_r: &Random, _rg: &RandomGenerator, _x: u64) {} │ ^^^^^^^ 'public' function 'not_allowed3' accepts 'Random' as a parameter │ = Functions that accept 'sui::random::Random' as a parameter might be abused by attackers by inspecting the results of randomness @@ -36,9 +36,9 @@ warning[Lint W99006]: Risky use of 'sui::random' = This warning can be suppressed with '#[allow(lint(public_random))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99006]: Risky use of 'sui::random' - ┌─ tests/sui_mode/linter/public_random_invalid.move:10:47 + ┌─ tests/sui_mode/linter/public_random_invalid.move:12:47 │ -10 │ public fun not_allowed3(_r: &Random, _rg: &RandomGenerator, _x: u64) {} +12 │ public fun not_allowed3(_r: &Random, _rg: &RandomGenerator, _x: u64) {} │ ^^^^^^^^^^^^^^^^ 'public' function 'not_allowed3' accepts 'RandomGenerator' as a parameter │ = Functions that accept 'sui::random::RandomGenerator' as a parameter might be abused by attackers by inspecting the results of randomness @@ -46,9 +46,9 @@ warning[Lint W99006]: Risky use of 'sui::random' = This warning can be suppressed with '#[allow(lint(public_random))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99006]: Risky use of 'sui::random' - ┌─ tests/sui_mode/linter/public_random_invalid.move:11:48 + ┌─ tests/sui_mode/linter/public_random_invalid.move:14:48 │ -11 │ public entry fun not_allowed4(_x: u64, _r: &Random, _y: u64) {} +14 │ public entry fun not_allowed4(_x: u64, _r: &Random, _y: u64) {} │ ^^^^^^^ 'public' function 'not_allowed4' accepts 'Random' as a parameter │ = Functions that accept 'sui::random::Random' as a parameter might be abused by attackers by inspecting the results of randomness diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/public_random_valid.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/public_random_valid.move index 5e031aaad2cce..0e441c7d6fbcd 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/public_random_valid.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/public_random_valid.move @@ -3,6 +3,7 @@ module a::test { use sui::random::{Random, RandomGenerator}; + friend a::test2; entry fun basic_random(_r: &Random) {} diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/self_transfer.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/self_transfer.move index 414486c7227ee..b38d83e94b8dd 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/self_transfer.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/self_transfer.move @@ -7,28 +7,28 @@ module a::test { use sui::tx_context::{Self, TxContext}; struct S1 has key, store { - id: UID + id: UID, } struct S2 has key { - id: UID + id: UID, } fun init(ctx: &mut TxContext) { - transfer::public_transfer(S1 { id: object::new(ctx), }, tx_context::sender(ctx)); - transfer::transfer(S1 { id: object::new(ctx), }, tx_context::sender(ctx)); + transfer::public_transfer(S1 { id: object::new(ctx) }, tx_context::sender(ctx)); + transfer::transfer(S1 { id: object::new(ctx) }, tx_context::sender(ctx)); } public fun public_transfer_bad(ctx: &mut TxContext) { - transfer::public_transfer(S1 { id: object::new(ctx), }, tx_context::sender(ctx)) + transfer::public_transfer(S1 { id: object::new(ctx) }, tx_context::sender(ctx)) } public fun private_transfer_bad(ctx: &mut TxContext) { - transfer::transfer(S1 { id: object::new(ctx), }, tx_context::sender(ctx)) + transfer::transfer(S1 { id: object::new(ctx) }, tx_context::sender(ctx)) } public fun private_transfer_no_store(ctx: &mut TxContext) { - transfer::transfer(S2 { id: object::new(ctx), }, tx_context::sender(ctx)) + transfer::transfer(S2 { id: object::new(ctx) }, tx_context::sender(ctx)) } // non-linter suppression annotation should not suppress linter warnings @@ -36,31 +36,33 @@ module a::test { public fun transfer_through_assigns_bad(ctx: &mut TxContext) { let sender = tx_context::sender(ctx); let another_sender = sender; - transfer::public_transfer(S1 { id: object::new(ctx), }, another_sender) + transfer::public_transfer(S1 { id: object::new(ctx) }, another_sender) } public fun transfer_to_param_ok(a: address, ctx: &mut TxContext) { - transfer::public_transfer(S1 { id: object::new(ctx), }, a); - transfer::transfer(S1 { id: object::new(ctx), }, a); + transfer::public_transfer(S1 { id: object::new(ctx) }, a); + transfer::transfer(S1 { id: object::new(ctx) }, a); } public fun conditional_transfer_ok(b: bool, a: address, ctx: &mut TxContext) { let xfer_address = if (b) { a } else { tx_context::sender(ctx) }; - transfer::public_transfer(S1 { id: object::new(ctx), }, xfer_address); - transfer::transfer(S1 { id: object::new(ctx), }, xfer_address); + transfer::public_transfer(S1 { id: object::new(ctx) }, xfer_address); + transfer::transfer(S1 { id: object::new(ctx) }, xfer_address); } #[allow(lint(self_transfer))] public fun public_transfer_bad_suppressed(ctx: &mut TxContext) { - transfer::public_transfer(S1 { id: object::new(ctx), }, tx_context::sender(ctx)) + transfer::public_transfer(S1 { id: object::new(ctx) }, tx_context::sender(ctx)) } } module sui::object { const ZERO: u64 = 0; + struct UID has store { id: address, } + public fun new(_: &mut sui::tx_context::TxContext): UID { abort ZERO } @@ -68,6 +70,7 @@ module sui::object { module sui::tx_context { struct TxContext has drop {} + public fun sender(_: &TxContext): address { @0 } @@ -75,6 +78,7 @@ module sui::tx_context { module sui::transfer { const ZERO: u64 = 0; + public fun transfer(_: T, _: address) { abort ZERO } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/self_transfer.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/self_transfer.snap index 9c7f48ab80067..763613b93eb55 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/self_transfer.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/self_transfer.snap @@ -10,10 +10,10 @@ warning[Lint W99001]: non-composable transfer to sender │ 22 │ public fun public_transfer_bad(ctx: &mut TxContext) { │ ------------------- Returning an object from a function, allows a caller to use the object and enables composability via programmable transactions. -23 │ transfer::public_transfer(S1 { id: object::new(ctx), }, tx_context::sender(ctx)) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - │ │ │ - │ │ Transaction sender address coming from here +23 │ transfer::public_transfer(S1 { id: object::new(ctx) }, tx_context::sender(ctx)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ │ │ + │ │ Transaction sender address coming from here │ Transfer of an object to transaction sender address │ = This warning can be suppressed with '#[allow(lint(self_transfer))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -23,10 +23,10 @@ warning[Lint W99001]: non-composable transfer to sender │ 26 │ public fun private_transfer_bad(ctx: &mut TxContext) { │ -------------------- Returning an object from a function, allows a caller to use the object and enables composability via programmable transactions. -27 │ transfer::transfer(S1 { id: object::new(ctx), }, tx_context::sender(ctx)) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - │ │ │ - │ │ Transaction sender address coming from here +27 │ transfer::transfer(S1 { id: object::new(ctx) }, tx_context::sender(ctx)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ │ │ + │ │ Transaction sender address coming from here │ Transfer of an object to transaction sender address │ = This warning can be suppressed with '#[allow(lint(self_transfer))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -39,7 +39,7 @@ warning[Lint W99001]: non-composable transfer to sender 37 │ let sender = tx_context::sender(ctx); │ ----------------------- Transaction sender address coming from here 38 │ let another_sender = sender; -39 │ transfer::public_transfer(S1 { id: object::new(ctx), }, another_sender) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Transfer of an object to transaction sender address +39 │ transfer::public_transfer(S1 { id: object::new(ctx) }, another_sender) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Transfer of an object to transaction sender address │ = This warning can be suppressed with '#[allow(lint(self_transfer))]' applied to the 'module' or module member ('const', 'fun', or 'struct') diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/suppress_lint_missing_key.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/suppress_lint_missing_key.move index 3e86667a95af7..a356094c7f1c5 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/suppress_lint_missing_key.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/suppress_lint_missing_key.move @@ -4,7 +4,7 @@ module a::trigger_lint_cases { // 4. Suppress warning #[allow(lint(missing_key))] struct SuppressWarning { - id: UID, + id: UID, } } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/suppress_public_mut_tx_context.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/suppress_public_mut_tx_context.move index 2d8f98657902c..5ef0b0324a7cf 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/suppress_public_mut_tx_context.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/suppress_public_mut_tx_context.move @@ -2,16 +2,13 @@ module 0x42::suppress_cases { use sui::tx_context::TxContext; #[allow(lint(prefer_mut_tx_context))] - public fun suppressed_function(_ctx: &TxContext) { - } + public fun suppressed_function(_ctx: &TxContext) {} #[allow(lint(prefer_mut_tx_context))] - public fun multi_suppressed_function(_ctx: &TxContext) { - } + public fun multi_suppressed_function(_ctx: &TxContext) {} #[allow(lint(prefer_mut_tx_context))] - public fun suppressed_multi_param(_a: u64, _ctx: &TxContext, _b: &mut TxContext) { - } + public fun suppressed_multi_param(_a: u64, _ctx: &TxContext, _b: &mut TxContext) {} } // Mocking the sui::tx_context module diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/suppress_unnecessary_public_entry.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/suppress_unnecessary_public_entry.move index a86c02e0e4ea5..1e048ccf9ae42 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/suppress_unnecessary_public_entry.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/suppress_unnecessary_public_entry.move @@ -1,8 +1,7 @@ module a::m { - #[allow(lint(public_entry))] public entry fun suppress_unnecessary_public_entry() {} #[allow(lint(public_entry))] - entry public fun suppress_unnecessary_public_entry_2() {} + public entry fun suppress_unnecessary_public_entry_2() {} } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/trigger_lint_missing_key.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/trigger_lint_missing_key.move index 5b6bb908d4ff3..c146e10a46bac 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/trigger_lint_missing_key.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/trigger_lint_missing_key.move @@ -5,7 +5,6 @@ module a::trigger_lint_cases { struct MissingKeyAbility { id: UID, } - } module sui::object { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_negative_public_mut_tx_context.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_negative_public_mut_tx_context.move index 1796cb046a7b7..b1305a5e2b87a 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_negative_public_mut_tx_context.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_negative_public_mut_tx_context.move @@ -3,18 +3,13 @@ module 0x42::true_negative { use sui::tx_context::TxContext; - public fun correct_mint(_ctx: &mut TxContext) { - } + public fun correct_mint(_ctx: &mut TxContext) {} - public fun another_correct(_a: u64, _b: &mut TxContext, _c: u64) { - } + public fun another_correct(_a: u64, _b: &mut TxContext, _c: u64) {} - fun private_function(_ctx: &TxContext) { - } + fun private_function(_ctx: &TxContext) {} public fun custom_module(_b: &mut sui::mock_tx_context::TxContext) {} - - } module sui::tx_context { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_negative_share_owned.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_negative_share_owned.move index 99f4d04ed30cb..ed2c8c21fe26b 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_negative_share_owned.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_negative_share_owned.move @@ -1,11 +1,11 @@ // object is re shared, but it is never transferred and doesn't have public transfer module a::is_not_transferred { + use sui::object::UID; use sui::transfer; use sui::tx_context::TxContext; - use sui::object::UID; struct Obj has key { - id: UID + id: UID, } public fun make_obj(ctx: &mut TxContext): Obj { @@ -23,11 +23,11 @@ module a::is_not_transferred { // object is created locally, even though it is transferred somewhere else and has public share module a::can_determine_to_be_new { - use sui::transfer; use sui::object::UID; + use sui::transfer; struct Obj has key, store { - id: UID + id: UID, } fun make_obj(_: u64, _: vector>, ctx: &mut sui::tx_context::TxContext): Obj { @@ -45,14 +45,13 @@ module a::can_determine_to_be_new { } } - // object is created locally, but the analysis cannot determine that currently module b::can_determine_to_be_new_with_struct { - use sui::transfer; use sui::object::UID; + use sui::transfer; struct Obj has key { - id: UID + id: UID, } struct X has drop {} @@ -72,10 +71,9 @@ module b::can_determine_to_be_new_with_struct { } } - - module sui::tx_context { struct TxContext has drop {} + public fun sender(_: &TxContext): address { @0 } @@ -83,12 +81,15 @@ module sui::tx_context { module sui::object { const ZERO: u64 = 0; + struct UID has store { id: address, } + public fun delete(_: UID) { abort ZERO } + public fun new(_: &mut sui::tx_context::TxContext): UID { abort ZERO } @@ -96,12 +97,15 @@ module sui::object { module sui::transfer { const ZERO: u64 = 0; + public fun transfer(_: T, _: address) { abort ZERO } + public fun share_object(_: T) { abort ZERO } + public fun public_share_object(_: T) { abort ZERO } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_positive_public_mut_tx_context.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_positive_public_mut_tx_context.move index cee7d73f1b2e7..628e2afc2da33 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_positive_public_mut_tx_context.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_positive_public_mut_tx_context.move @@ -5,11 +5,9 @@ module 0x42::true_positive { struct CustomStruct has drop {} - public fun incorrect_mint(_ctx: &TxContext) { - } + public fun incorrect_mint(_ctx: &TxContext) {} - public fun another_incorrect(_a: u64, _b: &TxContext, _c: u64) { - } + public fun another_incorrect(_a: u64, _b: &TxContext, _c: u64) {} public fun mixed_function(_a: &CustomStruct, _b: &TxContext, _c: &mut TxContext) {} @@ -20,7 +18,7 @@ module 0x42::true_positive { _b: &TxContext, // Should warn _c: &mut TxContext, _d: &T, - _e: &CustomStruct + _e: &CustomStruct, ) {} } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_positive_public_mut_tx_context.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_positive_public_mut_tx_context.snap index ff9cc6cd6fee9..37e4bf060ebe9 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_positive_public_mut_tx_context.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_positive_public_mut_tx_context.snap @@ -8,34 +8,34 @@ info: warning[Lint W99009]: prefer '&mut TxContext' over '&TxContext' ┌─ tests/sui_mode/linter/true_positive_public_mut_tx_context.move:8:37 │ -8 │ public fun incorrect_mint(_ctx: &TxContext) { +8 │ public fun incorrect_mint(_ctx: &TxContext) {} │ ^^^^^^^^^^ 'public' functions should prefer '&mut TxContext' over '&TxContext' for better upgradability. │ = When upgrading, the public function cannot be modified to take '&mut TxContext' instead of '&TxContext'. As such, it is recommended to consider using '&mut TxContext' to future-proof the function. = This warning can be suppressed with '#[allow(lint(prefer_mut_tx_context))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99009]: prefer '&mut TxContext' over '&TxContext' - ┌─ tests/sui_mode/linter/true_positive_public_mut_tx_context.move:11:47 + ┌─ tests/sui_mode/linter/true_positive_public_mut_tx_context.move:10:47 │ -11 │ public fun another_incorrect(_a: u64, _b: &TxContext, _c: u64) { +10 │ public fun another_incorrect(_a: u64, _b: &TxContext, _c: u64) {} │ ^^^^^^^^^^ 'public' functions should prefer '&mut TxContext' over '&TxContext' for better upgradability. │ = When upgrading, the public function cannot be modified to take '&mut TxContext' instead of '&TxContext'. As such, it is recommended to consider using '&mut TxContext' to future-proof the function. = This warning can be suppressed with '#[allow(lint(prefer_mut_tx_context))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99009]: prefer '&mut TxContext' over '&TxContext' - ┌─ tests/sui_mode/linter/true_positive_public_mut_tx_context.move:14:54 + ┌─ tests/sui_mode/linter/true_positive_public_mut_tx_context.move:12:54 │ -14 │ public fun mixed_function(_a: &CustomStruct, _b: &TxContext, _c: &mut TxContext) {} +12 │ public fun mixed_function(_a: &CustomStruct, _b: &TxContext, _c: &mut TxContext) {} │ ^^^^^^^^^^ 'public' functions should prefer '&mut TxContext' over '&TxContext' for better upgradability. │ = When upgrading, the public function cannot be modified to take '&mut TxContext' instead of '&TxContext'. As such, it is recommended to consider using '&mut TxContext' to future-proof the function. = This warning can be suppressed with '#[allow(lint(prefer_mut_tx_context))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99009]: prefer '&mut TxContext' over '&TxContext' - ┌─ tests/sui_mode/linter/true_positive_public_mut_tx_context.move:20:13 + ┌─ tests/sui_mode/linter/true_positive_public_mut_tx_context.move:18:13 │ -20 │ _b: &TxContext, // Should warn +18 │ _b: &TxContext, // Should warn │ ^^^^^^^^^^ 'public' functions should prefer '&mut TxContext' over '&TxContext' for better upgradability. │ = When upgrading, the public function cannot be modified to take '&mut TxContext' instead of '&TxContext'. As such, it is recommended to consider using '&mut TxContext' to future-proof the function. diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_positive_share_owned.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_positive_share_owned.move index 6e70d5f3eec0c..fedb6567b74e3 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_positive_share_owned.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_positive_share_owned.move @@ -1,11 +1,11 @@ // object has store, might be transferred elsewhere module a::has_store { + use sui::object::UID; use sui::transfer; use sui::tx_context::TxContext; - use sui::object::UID; struct Obj has key, store { - id: UID + id: UID, } public fun make_obj(ctx: &mut TxContext): Obj { @@ -20,12 +20,12 @@ module a::has_store { // object does not have store and is transferred module a::is_transferred { + use sui::object::UID; use sui::transfer; use sui::tx_context::{Self, TxContext}; - use sui::object::UID; struct Obj has key { - id: UID + id: UID, } public fun make_obj(ctx: &mut TxContext): Obj { @@ -45,6 +45,7 @@ module a::is_transferred { module sui::tx_context { struct TxContext has drop {} + public fun sender(_: &TxContext): address { @0 } @@ -52,12 +53,15 @@ module sui::tx_context { module sui::object { const ZERO: u64 = 0; + struct UID has store { id: address, } + public fun delete(_: UID) { abort ZERO } + public fun new(_: &mut sui::tx_context::TxContext): UID { abort ZERO } @@ -65,12 +69,15 @@ module sui::object { module sui::transfer { const ZERO: u64 = 0; + public fun transfer(_: T, _: address) { abort ZERO } + public fun share_object(_: T) { abort ZERO } + public fun public_share_object(_: T) { abort ZERO } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_unnecessary_public_entry.move b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_unnecessary_public_entry.move index 9958bc9d25aa5..8a3bd35c07ea1 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_unnecessary_public_entry.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_unnecessary_public_entry.move @@ -1,6 +1,9 @@ module a::m { public entry fun true_unnecessary_public_entry() {} - entry public fun true_unnecessary_public_entry_2() {} + + public entry fun true_unnecessary_public_entry_2() {} + entry fun true_unnecessary_public_entry_3() {} + public fun true_unnecessary_public_entry_4() {} } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_unnecessary_public_entry.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_unnecessary_public_entry.snap index faa035956661d..0f29d5091f35e 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_unnecessary_public_entry.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/linter/true_unnecessary_public_entry.snap @@ -15,10 +15,10 @@ warning[Lint W99010]: unnecessary `entry` on a `public` function = This warning can be suppressed with '#[allow(lint(public_entry))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W99010]: unnecessary `entry` on a `public` function - ┌─ tests/sui_mode/linter/true_unnecessary_public_entry.move:3:5 + ┌─ tests/sui_mode/linter/true_unnecessary_public_entry.move:4:12 │ -3 │ entry public fun true_unnecessary_public_entry_2() {} - │ ^^^^^ `entry` on `public` functions limits composability as it adds restrictions, e.g. the type of each return value must have `drop`. `entry` on `public` is only meaningful in niche scenarios. +4 │ public entry fun true_unnecessary_public_entry_2() {} + │ ^^^^^ `entry` on `public` functions limits composability as it adds restrictions, e.g. the type of each return value must have `drop`. `entry` on `public` is only meaningful in niche scenarios. │ = `public` functions can be called from PTBs. `entry` can be used to allow non-`public` functions to be called from PTBs, but it adds restrictions on the usage of input arguments and on the type of return values. Unless this `public` function interacts with an intricate set of other `entry` functions, the `entry` modifier should be removed. = This warning can be suppressed with '#[allow(lint(public_entry))]' applied to the 'module' or module member ('const', 'fun', or 'struct') diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/expansion/implicit_sui_aliases.move b/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/expansion/implicit_sui_aliases.move index 93c61989e6f04..c54a8eeef5f1e 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/expansion/implicit_sui_aliases.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/expansion/implicit_sui_aliases.move @@ -4,6 +4,7 @@ // use sui::tx_context::{Self, TxContext}; module a::m { public struct S has key { id: UID, other: ID } + public fun create(ctx: &mut TxContext) { transfer::transfer( S { id: object::new(ctx), other: object::id_from_address(@0) }, @@ -12,11 +13,10 @@ module a::m { } } - // we don't link out to the sui framework module sui::object { public struct ID has copy, drop, store { - bytes: address + bytes: address, } public struct UID has store { @@ -24,6 +24,7 @@ module sui::object { } public fun new(_: &mut TxContext): UID { abort 0 } + public fun id_from_address(_: address): ID { abort 0 } } module sui::transfer { @@ -31,5 +32,6 @@ module sui::transfer { } module sui::tx_context { public struct TxContext has drop {} + public fun sender(_: &TxContext): address { @0 } } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move b/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move index 0603222f2856b..05724cafba48a 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move @@ -2,7 +2,9 @@ module sui::object { public struct ID() public struct UID() } -module sui::transfer {} +module sui::transfer { + +} module sui::tx_context { public struct TxContext() } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/expansion/unnecessary_alias_default.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/expansion/unnecessary_alias_default.snap index 6070d46e0b7b3..ccdb5f6794cee 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/expansion/unnecessary_alias_default.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/expansion/unnecessary_alias_default.snap @@ -6,97 +6,97 @@ info: lint: false --- warning[W02021]: duplicate alias - ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:11:23 + ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:13:23 │ -11 │ use sui::object::{Self, ID, UID}; +13 │ use sui::object::{Self, ID, UID}; │ ^^^^ Unnecessary alias 'object' for module 'sui::object'. This alias is provided by default │ = This warning can be suppressed with '#[allow(duplicate_alias)]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[W09001]: unused alias - ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:11:23 + ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:13:23 │ -11 │ use sui::object::{Self, ID, UID}; +13 │ use sui::object::{Self, ID, UID}; │ ^^^^ Unused 'use' of alias 'object'. Consider removing it │ = This warning can be suppressed with '#[allow(unused_use)]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[W02021]: duplicate alias - ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:11:29 + ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:13:29 │ -11 │ use sui::object::{Self, ID, UID}; +13 │ use sui::object::{Self, ID, UID}; │ ^^ Unnecessary alias 'ID' for module member 'sui::object::ID'. This alias is provided by default │ = This warning can be suppressed with '#[allow(duplicate_alias)]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[W09001]: unused alias - ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:11:29 + ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:13:29 │ -11 │ use sui::object::{Self, ID, UID}; +13 │ use sui::object::{Self, ID, UID}; │ ^^ Unused 'use' of alias 'ID'. Consider removing it │ = This warning can be suppressed with '#[allow(unused_use)]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[W02021]: duplicate alias - ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:11:33 + ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:13:33 │ -11 │ use sui::object::{Self, ID, UID}; +13 │ use sui::object::{Self, ID, UID}; │ ^^^ Unnecessary alias 'UID' for module member 'sui::object::UID'. This alias is provided by default │ = This warning can be suppressed with '#[allow(duplicate_alias)]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[W09001]: unused alias - ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:11:33 + ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:13:33 │ -11 │ use sui::object::{Self, ID, UID}; +13 │ use sui::object::{Self, ID, UID}; │ ^^^ Unused 'use' of alias 'UID'. Consider removing it │ = This warning can be suppressed with '#[allow(unused_use)]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[W02021]: duplicate alias - ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:12:14 + ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:14:14 │ -12 │ use sui::transfer; +14 │ use sui::transfer; │ ^^^^^^^^ Unnecessary alias 'transfer' for module 'sui::transfer'. This alias is provided by default │ = This warning can be suppressed with '#[allow(duplicate_alias)]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[W09001]: unused alias - ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:12:14 + ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:14:14 │ -12 │ use sui::transfer; +14 │ use sui::transfer; │ ^^^^^^^^ Unused 'use' of alias 'transfer'. Consider removing it │ = This warning can be suppressed with '#[allow(unused_use)]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[W02021]: duplicate alias - ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:13:27 + ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:15:27 │ -13 │ use sui::tx_context::{Self, TxContext}; +15 │ use sui::tx_context::{Self, TxContext}; │ ^^^^ Unnecessary alias 'tx_context' for module 'sui::tx_context'. This alias is provided by default │ = This warning can be suppressed with '#[allow(duplicate_alias)]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[W09001]: unused alias - ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:13:27 + ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:15:27 │ -13 │ use sui::tx_context::{Self, TxContext}; +15 │ use sui::tx_context::{Self, TxContext}; │ ^^^^ Unused 'use' of alias 'tx_context'. Consider removing it │ = This warning can be suppressed with '#[allow(unused_use)]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[W02021]: duplicate alias - ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:13:33 + ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:15:33 │ -13 │ use sui::tx_context::{Self, TxContext}; +15 │ use sui::tx_context::{Self, TxContext}; │ ^^^^^^^^^ Unnecessary alias 'TxContext' for module member 'sui::tx_context::TxContext'. This alias is provided by default │ = This warning can be suppressed with '#[allow(duplicate_alias)]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[W09001]: unused alias - ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:13:33 + ┌─ tests/sui_mode/move_2024/expansion/unnecessary_alias_default.move:15:33 │ -13 │ use sui::tx_context::{Self, TxContext}; +15 │ use sui::tx_context::{Self, TxContext}; │ ^^^^^^^^^ Unused 'use' of alias 'TxContext'. Consider removing it │ = This warning can be suppressed with '#[allow(unused_use)]' applied to the 'module' or module member ('const', 'fun', or 'struct') diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/typing/deprecated_transitive.move b/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/typing/deprecated_transitive.move index 645411c5af1fe..b5c6cb094bc5a 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/typing/deprecated_transitive.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/typing/deprecated_transitive.move @@ -1,16 +1,16 @@ -module a::m; +module a::m { + #[deprecated] + public struct A1(u64) has drop; -#[deprecated] -public struct A1(u64) has drop; + #[deprecated] + public struct A2(A1) has drop; -#[deprecated] -public struct A2(A1) has drop; + #[deprecated] + public fun bad_1(): A1 { let A1(x) = A1(0); A1(x) } + // ^ Should not warn about deprecated type in deprecated function -#[deprecated] -public fun bad_1(): A1 { let A1(x) = A1(0); A1(x) } - // ^ Should not warn about deprecated type in deprecated function - -#[deprecated] - // v Should not warn about deprecated type in deprecated function -public fun bad_2(): A1 { bad_1() } - // ^ Should not warn about deprecated call in deprecated function + #[deprecated] + // v Should not warn about deprecated type in deprecated function + public fun bad_2(): A1 { bad_1() } +} +// ^ Should not warn about deprecated call in deprecated function diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/typing/deprecated_unused_field.move b/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/typing/deprecated_unused_field.move index 47d14882ba19b..b005a38433458 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/typing/deprecated_unused_field.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/typing/deprecated_unused_field.move @@ -1,8 +1,8 @@ -module a::m; +module a::m { + #[deprecated] + public struct A1(u64) has drop; + // ^ Should not warn about unused field because type is marked deprecated -#[deprecated] -public struct A1(u64) has drop; - // ^ Should not warn about unused field because type is marked deprecated - -#[allow(deprecated_usage)] -public fun bad_1(): A1 { abort 0 } + #[allow(deprecated_usage)] + public fun bad_1(): A1 { abort 0 } +} diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/typing/enum_in_struct_position.move b/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/typing/enum_in_struct_position.move index 3a38fc40f633e..fa52ab203fe2a 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/typing/enum_in_struct_position.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/typing/enum_in_struct_position.move @@ -1,42 +1,39 @@ module a::m { + public enum E { + V(), + } -public enum E { - V() -} - -public enum M has drop { - V() -} - -public enum Obj has key, store { - V() -} + public enum M has drop { + V(), + } -fun init(_: M, _: &mut TxContext) { -} + public enum Obj has key, store { + V(), + } -entry fun ret(): E { - E::V() -} + fun init(_: M, _: &mut TxContext) {} -entry fun x3(_: E) { - abort 0 -} + entry fun ret(): E { + E::V() + } + entry fun x3(_: E) { + abort 0 + } } module a::n { -public fun transfer(o: a::m::Obj) { - transfer::transfer(o, @0) -} + public fun transfer(o: a::m::Obj) { + transfer::transfer(o, @0) + } } module sui::transfer { -public fun transfer(_: T, _: address) { - abort 0 -} + public fun transfer(_: T, _: address) { + abort 0 + } } -module sui::tx_context{ -public struct TxContext has drop {} +module sui::tx_context { + public struct TxContext has drop {} } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/typing/enum_in_struct_position.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/typing/enum_in_struct_position.snap index 1e2e49fc13514..dbed2650cb32f 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/typing/enum_in_struct_position.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/move_2024/typing/enum_in_struct_position.snap @@ -6,40 +6,40 @@ info: lint: false --- error[Sui E02007]: invalid object declaration - ┌─ tests/sui_mode/move_2024/typing/enum_in_struct_position.move:11:13 + ┌─ tests/sui_mode/move_2024/typing/enum_in_struct_position.move:10:17 │ -11 │ public enum Obj has key, store { - │ ^^^ --- Enums cannot have the 'key' ability. - │ │ - │ Invalid object 'Obj' +10 │ public enum Obj has key, store { + │ ^^^ --- Enums cannot have the 'key' ability. + │ │ + │ Invalid object 'Obj' error[Sui E02002]: invalid 'entry' function signature - ┌─ tests/sui_mode/move_2024/typing/enum_in_struct_position.move:18:1 + ┌─ tests/sui_mode/move_2024/typing/enum_in_struct_position.move:16:5 │ - 3 │ public enum E { - │ - To satisfy the constraint, the 'drop' ability would need to be added here + 2 │ public enum E { + │ - To satisfy the constraint, the 'drop' ability would need to be added here · -18 │ entry fun ret(): E { - │ ^^^^^ - The type 'a::m::E' does not have the ability 'drop' - │ │ - │ Invalid return type for entry function 'ret' +16 │ entry fun ret(): E { + │ ^^^^^ - The type 'a::m::E' does not have the ability 'drop' + │ │ + │ Invalid return type for entry function 'ret' error[Sui E02002]: invalid 'entry' function signature - ┌─ tests/sui_mode/move_2024/typing/enum_in_struct_position.move:22:14 + ┌─ tests/sui_mode/move_2024/typing/enum_in_struct_position.move:20:18 │ -22 │ entry fun x3(_: E) { - │ ----- ^ - 'entry' parameters must be primitives (by-value), vectors of primitives, objects (by-reference or by-value), vectors of objects, or 'Receiving' arguments (by-reference or by-value) - │ │ │ - │ │ Invalid 'entry' parameter type for parameter '_' - │ 'x3' was declared 'entry' here +20 │ entry fun x3(_: E) { + │ ----- ^ - 'entry' parameters must be primitives (by-value), vectors of primitives, objects (by-reference or by-value), vectors of objects, or 'Receiving' arguments (by-reference or by-value) + │ │ │ + │ │ Invalid 'entry' parameter type for parameter '_' + │ 'x3' was declared 'entry' here error[Sui E02009]: invalid private transfer call - ┌─ tests/sui_mode/move_2024/typing/enum_in_struct_position.move:30:5 + ┌─ tests/sui_mode/move_2024/typing/enum_in_struct_position.move:27:9 │ -11 │ public enum Obj has key, store { - │ ----- The object has 'store' so 'sui::transfer::public_transfer' can be called instead +10 │ public enum Obj has key, store { + │ ----- The object has 'store' so 'sui::transfer::public_transfer' can be called instead · -29 │ public fun transfer(o: a::m::Obj) { - │ --------- The type 'a::m::Obj' is not declared in the current module -30 │ transfer::transfer(o, @0) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid private transfer. The function 'sui::transfer::transfer' is restricted to being called in the object's module, 'a::m' +26 │ public fun transfer(o: a::m::Obj) { + │ --------- The type 'a::m::Obj' is not declared in the current module +27 │ transfer::transfer(o, @0) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid private transfer. The function 'sui::transfer::transfer' is restricted to being called in the object's module, 'a::m' diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/init_many_wrong_parameters.move b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/init_many_wrong_parameters.move index cfd7e72be437f..743f657290739 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/init_many_wrong_parameters.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/init_many_wrong_parameters.move @@ -4,6 +4,7 @@ module a::m { module a::beep { struct BEEP has drop {} + fun init(_: Who, _: u64, _: &mut sui::tx_context::TxContext) {} } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/init_many_wrong_parameters.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/init_many_wrong_parameters.snap index 971122d22d144..dc65ffbda7a45 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/init_many_wrong_parameters.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/init_many_wrong_parameters.snap @@ -32,15 +32,15 @@ error[E03002]: unbound module │ ^^^ Unbound module alias 'who' error[Sui E02003]: invalid 'init' function - ┌─ tests/sui_mode/one_time_witness/init_many_wrong_parameters.move:7:9 + ┌─ tests/sui_mode/one_time_witness/init_many_wrong_parameters.move:8:9 │ -7 │ fun init(_: Who, _: u64, _: &mut sui::tx_context::TxContext) {} +8 │ fun init(_: Who, _: u64, _: &mut sui::tx_context::TxContext) {} │ ^^^^ - 'init' functions can have at most two parameters │ │ │ Invalid 'init' function declaration error[E03004]: unbound type - ┌─ tests/sui_mode/one_time_witness/init_many_wrong_parameters.move:7:17 + ┌─ tests/sui_mode/one_time_witness/init_many_wrong_parameters.move:8:17 │ -7 │ fun init(_: Who, _: u64, _: &mut sui::tx_context::TxContext) {} +8 │ fun init(_: Who, _: u64, _: &mut sui::tx_context::TxContext) {} │ ^^^ Unbound type 'Who' in current scope diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/init_unbound_type.move b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/init_unbound_type.move index 1c2f1393a44bf..6133c2dde394e 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/init_unbound_type.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/init_unbound_type.move @@ -4,6 +4,7 @@ module a::m { module a::beep { struct BEEP has drop {} + fun init(_: Who, _ctx: &mut sui::tx_context::TxContext) {} } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/init_unbound_type.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/init_unbound_type.snap index f1e0f2f253394..a9d5e305491d2 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/init_unbound_type.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/init_unbound_type.snap @@ -12,7 +12,7 @@ error[E03002]: unbound module │ ^^^ Unbound module alias 'who' error[E03004]: unbound type - ┌─ tests/sui_mode/one_time_witness/init_unbound_type.move:7:17 + ┌─ tests/sui_mode/one_time_witness/init_unbound_type.move:8:17 │ -7 │ fun init(_: Who, _ctx: &mut sui::tx_context::TxContext) {} +8 │ fun init(_: Who, _ctx: &mut sui::tx_context::TxContext) {} │ ^^^ Unbound type 'Who' in current scope diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/instantiate.move b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/instantiate.move index 5720ece0aee9e..6edf4a3ea191e 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/instantiate.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/instantiate.move @@ -5,8 +5,7 @@ module a::m { struct M has drop { dummy: bool } - fun init(_otw: M, _ctx: &mut tx_context::TxContext) { - } + fun init(_otw: M, _ctx: &mut tx_context::TxContext) {} fun pack(): M { M { dummy: false } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/instantiate.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/instantiate.snap index 546c410bf58bb..7b301911cb919 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/instantiate.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/instantiate.snap @@ -6,9 +6,9 @@ info: lint: false --- error[Sui E02005]: invalid one-time witness usage - ┌─ tests/sui_mode/one_time_witness/instantiate.move:12:9 + ┌─ tests/sui_mode/one_time_witness/instantiate.move:11:9 │ -12 │ M { dummy: false } +11 │ M { dummy: false } │ ^^^^^^^^^^^^^^^^^^ Invalid one-time witness construction. One-time witness types cannot be created manually, but are passed as an argument 'init' │ = One-time witness types are structs with the following requirements: their name is the upper-case version of the module's name, they have no fields (or a single boolean field), they have no type parameters, and they have only the 'drop' ability. diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/many_fields_invalid.move b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/many_fields_invalid.move index b356234257f92..8feeb0586ddd9 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/many_fields_invalid.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/many_fields_invalid.move @@ -2,10 +2,9 @@ module a::m { use sui::tx_context; - struct M has drop { some_field: bool, some_field2: bool } + struct M has drop { some_field: bool, some_field2: bool } - fun init(_otw: M, _ctx: &mut tx_context::TxContext) { - } + fun init(_otw: M, _ctx: &mut tx_context::TxContext) {} } module sui::tx_context { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/many_fields_invalid.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/many_fields_invalid.snap index 26a35e90a4b57..c17545fe4ba61 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/many_fields_invalid.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/many_fields_invalid.snap @@ -8,12 +8,12 @@ info: error[Sui E02004]: invalid one-time witness declaration ┌─ tests/sui_mode/one_time_witness/many_fields_invalid.move:5:12 │ -5 │ struct M has drop { some_field: bool, some_field2: bool } +5 │ struct M has drop { some_field: bool, some_field2: bool } │ ^ ----------- Found more than one field. One-time witness types must have no fields, or exactly one field of type 'bool' │ │ │ Invalid one-time witness declaration 6 │ -7 │ fun init(_otw: M, _ctx: &mut tx_context::TxContext) { +7 │ fun init(_otw: M, _ctx: &mut tx_context::TxContext) {} │ - Attempted usage as a one-time witness here │ = One-time witness types are structs with the following requirements: their name is the upper-case version of the module's name, they have no fields (or a single boolean field), they have no type parameters, and they have only the 'drop' ability. diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/many_fields_valid.move b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/many_fields_valid.move index 78fdb6f431c1d..c14201fafeeb9 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/many_fields_valid.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/many_fields_valid.move @@ -1,6 +1,6 @@ // Since it is not a OTW (because of the multiple fields), we can pack it module a::n { - struct N has drop { some_field: bool, some_field2: bool } + struct N has drop { some_field: bool, some_field2: bool } public fun new(): N { N { some_field: false, some_field2: true } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/more_abilities.move b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/more_abilities.move index 9cb152cb0a556..1baadc49a708b 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/more_abilities.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/more_abilities.move @@ -3,11 +3,9 @@ module a::m1 { use sui::tx_context; - struct M1 has drop, copy { dummy: bool } - - fun init(_otw: M1, _ctx: &mut tx_context::TxContext) { - } + struct M1 has copy, drop { dummy: bool } + fun init(_otw: M1, _ctx: &mut tx_context::TxContext) {} } module a::m2 { @@ -15,19 +13,15 @@ module a::m2 { struct M2 has drop, store { dummy: bool } - fun init(_otw: M2, _ctx: &mut tx_context::TxContext) { - } - + fun init(_otw: M2, _ctx: &mut tx_context::TxContext) {} } module a::m3 { use sui::tx_context; - struct M3 has drop, copy, store { dummy: bool } - - fun init(_otw: M3, _ctx: &mut tx_context::TxContext) { - } + struct M3 has copy, drop, store { dummy: bool } + fun init(_otw: M3, _ctx: &mut tx_context::TxContext) {} } module sui::tx_context { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/more_abilities.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/more_abilities.snap index 09f1e1e486dcd..e658482adfcef 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/more_abilities.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/more_abilities.snap @@ -8,17 +8,17 @@ info: error[Sui E02004]: invalid one-time witness declaration ┌─ tests/sui_mode/one_time_witness/more_abilities.move:6:12 │ -6 │ struct M1 has drop, copy { dummy: bool } - │ ^^ ---- One-time witness types can only have the have the 'drop' ability - │ │ +6 │ struct M1 has copy, drop { dummy: bool } + │ ^^ ---- One-time witness types can only have the have the 'drop' ability + │ │ │ Invalid one-time witness declaration │ = One-time witness types are structs with the following requirements: their name is the upper-case version of the module's name, they have no fields (or a single boolean field), they have no type parameters, and they have only the 'drop' ability. error[Sui E02004]: invalid one-time witness declaration - ┌─ tests/sui_mode/one_time_witness/more_abilities.move:16:12 + ┌─ tests/sui_mode/one_time_witness/more_abilities.move:14:12 │ -16 │ struct M2 has drop, store { dummy: bool } +14 │ struct M2 has drop, store { dummy: bool } │ ^^ ----- One-time witness types can only have the have the 'drop' ability │ │ │ Invalid one-time witness declaration @@ -26,11 +26,11 @@ error[Sui E02004]: invalid one-time witness declaration = One-time witness types are structs with the following requirements: their name is the upper-case version of the module's name, they have no fields (or a single boolean field), they have no type parameters, and they have only the 'drop' ability. error[Sui E02004]: invalid one-time witness declaration - ┌─ tests/sui_mode/one_time_witness/more_abilities.move:26:12 + ┌─ tests/sui_mode/one_time_witness/more_abilities.move:22:12 │ -26 │ struct M3 has drop, copy, store { dummy: bool } - │ ^^ ---- One-time witness types can only have the have the 'drop' ability - │ │ +22 │ struct M3 has copy, drop, store { dummy: bool } + │ ^^ ---- One-time witness types can only have the have the 'drop' ability + │ │ │ Invalid one-time witness declaration │ = One-time witness types are structs with the following requirements: their name is the upper-case version of the module's name, they have no fields (or a single boolean field), they have no type parameters, and they have only the 'drop' ability. diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/no_field.move b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/no_field.move index d15ac88da990f..e8954bfbddbff 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/no_field.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/no_field.move @@ -5,9 +5,7 @@ module a::m { struct M has drop {} - fun init(_otw: M, _ctx: &mut tx_context::TxContext) { - } - + fun init(_otw: M, _ctx: &mut tx_context::TxContext) {} } module sui::tx_context { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/no_init_arg.move b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/no_init_arg.move index ddc84691c145d..012a1f8dd77b6 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/no_init_arg.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/no_init_arg.move @@ -5,8 +5,7 @@ module a::m { struct M has drop { dummy: bool } - fun init(_ctx: &mut tx_context::TxContext) { - } + fun init(_ctx: &mut tx_context::TxContext) {} } module sui::tx_context { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/no_init_arg.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/no_init_arg.snap index c93b273f956f3..a348d6a0b2317 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/no_init_arg.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/no_init_arg.snap @@ -11,7 +11,7 @@ error[Sui E02003]: invalid 'init' function 6 │ struct M has drop { dummy: bool } │ - One-time witness declared here 7 │ -8 │ fun init(_ctx: &mut tx_context::TxContext) { +8 │ fun init(_ctx: &mut tx_context::TxContext) {} │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid first parameter to 'init'. Expected this module's one-time witness type 'a::m::M' │ = One-time witness types are structs with the following requirements: their name is the upper-case version of the module's name, they have no fields (or a single boolean field), they have no type parameters, and they have only the 'drop' ability. diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/other_mod_def.move b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/other_mod_def.move index b318c15860603..9be7eec4428a3 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/other_mod_def.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/other_mod_def.move @@ -4,12 +4,9 @@ module a::n { use sui::sui; use sui::tx_context; - fun init(_otw: sui::SUI, _ctx: &mut tx_context::TxContext) { - } - + fun init(_otw: sui::SUI, _ctx: &mut tx_context::TxContext) {} } - module sui::tx_context { struct TxContext has drop {} } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/other_mod_def.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/other_mod_def.snap index 86f9d7410fc2a..af3e852f74127 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/other_mod_def.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/other_mod_def.snap @@ -8,7 +8,7 @@ info: error[Sui E02003]: invalid 'init' function ┌─ tests/sui_mode/one_time_witness/other_mod_def.move:7:9 │ -7 │ fun init(_otw: sui::SUI, _ctx: &mut tx_context::TxContext) { +7 │ fun init(_otw: sui::SUI, _ctx: &mut tx_context::TxContext) {} │ ^^^^ -------- Invalid parameter '_otw' of type 'sui::sui::SUI'. Expected a one-time witness type, 'a::n::N │ │ │ Invalid 'init' function declaration diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/type_param.move b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/type_param.move index 0f873e522df66..ce0a3ed0836d2 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/type_param.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/type_param.move @@ -6,8 +6,7 @@ module a::m { struct M has drop { dummy: bool } - fun init(_otw: M, _ctx: &mut tx_context::TxContext) { - } + fun init(_otw: M, _ctx: &mut tx_context::TxContext) {} } module a::x { @@ -15,8 +14,7 @@ module a::x { struct X has drop { dummy: bool } - fun init(_ctx: &mut tx_context::TxContext) { - } + fun init(_ctx: &mut tx_context::TxContext) {} } module sui::tx_context { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/type_param.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/type_param.snap index fa7042e2af5c2..a2477760d0a78 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/type_param.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/type_param.snap @@ -18,15 +18,15 @@ error[Sui E02004]: invalid one-time witness declaration error[Sui E02003]: invalid 'init' function ┌─ tests/sui_mode/one_time_witness/type_param.move:9:9 │ -9 │ fun init(_otw: M, _ctx: &mut tx_context::TxContext) { +9 │ fun init(_otw: M, _ctx: &mut tx_context::TxContext) {} │ ^^^^ - 'init' functions cannot have type parameters │ │ │ Invalid 'init' function declaration error[Sui E02004]: invalid one-time witness declaration - ┌─ tests/sui_mode/one_time_witness/type_param.move:16:12 + ┌─ tests/sui_mode/one_time_witness/type_param.move:15:12 │ -16 │ struct X has drop { dummy: bool } +15 │ struct X has drop { dummy: bool } │ ^ - One-time witness types cannot have type parameters │ │ │ Invalid one-time witness declaration @@ -34,12 +34,12 @@ error[Sui E02004]: invalid one-time witness declaration = One-time witness types are structs with the following requirements: their name is the upper-case version of the module's name, they have no fields (or a single boolean field), they have no type parameters, and they have only the 'drop' ability. error[Sui E02003]: invalid 'init' function - ┌─ tests/sui_mode/one_time_witness/type_param.move:18:20 + ┌─ tests/sui_mode/one_time_witness/type_param.move:17:20 │ -16 │ struct X has drop { dummy: bool } +15 │ struct X has drop { dummy: bool } │ - One-time witness declared here -17 │ -18 │ fun init(_ctx: &mut tx_context::TxContext) { +16 │ +17 │ fun init(_ctx: &mut tx_context::TxContext) {} │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid first parameter to 'init'. Expected this module's one-time witness type 'a::x::X' │ = One-time witness types are structs with the following requirements: their name is the upper-case version of the module's name, they have no fields (or a single boolean field), they have no type parameters, and they have only the 'drop' ability. diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type.move b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type.move index 279d28a86c438..4e329137a099f 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type.move @@ -3,10 +3,9 @@ module a::m { use sui::tx_context; - struct M has store, drop { value: u64 } + struct M has drop, store { value: u64 } - fun init(_ctx: &mut tx_context::TxContext) { - } + fun init(_ctx: &mut tx_context::TxContext) {} fun foo() { _ = M { value: 7 }; @@ -15,7 +14,7 @@ module a::m { } module 0::beep { - struct BEEP has store { boop: sui::table::Table } + struct BEEP has store { boop: sui::table::Table } } module sui::tx_context { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type_and_extra_field.move b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type_and_extra_field.move index d7bb4e290a1a7..9b88386b8f3a1 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type_and_extra_field.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type_and_extra_field.move @@ -3,8 +3,8 @@ module a::beep { f0: u64, f1: bool, } - fun init(_ctx: &mut sui::tx_context::TxContext) { - } + + fun init(_ctx: &mut sui::tx_context::TxContext) {} } module sui::tx_context { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type_and_extra_field_with_init.move b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type_and_extra_field_with_init.move index fbc5a0c860092..3374e2b10e28f 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type_and_extra_field_with_init.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type_and_extra_field_with_init.move @@ -3,8 +3,8 @@ module a::beep { f0: u64, f1: bool, } - fun init(_: BEEP, _ctx: &mut sui::tx_context::TxContext) { - } + + fun init(_: BEEP, _ctx: &mut sui::tx_context::TxContext) {} } module sui::tx_context { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type_and_extra_field_with_init.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type_and_extra_field_with_init.snap index f4008a014254c..3584b06f85487 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type_and_extra_field_with_init.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type_and_extra_field_with_init.snap @@ -13,7 +13,7 @@ error[Sui E02004]: invalid one-time witness declaration 3 │ f0: u64, │ -- One-time witness types must have no fields, or exactly one field of type 'bool' · -6 │ fun init(_: BEEP, _ctx: &mut sui::tx_context::TxContext) { +7 │ fun init(_: BEEP, _ctx: &mut sui::tx_context::TxContext) {} │ ---- Attempted usage as a one-time witness here │ = One-time witness types are structs with the following requirements: their name is the upper-case version of the module's name, they have no fields (or a single boolean field), they have no type parameters, and they have only the 'drop' ability. diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type_with_init.move b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type_with_init.move index ea34474265dd9..c1f31f5787c99 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type_with_init.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type_with_init.move @@ -5,8 +5,7 @@ module a::m { struct M has drop { value: u64 } - fun init(_otw: M, _ctx: &mut tx_context::TxContext) { - } + fun init(_otw: M, _ctx: &mut tx_context::TxContext) {} } module sui::tx_context { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type_with_init.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type_with_init.snap index 5271a469aa8b7..1eccd7d2ee10f 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type_with_init.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_field_type_with_init.snap @@ -13,7 +13,7 @@ error[Sui E02004]: invalid one-time witness declaration │ │ │ Invalid one-time witness declaration 7 │ -8 │ fun init(_otw: M, _ctx: &mut tx_context::TxContext) { +8 │ fun init(_otw: M, _ctx: &mut tx_context::TxContext) {} │ - Attempted usage as a one-time witness here │ = One-time witness types are structs with the following requirements: their name is the upper-case version of the module's name, they have no fields (or a single boolean field), they have no type parameters, and they have only the 'drop' ability. diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_init_type.move b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_init_type.move index 7d090f1d9c754..76e2cc3f5b098 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_init_type.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_init_type.move @@ -6,8 +6,7 @@ module a::m { struct M has drop { dummy: bool } struct N has drop { dummy: bool } - fun init(_otw: N, _ctx: &mut tx_context::TxContext) { - } + fun init(_otw: N, _ctx: &mut tx_context::TxContext) {} } module sui::tx_context { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_init_type.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_init_type.snap index b96e203cf6a56..8d584f1965b62 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_init_type.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_init_type.snap @@ -8,7 +8,7 @@ info: error[Sui E02003]: invalid 'init' function ┌─ tests/sui_mode/one_time_witness/wrong_init_type.move:9:9 │ -9 │ fun init(_otw: N, _ctx: &mut tx_context::TxContext) { +9 │ fun init(_otw: N, _ctx: &mut tx_context::TxContext) {} │ ^^^^ - Invalid parameter '_otw' of type 'a::m::N'. Expected a one-time witness type, 'a::m::M │ │ │ Invalid 'init' function declaration diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_name.move b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_name.move index c86d811acca45..576d5274e1671 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_name.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_name.move @@ -5,8 +5,7 @@ module a::m { struct OneTimeWitness has drop { dummy: bool } - fun init(_otw: OneTimeWitness, _ctx: &mut tx_context::TxContext) { - } + fun init(_otw: OneTimeWitness, _ctx: &mut tx_context::TxContext) {} } module sui::tx_context { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_name.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_name.snap index 7397be902e2dc..ed34f03dc913a 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_name.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_name.snap @@ -8,7 +8,7 @@ info: error[Sui E02003]: invalid 'init' function ┌─ tests/sui_mode/one_time_witness/wrong_name.move:8:9 │ -8 │ fun init(_otw: OneTimeWitness, _ctx: &mut tx_context::TxContext) { +8 │ fun init(_otw: OneTimeWitness, _ctx: &mut tx_context::TxContext) {} │ ^^^^ -------------- Invalid parameter '_otw' of type 'a::m::OneTimeWitness'. Expected a one-time witness type, 'a::m::M │ │ │ Invalid 'init' function declaration diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_name_format.move b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_name_format.move index 8a03485509719..d0402ff7815e4 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_name_format.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_name_format.move @@ -5,8 +5,7 @@ module a::mod { struct Mod has drop { dummy: bool } - fun init(_mod: Mod, _ctx: &mut tx_context::TxContext) { - } + fun init(_mod: Mod, _ctx: &mut tx_context::TxContext) {} } module sui::tx_context { diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_name_format.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_name_format.snap index 7c778a7b3d17b..fce2eeda9e603 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_name_format.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/one_time_witness/wrong_name_format.snap @@ -8,7 +8,7 @@ info: error[Sui E02003]: invalid 'init' function ┌─ tests/sui_mode/one_time_witness/wrong_name_format.move:8:9 │ -8 │ fun init(_mod: Mod, _ctx: &mut tx_context::TxContext) { +8 │ fun init(_mod: Mod, _ctx: &mut tx_context::TxContext) {} │ ^^^^ --- Invalid parameter '_mod' of type 'a::mod::Mod'. Expected a one-time witness type, 'a::mod::MOD │ │ │ Invalid 'init' function declaration diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/new_currency.move b/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/new_currency.move index 79c025624c09c..bf5a08c3820a9 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/new_currency.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/new_currency.move @@ -1,53 +1,53 @@ // tests that `new_currency` can only be called by internal structs. module a::m { - use a::other::External; - use sui::coin_registry; - use sui::object::UID; + use a::other::External; + use sui::coin_registry; + use sui::object::UID; - struct Internal has key { - id: UID, - } + struct Internal has key { + id: UID, + } - struct InternalGeneric has key { - id: UID, - } + struct InternalGeneric has key { + id: UID, + } - public fun t1() { - coin_registry::new_currency(); - } + public fun t1() { + coin_registry::new_currency(); + } - public fun t2() { - coin_registry::new_currency(); - } + public fun t2() { + coin_registry::new_currency(); + } - public fun t3() { - coin_registry::new_currency>(); - } + public fun t3() { + coin_registry::new_currency>(); + } } module a::other { - use sui::object::UID; + use sui::object::UID; - struct External has key { - id: UID, - } + struct External has key { + id: UID, + } } module sui::object { - struct UID has store { - id: address, - } + struct UID has store { + id: address, + } } module sui::coin_registry { - public fun new_currency() { abort 0 } + public fun new_currency() { abort 0 } } module sui::coin { - use sui::object::UID; + use sui::object::UID; - struct Coin has key { - id: UID, - } + struct Coin has key { + id: UID, + } } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/new_currency.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/new_currency.snap index a0512cc4c010e..cce9adb726162 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/new_currency.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/new_currency.snap @@ -6,10 +6,10 @@ info: lint: false --- error[Sui E02010]: invalid coin creation call - ┌─ tests/sui_mode/private_generics/new_currency.move:17:5 + ┌─ tests/sui_mode/private_generics/new_currency.move:17:9 │ -17 │ coin_registry::new_currency(); - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - │ │ │ - │ │ The type 'a::other::External' is not declared in the current module - │ Invalid coin creation. The function 'sui::coin_registry::new_currency' must be called with a type defined in the current module +17 │ coin_registry::new_currency(); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ │ │ + │ │ The type 'a::other::External' is not declared in the current module + │ Invalid coin creation. The function 'sui::coin_registry::new_currency' must be called with a type defined in the current module diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/no_public_transfer.move b/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/no_public_transfer.move index 69871ae661601..c9039a7a116c2 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/no_public_transfer.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/no_public_transfer.move @@ -1,9 +1,9 @@ // tests modules cannot use transfer internal functions outside of the defining module module a::m { - use sui::transfer::{Self, Receiving}; use a::other; use sui::object::UID; + use sui::transfer::{Self, Receiving}; public fun t1(s: other::S) { transfer::transfer(s, @0x100); @@ -48,7 +48,7 @@ module sui::object { module sui::transfer { use sui::object::{UID, ID}; - struct Receiving { } + struct Receiving {} public fun transfer(_: T, _: address) { abort 0 diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/no_public_transfer_generic.move b/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/no_public_transfer_generic.move index 73a56f3c470f7..1aa0b096a633c 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/no_public_transfer_generic.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/no_public_transfer_generic.move @@ -3,8 +3,8 @@ // where a given instantiation`T<...>` has key but does _not_ have store module a::m { - use sui::transfer::{Self, Receiving}; use sui::object::UID; + use sui::transfer::{Self, Receiving}; public fun t1(s: T) { transfer::transfer(s, @0x100); @@ -36,7 +36,7 @@ module sui::object { module sui::transfer { use sui::object::UID; - struct Receiving { } + struct Receiving {} public fun transfer(_: T, _: address) { abort 0 diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/no_public_transfer_store.move b/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/no_public_transfer_store.move index 58e67c67c3f9b..403e200660ce7 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/no_public_transfer_store.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/no_public_transfer_store.move @@ -2,9 +2,9 @@ // even if it has store module a::m { - use sui::transfer::{Self, Receiving}; use a::other; use sui::object::UID; + use sui::transfer::{Self, Receiving}; public fun t1(s: other::S) { transfer::transfer(s, @0x100); @@ -42,7 +42,7 @@ module sui::object { module sui::transfer { use sui::object::UID; - struct Receiving { } + struct Receiving {} public fun transfer(_: T, _: address) { abort 0 diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/no_public_transfer_store_generic.move b/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/no_public_transfer_store_generic.move index b685a76a504a7..ee01e412ea409 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/no_public_transfer_store_generic.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/no_public_transfer_store_generic.move @@ -4,8 +4,8 @@ // where a given instantiation`T<...>` has key but does _not_ have store module a::m { - use sui::transfer::{Self, Receiving}; use sui::object::UID; + use sui::transfer::{Self, Receiving}; public fun t1(s: T) { transfer::transfer(s, @0x100); @@ -37,7 +37,7 @@ module sui::object { module sui::transfer { use sui::object::UID; - struct Receiving { } + struct Receiving {} public fun transfer(_: T, _: address) { abort 0 diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/private_event_emit_authenticated.move b/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/private_event_emit_authenticated.move index 8d44e1771546b..ee214d77b308c 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/private_event_emit_authenticated.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/private_event_emit_authenticated.move @@ -27,5 +27,6 @@ module a::other { module sui::event { public fun emit(_: T) { abort 0 } + public fun emit_authenticated(_: T) { abort 0 } -} \ No newline at end of file +} diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/public_transfer_with_store.move b/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/public_transfer_with_store.move index 654df46a8fef0..30bb6256378f5 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/public_transfer_with_store.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/public_transfer_with_store.move @@ -1,9 +1,9 @@ // tests modules can use transfer functions outside of the defining module, if the type // has store module a::m { - use sui::transfer::{Self, Receiving}; use a::other; use sui::object::UID; + use sui::transfer::{Self, Receiving}; public fun t(s: other::S) { transfer::public_transfer(s, @0x100) @@ -24,7 +24,6 @@ module a::m { public fun m(s: other::S, p: sui::party::Party) { transfer::public_party_transfer(s, p) } - } module a::other { @@ -42,7 +41,7 @@ module sui::object { module sui::transfer { use sui::object::UID; - struct Receiving { } + struct Receiving {} public fun transfer(_: T, _: address) { abort 0 diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/public_transfer_with_store_generic.move b/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/public_transfer_with_store_generic.move index f88326ffba38d..62d908b928509 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/public_transfer_with_store_generic.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/private_generics/public_transfer_with_store_generic.move @@ -2,13 +2,14 @@ // has store. module a::m { - use sui::transfer::{Self, Receiving}; use a::other; use sui::object::UID; + use sui::transfer::{Self, Receiving}; public fun t(s: other::S) { transfer::public_transfer(s, @0x100) } + public fun t_gen(s: T) { transfer::public_transfer(s, @0x100) } @@ -16,6 +17,7 @@ module a::m { public fun f(s: other::S) { transfer::public_freeze_object(s) } + public fun f_gen(s: T) { transfer::public_freeze_object(s) } @@ -23,6 +25,7 @@ module a::m { public fun s(s: other::S) { transfer::public_share_object(s) } + public fun s_gen(s: T) { transfer::public_share_object(s) } @@ -38,6 +41,7 @@ module a::m { public fun m(s: other::S, p: sui::party::Party) { transfer::public_party_transfer(s, p) } + public fun m_gen(s: T, p: sui::party::Party) { transfer::public_party_transfer(s, p) } @@ -59,7 +63,7 @@ module sui::object { module sui::transfer { use sui::object::UID; - struct Receiving { } + struct Receiving {} public fun transfer(_: T, _: address) { abort 0 diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_first_field_not_id.move b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_first_field_not_id.move index 4f69b6d00ee35..1bc9f5584a9c5 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_first_field_not_id.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_first_field_not_id.move @@ -1,6 +1,6 @@ // invalid, first field of an object must be sui::object::UID module a::m { struct S has key { - flag: bool + flag: bool, } } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_first_field_not_id.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_first_field_not_id.snap index b4a985a84dd46..8204976021b80 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_first_field_not_id.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_first_field_not_id.snap @@ -10,5 +10,5 @@ error[Sui E02007]: invalid object declaration │ 3 │ struct S has key { │ --- The 'key' ability is used to declare objects in Sui -4 │ flag: bool +4 │ flag: bool, │ ^^^^ Invalid object 'S'. Structs with the 'key' ability must have 'id: sui::object::UID' as their first field diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_struct_address.move b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_struct_address.move index 985aa7672917d..837435496ac28 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_struct_address.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_struct_address.move @@ -2,13 +2,13 @@ module a::object { struct UID has store { flag: bool } struct S has key { - id: UID + id: UID, } } module 0x3::object { struct UID has store { flag: bool } struct S has key { - id: UID + id: UID, } } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_struct_address.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_struct_address.snap index d23157a8924f3..a64c5183c517a 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_struct_address.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_struct_address.snap @@ -10,7 +10,7 @@ error[Sui E02007]: invalid object declaration │ 4 │ struct S has key { │ --- The 'key' ability is used to declare objects in Sui -5 │ id: UID +5 │ id: UID, │ ^^ --- But found type: 'a::object::UID' │ │ │ Invalid object 'S'. Structs with the 'key' ability must have 'id: sui::object::UID' as their first field @@ -20,7 +20,7 @@ error[Sui E02007]: invalid object declaration │ 11 │ struct S has key { │ --- The 'key' ability is used to declare objects in Sui -12 │ id: UID +12 │ id: UID, │ ^^ --- But found type: '0x3::object::UID' │ │ │ Invalid object 'S'. Structs with the 'key' ability must have 'id: sui::object::UID' as their first field diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_struct_name.move b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_struct_name.move index 4204ec5598c58..7da0125b2b051 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_struct_name.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_struct_name.move @@ -1,8 +1,9 @@ // invalid, objects need UID not ID module a::m { use sui::object; + struct S has key { - id: object::ID + id: object::ID, } } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_struct_name.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_struct_name.snap index b4731b31c90ed..2e51fb6944a2f 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_struct_name.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_struct_name.snap @@ -6,11 +6,11 @@ info: lint: false --- error[Sui E02007]: invalid object declaration - ┌─ tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_struct_name.move:5:9 + ┌─ tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_struct_name.move:6:9 │ -4 │ struct S has key { +5 │ struct S has key { │ --- The 'key' ability is used to declare objects in Sui -5 │ id: object::ID +6 │ id: object::ID, │ ^^ ---------- But found type: 'sui::object::ID' │ │ │ Invalid object 'S'. Structs with the 'key' ability must have 'id: sui::object::UID' as their first field diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_type.move b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_type.move index 461ff9943f949..27a780563442a 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_type.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_type.move @@ -1,6 +1,6 @@ // invalid, id field must have type UID module a::m { struct S has key { - id: bool + id: bool, } } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_type.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_type.snap index e3b966fc7ac88..d0698afbcd5ae 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_type.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_incorrect_type.snap @@ -10,7 +10,7 @@ error[Sui E02007]: invalid object declaration │ 3 │ struct S has key { │ --- The 'key' ability is used to declare objects in Sui -4 │ id: bool +4 │ id: bool, │ ^^ ---- But found type: 'bool' │ │ │ Invalid object 'S'. Structs with the 'key' ability must have 'id: sui::object::UID' as their first field diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_valid.move b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_valid.move index 8281a48b8bab5..613f0b1d3c5a2 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_valid.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_id_field_valid.move @@ -1,8 +1,9 @@ // valid module a::m { use sui::object; + struct S has key { - id: object::UID + id: object::UID, } } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_second_field_id.move b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_second_field_id.move index edb1d436903b9..c6b469c55fa2e 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_second_field_id.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_second_field_id.move @@ -2,6 +2,7 @@ module a::m { use sui::object; + struct S has key { flag: bool, id: object::UID, diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_second_field_id.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_second_field_id.snap index 6bfdea507bb14..9b4d5fe42c344 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_second_field_id.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_second_field_id.snap @@ -6,17 +6,17 @@ info: lint: false --- error[Sui E02007]: invalid object declaration - ┌─ tests/sui_mode/struct_with_key/key_struct_second_field_id.move:6:9 + ┌─ tests/sui_mode/struct_with_key/key_struct_second_field_id.move:7:9 │ -5 │ struct S has key { +6 │ struct S has key { │ --- The 'key' ability is used to declare objects in Sui -6 │ flag: bool, +7 │ flag: bool, │ ^^^^ Invalid object 'S'. Structs with the 'key' ability must have 'id: sui::object::UID' as their first field error[Sui E02007]: invalid object declaration - ┌─ tests/sui_mode/struct_with_key/key_struct_second_field_id.move:11:9 + ┌─ tests/sui_mode/struct_with_key/key_struct_second_field_id.move:12:9 │ -10 │ struct R has key { +11 │ struct R has key { │ --- The 'key' ability is used to declare objects in Sui -11 │ flag: bool, +12 │ flag: bool, │ ^^^^ Invalid object 'R'. Structs with the 'key' ability must have 'id: sui::object::UID' as their first field diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_with_drop.move b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_with_drop.move index bd5ac040bc644..907b868187545 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_with_drop.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_with_drop.move @@ -2,9 +2,10 @@ module a::m { use sui::object; + struct S has key, drop { id: object::UID, - flag: bool + flag: bool, } } diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_with_drop.snap b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_with_drop.snap index 4cd063b6ccd0f..4595a7a2fcccd 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_with_drop.snap +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/key_struct_with_drop.snap @@ -6,13 +6,13 @@ info: lint: false --- error[E05001]: ability constraint not satisfied - ┌─ tests/sui_mode/struct_with_key/key_struct_with_drop.move:6:13 + ┌─ tests/sui_mode/struct_with_key/key_struct_with_drop.move:7:13 │ - 6 │ id: object::UID, + 7 │ id: object::UID, │ ^^^^^^^^^^^ │ │ │ Invalid field type. The struct was declared with the ability 'drop' so all fields require the ability 'drop' │ The type 'sui::object::UID' does not have the ability 'drop' · -12 │ struct UID has store { +13 │ struct UID has store { │ --- To satisfy the constraint, the 'drop' ability would need to be added here diff --git a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/unused_id_field.move b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/unused_id_field.move index 52a1ea59fe8ce..95a8e01cce81c 100644 --- a/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/unused_id_field.move +++ b/external-crates/move/crates/move-compiler/tests/sui_mode/struct_with_key/unused_id_field.move @@ -4,5 +4,6 @@ module a::m { module sui::object { struct UID has store { value: address } + public fun borrow_address(id: &UID): &address { &id.value } } From 36829cfff9aed0c32ec0a0002adb23ff5ca9518a Mon Sep 17 00:00:00 2001 From: Damir Shamanaev Date: Fri, 28 Nov 2025 16:50:03 +0400 Subject: [PATCH 2/2] formats linter/move_2024 --- .../crates/move-compiler/tests/.prettierrc | 12 ++- .../move_2024/allowed_unneeded_return.move | 13 +-- .../false_negative_equal_operands.move | 1 + .../linter/move_2024/ref_deref_complex.move | 16 +-- .../linter/move_2024/ref_deref_complex.snap | 18 ++-- .../move_2024/ref_deref_conditional.move | 26 ++--- .../move_2024/ref_deref_conditional.snap | 28 ++--- .../ref_deref_conditional_valid.move | 12 +-- .../linter/move_2024/ref_deref_fields.move | 28 ++--- .../linter/move_2024/ref_deref_fields.snap | 24 ++--- .../move_2024/ref_deref_fields_valid.move | 14 +-- .../linter/move_2024/unneeded_return.move | 13 +-- .../linter/move_2024/unneeded_return.snap | 62 +++++------ .../move_2024/unneeded_return_branch.move | 9 +- .../move_2024/unneeded_return_branch.snap | 102 +++++++++--------- 15 files changed, 196 insertions(+), 182 deletions(-) diff --git a/external-crates/move/crates/move-compiler/tests/.prettierrc b/external-crates/move/crates/move-compiler/tests/.prettierrc index cfa3d29c8185a..6664d5678af30 100644 --- a/external-crates/move/crates/move-compiler/tests/.prettierrc +++ b/external-crates/move/crates/move-compiler/tests/.prettierrc @@ -2,5 +2,15 @@ "autoGroupImports": "module", "printWidth": 100, "useModuleLabel": false, - "tabWidth": 4 + "tabWidth": 4, + "overrides": [ + { + "files": "linter/move_2024/*.move", + "options": { + "parser": "move", + "tabWidth": 4, + "useModuleLabel": true + } + } + ] } diff --git a/external-crates/move/crates/move-compiler/tests/linter/move_2024/allowed_unneeded_return.move b/external-crates/move/crates/move-compiler/tests/linter/move_2024/allowed_unneeded_return.move index 6eac4f0465547..8d957f425c606 100644 --- a/external-crates/move/crates/move-compiler/tests/linter/move_2024/allowed_unneeded_return.move +++ b/external-crates/move/crates/move-compiler/tests/linter/move_2024/allowed_unneeded_return.move @@ -6,25 +6,26 @@ fun t0(): u64 { return 5 } #[allow(lint(unneeded_return))] fun t1(): u64 { return t0() } -public struct S { } +public struct S {} #[allow(lint(unneeded_return))] -fun t2(): S { return S { } } +fun t2(): S { return S {} } -public enum E { V } +public enum E { + V, +} #[allow(lint(unneeded_return))] fun t3(): E { return E::V } #[allow(lint(unneeded_return))] -fun t4(): vector { return vector[1,2,3] } +fun t4(): vector { return vector[1, 2, 3] } #[allow(lint(unneeded_return))] fun t5() { return () } #[allow(lint(unneeded_return))] -fun t6(): u64 { let x = 0; return move x -} +fun t6(): u64 { let x = 0; return move x } #[allow(lint(unneeded_return))] fun t7(): u64 { diff --git a/external-crates/move/crates/move-compiler/tests/linter/move_2024/false_negative_equal_operands.move b/external-crates/move/crates/move-compiler/tests/linter/move_2024/false_negative_equal_operands.move index be5e361978526..6c2eadc16d175 100644 --- a/external-crates/move/crates/move-compiler/tests/linter/move_2024/false_negative_equal_operands.move +++ b/external-crates/move/crates/move-compiler/tests/linter/move_2024/false_negative_equal_operands.move @@ -1,6 +1,7 @@ // this should warn, but it does not at the current state of optimizations in the compiler module a::m; + fun test_equal_operand() { let x = 0; &x == &0; diff --git a/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_complex.move b/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_complex.move index de1b87a17f134..20c85bd4be336 100644 --- a/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_complex.move +++ b/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_complex.move @@ -7,7 +7,7 @@ public struct S has copy, drop { // Non-Local but Simple Borrow Cases public fun literal_case() { - let _ref = &*&0; // Redundant borrow-dereference on literal + let _ref = &*&0; // Redundant borrow-dereference on literal } public fun literal_case_valid() { let _ref = &0; } @@ -15,7 +15,7 @@ public fun literal_case_valid() { let _ref = &0; } public fun get_resource(): S { S { a: 20 } } public fun function_call_case() { - let _ref = &*&get_resource(); // Redundant borrow-dereference on function call result + let _ref = &*&get_resource(); // Redundant borrow-dereference on function call result } public fun function_call_case_valid() { let _ref = &get_resource(); } @@ -24,30 +24,30 @@ public fun function_call_case_valid() { let _ref = &get_resource(); } public fun field_borrows() { let resource = S { a: 10 }; - let _ref = &*(&*&resource.a); // Multiple redundant borrows on field + let _ref = &*(&*&resource.a); // Multiple redundant borrows on field } public fun field_borrows_valid() { let resource = S { a: 10 }; - let _ref = &(copy resource.a); // Multiple redundant borrows on field + let _ref = &(copy resource.a); // Multiple redundant borrows on field } public fun mixed_borrow_types() { let resource = S { a: 10 }; - let _ref = &*&mut *&resource; // Mixed mutable and immutable redundant borrows + let _ref = &*&mut *&resource; // Mixed mutable and immutable redundant borrows } public fun mixed_borrow_types_valid() { let resource = S { a: 10 }; - let _ref = &(copy resource); // Mixed mutable and immutable redundant borrows + let _ref = &(copy resource); // Mixed mutable and immutable redundant borrows } public fun complex_expression() { let resource = S { a: 10 }; - let _a = *&(*&resource.a + 1); // Redundant borrows in complex expression + let _a = *&(*&resource.a + 1); // Redundant borrows in complex expression } public fun complex_expression_valid() { let resource = S { a: 10 }; - let _a = (copy resource.a) + 1; // Redundant borrows in complex expression + let _a = (copy resource.a) + 1; // Redundant borrows in complex expression } diff --git a/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_complex.snap b/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_complex.snap index d5388757b41ee..4919815dc6d68 100644 --- a/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_complex.snap +++ b/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_complex.snap @@ -8,7 +8,7 @@ info: warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_complex.move:10:17 │ -10 │ let _ref = &*&0; // Redundant borrow-dereference on literal +10 │ let _ref = &*&0; // Redundant borrow-dereference on literal │ ^^^ Redundant borrow-dereference detected. Remove this borrow-deref and use the expression directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -16,7 +16,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_complex.move:18:17 │ -18 │ let _ref = &*&get_resource(); // Redundant borrow-dereference on function call result +18 │ let _ref = &*&get_resource(); // Redundant borrow-dereference on function call result │ ^^^^^^^^^^^^^^^^ Redundant borrow-dereference detected. Remove this borrow-deref and use the expression directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -24,7 +24,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_complex.move:27:17 │ -27 │ let _ref = &*(&*&resource.a); // Multiple redundant borrows on field +27 │ let _ref = &*(&*&resource.a); // Multiple redundant borrows on field │ ^^^^^^^^^^^^^^^^ Redundant borrow-dereference detected. Use the inner expression directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -32,7 +32,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_complex.move:27:20 │ -27 │ let _ref = &*(&*&resource.a); // Multiple redundant borrows on field +27 │ let _ref = &*(&*&resource.a); // Multiple redundant borrows on field │ ^^^^^^^^^^^^ Redundant borrow-dereference detected. Use the field access directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -40,7 +40,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_complex.move:32:18 │ -32 │ let _ref = &(copy resource.a); // Multiple redundant borrows on field +32 │ let _ref = &(copy resource.a); // Multiple redundant borrows on field │ ^^^^^^^^^^^^^^^ Redundant borrow-dereference detected. Use the field access directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -48,7 +48,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_complex.move:37:17 │ -37 │ let _ref = &*&mut *&resource; // Mixed mutable and immutable redundant borrows +37 │ let _ref = &*&mut *&resource; // Mixed mutable and immutable redundant borrows │ ^^^^^^^^^^^^^^^^ Redundant borrow-dereference detected. Use the inner expression directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -56,7 +56,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_complex.move:37:23 │ -37 │ let _ref = &*&mut *&resource; // Mixed mutable and immutable redundant borrows +37 │ let _ref = &*&mut *&resource; // Mixed mutable and immutable redundant borrows │ ^^^^^^^^^^ Redundant borrow-dereference detected. Replace this borrow-deref with 'copy'. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -64,7 +64,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_complex.move:47:17 │ -47 │ let _a = *&(*&resource.a + 1); // Redundant borrows in complex expression +47 │ let _a = *&(*&resource.a + 1); // Redundant borrows in complex expression │ ^^^^^^^^^^^^ Redundant borrow-dereference detected. Use the field access directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -72,7 +72,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_complex.move:52:15 │ -52 │ let _a = (copy resource.a) + 1; // Redundant borrows in complex expression +52 │ let _a = (copy resource.a) + 1; // Redundant borrows in complex expression │ ^^^^^^^^^^^^^^^ Redundant borrow-dereference detected. Use the field access directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') diff --git a/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_conditional.move b/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_conditional.move index 652628b3ee3cf..2deff9d172f0b 100644 --- a/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_conditional.move +++ b/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_conditional.move @@ -7,19 +7,19 @@ struct MyResource has copy, drop { // Case 1: Should be flagged - simple &*& pattern public fun should_flag_simple() { let resource = MyResource { value: 10 }; - let _ref = &*&resource; // Should be flagged + let _ref = &*&resource; // Should be flagged } // Case 2: Should be flagged - &mut *& pattern public fun should_flag_mut() { let resource = MyResource { value: 10 }; - let _ref = &mut *&resource; // Should be flagged + let _ref = &mut *&resource; // Should be flagged } // Case 3: Should be flagged - &*& pattern with field access public fun should_flag_field() { let mut resource = MyResource { value: 10 }; - let _ref = &*&resource.value; // Should be flagged + let _ref = &*&resource.value; // Should be flagged resource.value = 10; } @@ -27,27 +27,27 @@ public fun should_flag_field() { public fun should_not_flag_modified() { let resource = MyResource { value: 10 }; let ref1 = &resource; - resource.value = 20; // Modifying the resource - let _ref2 = &*ref1; // No flag -- ref was made elsewhere + resource.value = 20; // Modifying the resource + let _ref2 = &*ref1; // No flag -- ref was made elsewhere } // Case 5: Should be flagged - nested &*& pattern public fun should_flag_nested() { let resource = MyResource { value: 10 }; - let _ref = &*(&*&resource); // Should be flagged + let _ref = &*(&*&resource); // Should be flagged } // Case 6: Should not be flagged - &* pattern without extra & public fun should_not_flag_deref_only() { let resource = MyResource { value: 10 }; let ref1 = &resource; - let _ref2 = &*ref1; // Should not be flagged + let _ref2 = &*ref1; // Should not be flagged } // Case 7: Should be flagged - *& pattern without leading & public fun should_flag_copy() { let resource = MyResource { value: 10 }; - let _copy = *&resource; // Should be flagged, making a copy + let _copy = *&resource; // Should be flagged, making a copy } // Case 8: Should be flagged for removal - &*& pattern with function call @@ -56,12 +56,12 @@ public fun get_resource(): MyResource { } public fun should_flag_function_call() { - let _ref = &*&get_resource(); // Should be flagged + let _ref = &*&get_resource(); // Should be flagged } // Case 9: Should be flagged for removal - &*& pattern with constant value public fun should_flag_value() { - let _ref = &*&0; // Should be flagged + let _ref = &*&0; // Should be flagged } // Case 10: Should be flagged - &*& pattern but path is mutated in a loop @@ -69,7 +69,7 @@ public fun should_flag_loop_mutation() { let mut resource = MyResource { value: 10 }; let mut i = 0; while (i < 5) { - let _ref = &*&resource; // Should be flagged regardless + let _ref = &*&resource; // Should be flagged regardless resource.value = resource.value + 1; i = i + 1; } @@ -80,10 +80,10 @@ const E: u64 = 0; // Case 11: Should be flagged -- constant #[allow(implicit_const_copy)] public fun should_flag_constant() { - let _ref = &*&E; // Should be flagged + let _ref = &*&E; // Should be flagged } // Case 12: Should be flagged -- vector public fun should_flag_vector() { - let _ref = &*&vector[1,2,3]; // Should be flagged + let _ref = &*&vector[1, 2, 3]; // Should be flagged } diff --git a/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_conditional.snap b/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_conditional.snap index a314e154c2fb0..41c174a7cc53d 100644 --- a/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_conditional.snap +++ b/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_conditional.snap @@ -16,7 +16,7 @@ error[E01003]: invalid modifier warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_conditional.move:10:17 │ -10 │ let _ref = &*&resource; // Should be flagged +10 │ let _ref = &*&resource; // Should be flagged │ ^^^^^^^^^^ Redundant borrow-dereference detected. Replace this borrow-deref with 'copy'. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -24,7 +24,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_conditional.move:16:21 │ -16 │ let _ref = &mut *&resource; // Should be flagged +16 │ let _ref = &mut *&resource; // Should be flagged │ ^^^^^^^^^^ Redundant borrow-dereference detected. Replace this borrow-deref with 'copy'. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -32,7 +32,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_conditional.move:22:17 │ -22 │ let _ref = &*&resource.value; // Should be flagged +22 │ let _ref = &*&resource.value; // Should be flagged │ ^^^^^^^^^^^^^^^^ Redundant borrow-dereference detected. Use the field access directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -43,7 +43,7 @@ error[E04024]: invalid usage of immutable variable 28 │ let resource = MyResource { value: 10 }; │ -------- To use the variable mutably, it must be declared 'mut', e.g. 'mut resource' 29 │ let ref1 = &resource; -30 │ resource.value = 20; // Modifying the resource +30 │ resource.value = 20; // Modifying the resource │ ^^^^^^^^^^^^^^ Invalid mutable borrow of immutable variable 'resource' error[E07002]: mutable ownership violated @@ -51,13 +51,13 @@ error[E07002]: mutable ownership violated │ 29 │ let ref1 = &resource; │ --------- It is still being borrowed by this reference -30 │ resource.value = 20; // Modifying the resource +30 │ resource.value = 20; // Modifying the resource │ ^^^^^^^^^^^^^^ Invalid mutable borrow at field 'value'. warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_conditional.move:37:17 │ -37 │ let _ref = &*(&*&resource); // Should be flagged +37 │ let _ref = &*(&*&resource); // Should be flagged │ ^^^^^^^^^^^^^^ Redundant borrow-dereference detected. Use the inner expression directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -65,7 +65,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_conditional.move:37:20 │ -37 │ let _ref = &*(&*&resource); // Should be flagged +37 │ let _ref = &*(&*&resource); // Should be flagged │ ^^^^^^^^^^ Redundant borrow-dereference detected. Replace this borrow-deref with 'copy'. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -73,7 +73,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_conditional.move:50:17 │ -50 │ let _copy = *&resource; // Should be flagged, making a copy +50 │ let _copy = *&resource; // Should be flagged, making a copy │ ^^^^^^^^^^ Redundant borrow-dereference detected. Replace this borrow-deref with 'copy'. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -81,7 +81,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_conditional.move:59:17 │ -59 │ let _ref = &*&get_resource(); // Should be flagged +59 │ let _ref = &*&get_resource(); // Should be flagged │ ^^^^^^^^^^^^^^^^ Redundant borrow-dereference detected. Remove this borrow-deref and use the expression directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -89,7 +89,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_conditional.move:64:17 │ -64 │ let _ref = &*&0; // Should be flagged +64 │ let _ref = &*&0; // Should be flagged │ ^^^ Redundant borrow-dereference detected. Remove this borrow-deref and use the expression directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -97,7 +97,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_conditional.move:72:21 │ -72 │ let _ref = &*&resource; // Should be flagged regardless +72 │ let _ref = &*&resource; // Should be flagged regardless │ ^^^^^^^^^^ Redundant borrow-dereference detected. Replace this borrow-deref with 'copy'. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -105,7 +105,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_conditional.move:83:17 │ -83 │ let _ref = &*&E; // Should be flagged +83 │ let _ref = &*&E; // Should be flagged │ ^^^ Redundant borrow-dereference detected. Remove this borrow-deref and use the expression directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -113,7 +113,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_conditional.move:88:17 │ -88 │ let _ref = &*&vector[1,2,3]; // Should be flagged - │ ^^^^^^^^^^^^^^^ Redundant borrow-dereference detected. Remove this borrow-deref and use the expression directly. +88 │ let _ref = &*&vector[1, 2, 3]; // Should be flagged + │ ^^^^^^^^^^^^^^^^^ Redundant borrow-dereference detected. Remove this borrow-deref and use the expression directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') diff --git a/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_conditional_valid.move b/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_conditional_valid.move index 3392b4336cbc5..c683c4dd82acc 100644 --- a/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_conditional_valid.move +++ b/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_conditional_valid.move @@ -7,7 +7,7 @@ public struct MyResource has copy, drop { // Case 1 public fun should_not_flag_simple() { let resource = MyResource { value: 10 }; - let _ref = & resource; + let _ref = &resource; } // Case 2 @@ -28,7 +28,7 @@ public fun should_not_flag_modified() { let mut resource = MyResource { value: 10 }; let ref1 = © resource; resource.value = 20; - let _ref2 = &*ref1; // No flag -- ref was made elsewhere + let _ref2 = &*ref1; // No flag -- ref was made elsewhere } // Case 5 @@ -41,7 +41,7 @@ public fun should_not_flag_nested() { public fun should_not_flag_deref_only() { let resource = MyResource { value: 10 }; let ref1 = &resource; - let _ref2 = &*ref1; // Should not be flagged + let _ref2 = &*ref1; // Should not be flagged } // Case 7 @@ -65,7 +65,7 @@ public fun should_not_flag_loop_mutation() { let mut resource = MyResource { value: 10 }; let mut i = 0; while (i < 5) { - let _ref = © resource; // Should be flagged regardless + let _ref = © resource; // Should be flagged regardless resource.value = resource.value + 1; i = i + 1; } @@ -76,10 +76,10 @@ const E: u64 = 0; // Case 11 #[allow(implicit_const_copy)] public fun should_flag_constant() { - let _ref = &E; // Should be flagged + let _ref = &E; // Should be flagged } // Case 12 public fun should_not_flag_vector() { - let _ref = &vector[1,2,3]; // Should be flagged + let _ref = &vector[1, 2, 3]; // Should be flagged } diff --git a/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_fields.move b/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_fields.move index 6381962bb954c..825e6b89fbe66 100644 --- a/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_fields.move +++ b/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_fields.move @@ -9,31 +9,31 @@ public struct MyResource has copy, drop { public fun case_1() { let resource = MyResource { value: 10 }; let ref1 = &resource; - let _ref2 = &*ref1; // Might be intentional for creating a new reference + let _ref2 = &*ref1; // Might be intentional for creating a new reference } public fun case_2(resource: &mut MyResource) { - let _ref = &mut *resource; // Might be necessary in generic contexts + let _ref = &mut *resource; // Might be necessary in generic contexts } public fun case_3() { let resource = MyResource { value: 10 }; let ref1 = &resource; - let _ref2 = &(*ref1); // Dereference then reference -- c'est la vie + let _ref2 = &(*ref1); // Dereference then reference -- c'est la vie } public fun case_5(s: S) { - let _value: T = *&((&s).value); // Complex field expression - // Could be removed in favor of the implicit copy, but path - // processing makes it unclear what to do after typing rewrites - // it. See note in lint analysis. + let _value: T = *&((&s).value); // Complex field expression + // Could be removed in favor of the implicit copy, but path + // processing makes it unclear what to do after typing rewrites + // it. See note in lint analysis. } // Flagged Cases public fun case_4() { let resource = MyResource { value: 10 }; - let _ref = &*(&*(&resource)); // Triple nested borrow-dereference, might be missed + let _ref = &*(&*(&resource)); // Triple nested borrow-dereference, might be missed } public struct S has drop { @@ -42,30 +42,30 @@ public struct S has drop { public fun case_5_b(s: S) { let _value: T = *&(copy s.value); // Complex field expression - // Could be removed in favor of the implicit copy + // Could be removed in favor of the implicit copy } public fun case_5_c(s: &S) { - let _value: T = copy s.value; // Complex field expression -- bad copy + let _value: T = copy s.value; // Complex field expression -- bad copy } public fun case_5_d(s: &mut S) { - let _value: T = copy s.value; // Complex field expression -- bad copy + let _value: T = copy s.value; // Complex field expression -- bad copy } public fun case_6() { let resource = MyResource { value: 10 }; - let _ref = &*(&resource.value); // Complex nested borrow on field + let _ref = &*(&resource.value); // Complex nested borrow on field } //Field Borrow Cases public fun redundant_case() { let resource = MyResource { value: 10 }; - let _ref = &*&resource.value; // Direct, redundant borrow-dereference on field + let _ref = &*&resource.value; // Direct, redundant borrow-dereference on field } public fun nested_case() { let resource = MyResource { value: 10 }; - let _ref = &*&(&resource).value; // Nested redundant borrow-dereference on field + let _ref = &*&(&resource).value; // Nested redundant borrow-dereference on field } diff --git a/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_fields.snap b/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_fields.snap index 59c013ba1691f..bc8d81be9b802 100644 --- a/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_fields.snap +++ b/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_fields.snap @@ -8,7 +8,7 @@ info: warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_fields.move:26:21 │ -26 │ let _value: T = *&((&s).value); // Complex field expression +26 │ let _value: T = *&((&s).value); // Complex field expression │ ^^^^^^^^^^^^^^ Redundant borrow-dereference detected. Use the inner expression directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -16,7 +16,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_fields.move:36:17 │ -36 │ let _ref = &*(&*(&resource)); // Triple nested borrow-dereference, might be missed +36 │ let _ref = &*(&*(&resource)); // Triple nested borrow-dereference, might be missed │ ^^^^^^^^^^^^^^^^ Redundant borrow-dereference detected. Use the inner expression directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -24,7 +24,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_fields.move:36:20 │ -36 │ let _ref = &*(&*(&resource)); // Triple nested borrow-dereference, might be missed +36 │ let _ref = &*(&*(&resource)); // Triple nested borrow-dereference, might be missed │ ^^^^^^^^^^^^ Redundant borrow-dereference detected. Replace this borrow-deref with 'copy'. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -46,25 +46,25 @@ warning[Lint W01009]: redundant reference/dereference = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W01009]: redundant reference/dereference - ┌─ tests/linter/move_2024/ref_deref_fields.move:49:22 + ┌─ tests/linter/move_2024/ref_deref_fields.move:49:21 │ -49 │ let _value: T = copy s.value; // Complex field expression -- bad copy - │ ^^^^^^^^^^^^ Redundant borrow-dereference detected. Use the field access directly. +49 │ let _value: T = copy s.value; // Complex field expression -- bad copy + │ ^^^^^^^^^^^^ Redundant borrow-dereference detected. Use the field access directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W01009]: redundant reference/dereference - ┌─ tests/linter/move_2024/ref_deref_fields.move:53:22 + ┌─ tests/linter/move_2024/ref_deref_fields.move:53:21 │ -53 │ let _value: T = copy s.value; // Complex field expression -- bad copy - │ ^^^^^^^^^^^^ Redundant borrow-dereference detected. Use the field access directly. +53 │ let _value: T = copy s.value; // Complex field expression -- bad copy + │ ^^^^^^^^^^^^ Redundant borrow-dereference detected. Use the field access directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_fields.move:58:17 │ -58 │ let _ref = &*(&resource.value); // Complex nested borrow on field +58 │ let _ref = &*(&resource.value); // Complex nested borrow on field │ ^^^^^^^^^^^^^^^^^^ Redundant borrow-dereference detected. Use the field access directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -72,7 +72,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_fields.move:65:17 │ -65 │ let _ref = &*&resource.value; // Direct, redundant borrow-dereference on field +65 │ let _ref = &*&resource.value; // Direct, redundant borrow-dereference on field │ ^^^^^^^^^^^^^^^^ Redundant borrow-dereference detected. Use the field access directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -80,7 +80,7 @@ warning[Lint W01009]: redundant reference/dereference warning[Lint W01009]: redundant reference/dereference ┌─ tests/linter/move_2024/ref_deref_fields.move:70:17 │ -70 │ let _ref = &*&(&resource).value; // Nested redundant borrow-dereference on field +70 │ let _ref = &*&(&resource).value; // Nested redundant borrow-dereference on field │ ^^^^^^^^^^^^^^^^^^^ Redundant borrow-dereference detected. Use the field access directly. │ = This warning can be suppressed with '#[allow(lint(redundant_ref_deref))]' applied to the 'module' or module member ('const', 'fun', or 'struct') diff --git a/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_fields_valid.move b/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_fields_valid.move index fc963e8bd1842..dd63016c081f4 100644 --- a/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_fields_valid.move +++ b/external-crates/move/crates/move-compiler/tests/linter/move_2024/ref_deref_fields_valid.move @@ -8,7 +8,7 @@ public struct MyResource has copy, drop { public fun case_4() { let resource = MyResource { value: 10 }; - let _ref = & copy resource; + let _ref = © resource; } public struct S has drop { @@ -16,7 +16,7 @@ public struct S has drop { } public fun case_5(s: S) { - let _value: T = s.value; // Complex field expression + let _value: T = s.value; // Complex field expression } public fun case_5_b(s: S) { @@ -24,26 +24,26 @@ public fun case_5_b(s: S) { } public fun case_5_c(s: &S) { - let _value: T = s.value; // Complex field expression -- bad copy + let _value: T = s.value; // Complex field expression -- bad copy } public fun case_5_d(s: &mut S) { - let _value: T = s.value; // Complex field expression -- bad copy + let _value: T = s.value; // Complex field expression -- bad copy } public fun case_6() { let resource = MyResource { value: 10 }; - let _ref = &resource.value; // Complex nested borrow on field + let _ref = &resource.value; // Complex nested borrow on field } //Field Borrow Cases public fun redundant_case() { let resource = MyResource { value: 10 }; - let _ref = &resource.value; // Direct, redundant borrow-dereference on field + let _ref = &resource.value; // Direct, redundant borrow-dereference on field } public fun nested_case() { let resource = MyResource { value: 10 }; - let _ref = &(&resource).value; // Nested redundant borrow-dereference on field + let _ref = &(&resource).value; // Nested redundant borrow-dereference on field } diff --git a/external-crates/move/crates/move-compiler/tests/linter/move_2024/unneeded_return.move b/external-crates/move/crates/move-compiler/tests/linter/move_2024/unneeded_return.move index 891cd62de161b..b758e51a07bbc 100644 --- a/external-crates/move/crates/move-compiler/tests/linter/move_2024/unneeded_return.move +++ b/external-crates/move/crates/move-compiler/tests/linter/move_2024/unneeded_return.move @@ -4,20 +4,21 @@ fun t0(): u64 { return 5 } fun t1(): u64 { return t0() } -public struct S { } +public struct S {} -fun t2(): S { return S { } } +fun t2(): S { return S {} } -public enum E { V } +public enum E { + V, +} fun t3(): E { return E::V } -fun t4(): vector { return vector[1,2,3] } +fun t4(): vector { return vector[1, 2, 3] } fun t5() { return () } -fun t6(): u64 { let x = 0; return move x -} +fun t6(): u64 { let x = 0; return move x } fun t7(): u64 { let x = 0; diff --git a/external-crates/move/crates/move-compiler/tests/linter/move_2024/unneeded_return.snap b/external-crates/move/crates/move-compiler/tests/linter/move_2024/unneeded_return.snap index ca4eca410e720..746887a10fffc 100644 --- a/external-crates/move/crates/move-compiler/tests/linter/move_2024/unneeded_return.snap +++ b/external-crates/move/crates/move-compiler/tests/linter/move_2024/unneeded_return.snap @@ -24,120 +24,120 @@ warning[Lint W04004]: unneeded return warning[Lint W04004]: unneeded return ┌─ tests/linter/move_2024/unneeded_return.move:9:15 │ -9 │ fun t2(): S { return S { } } - │ ^^^^^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position +9 │ fun t2(): S { return S {} } + │ ^^^^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return.move:13:15 + ┌─ tests/linter/move_2024/unneeded_return.move:15:15 │ -13 │ fun t3(): E { return E::V } +15 │ fun t3(): E { return E::V } │ ^^^^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return.move:15:25 + ┌─ tests/linter/move_2024/unneeded_return.move:17:25 │ -15 │ fun t4(): vector { return vector[1,2,3] } - │ ^^^^^^^^^^^^^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position +17 │ fun t4(): vector { return vector[1, 2, 3] } + │ ^^^^^^^^^^^^^^^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return.move:17:12 + ┌─ tests/linter/move_2024/unneeded_return.move:19:12 │ -17 │ fun t5() { return () } +19 │ fun t5() { return () } │ ^^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return.move:19:28 + ┌─ tests/linter/move_2024/unneeded_return.move:21:28 │ -19 │ fun t6(): u64 { let x = 0; return move x +21 │ fun t6(): u64 { let x = 0; return move x } │ ^^^^^^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return.move:24:5 + ┌─ tests/linter/move_2024/unneeded_return.move:25:5 │ -24 │ return copy x +25 │ return copy x │ ^^^^^^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return.move:29:17 + ┌─ tests/linter/move_2024/unneeded_return.move:30:17 │ -29 │ fun t8(): u64 { return VALUE } +30 │ fun t8(): u64 { return VALUE } │ ^^^^^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return.move:33:5 + ┌─ tests/linter/move_2024/unneeded_return.move:34:5 │ -33 │ return &x +34 │ return &x │ ^^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') error[E07004]: invalid return of locally borrowed state - ┌─ tests/linter/move_2024/unneeded_return.move:33:5 + ┌─ tests/linter/move_2024/unneeded_return.move:34:5 │ -33 │ return &x +34 │ return &x │ ^^^^^^^^^ │ │ │ │ │ It is still being borrowed by this reference │ Invalid return. Local variable 'x' is still being borrowed. warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return.move:36:18 + ┌─ tests/linter/move_2024/unneeded_return.move:37:18 │ -36 │ fun t10(): u64 { return 5 + 2 } +37 │ fun t10(): u64 { return 5 + 2 } │ ^^^^^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return.move:38:19 + ┌─ tests/linter/move_2024/unneeded_return.move:39:19 │ -38 │ fun t11(): bool { return !true } +39 │ fun t11(): bool { return !true } │ ^^^^^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return.move:40:25 + ┌─ tests/linter/move_2024/unneeded_return.move:41:25 │ -40 │ fun t12(x: &u64): u64 { return *x } +41 │ fun t12(x: &u64): u64 { return *x } │ ^^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return.move:42:25 + ┌─ tests/linter/move_2024/unneeded_return.move:43:25 │ -42 │ fun t13(x: u64): u128 { return x as u128 } +43 │ fun t13(x: u64): u128 { return x as u128 } │ ^^^^^^^^^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return.move:44:18 + ┌─ tests/linter/move_2024/unneeded_return.move:45:18 │ -44 │ fun t14(): u64 { return (0: u64) } +45 │ fun t14(): u64 { return (0: u64) } │ ^^^^^^^^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return.move:46:18 + ┌─ tests/linter/move_2024/unneeded_return.move:47:18 │ -46 │ fun t15(): u64 { return loop { break 5 } } +47 │ fun t15(): u64 { return loop { break 5 } } │ ^^^^^^^^^^^^^^^^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') diff --git a/external-crates/move/crates/move-compiler/tests/linter/move_2024/unneeded_return_branch.move b/external-crates/move/crates/move-compiler/tests/linter/move_2024/unneeded_return_branch.move index 6481436833a3a..2ac70dba3f9b0 100644 --- a/external-crates/move/crates/move-compiler/tests/linter/move_2024/unneeded_return_branch.move +++ b/external-crates/move/crates/move-compiler/tests/linter/move_2024/unneeded_return_branch.move @@ -1,4 +1,5 @@ module 0x42::m; + const ZERO: u64 = 0; fun t0(cond: bool): u64 { @@ -23,17 +24,17 @@ fun t4(cond: bool): u64 { public enum E has drop { V0, - V1 + V1, } -fun t5(e: E): u64{ +fun t5(e: E): u64 { return match (e) { E::V0 => 0, E::V1 => 1, } } -fun t6(e: E): u64{ +fun t6(e: E): u64 { match (e) { E::V0 => return 0, E::V1 => 1, @@ -47,7 +48,7 @@ fun t7(e: E): u64 { } } -fun t8(e: E): u64{ +fun t8(e: E): u64 { match (e) { E::V0 => return 0, E::V1 => abort ZERO, diff --git a/external-crates/move/crates/move-compiler/tests/linter/move_2024/unneeded_return_branch.snap b/external-crates/move/crates/move-compiler/tests/linter/move_2024/unneeded_return_branch.snap index 3023687b60132..44ee16a81b23e 100644 --- a/external-crates/move/crates/move-compiler/tests/linter/move_2024/unneeded_return_branch.snap +++ b/external-crates/move/crates/move-compiler/tests/linter/move_2024/unneeded_return_branch.snap @@ -6,130 +6,130 @@ info: lint: true --- warning[W09005]: dead or unreachable code - ┌─ tests/linter/move_2024/unneeded_return_branch.move:5:5 + ┌─ tests/linter/move_2024/unneeded_return_branch.move:6:5 │ -5 │ if (cond) { return 5 } else { abort ZERO } +6 │ if (cond) { return 5 } else { abort ZERO } │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Any code after this expression will not be reached │ = This warning can be suppressed with '#[allow(dead_code)]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return_branch.move:5:17 + ┌─ tests/linter/move_2024/unneeded_return_branch.move:6:17 │ -5 │ if (cond) { return 5 } else { abort ZERO } +6 │ if (cond) { return 5 } else { abort ZERO } │ ^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[W09005]: dead or unreachable code - ┌─ tests/linter/move_2024/unneeded_return_branch.move:9:5 - │ -9 │ if (cond) { return 5 } else { return 0 } - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Any code after this expression will not be reached - │ - = This warning can be suppressed with '#[allow(dead_code)]' applied to the 'module' or module member ('const', 'fun', or 'struct') + ┌─ tests/linter/move_2024/unneeded_return_branch.move:10:5 + │ +10 │ if (cond) { return 5 } else { return 0 } + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Any code after this expression will not be reached + │ + = This warning can be suppressed with '#[allow(dead_code)]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return_branch.move:9:17 - │ -9 │ if (cond) { return 5 } else { return 0 } - │ ^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position - │ - = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') + ┌─ tests/linter/move_2024/unneeded_return_branch.move:10:17 + │ +10 │ if (cond) { return 5 } else { return 0 } + │ ^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position + │ + = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return_branch.move:9:35 - │ -9 │ if (cond) { return 5 } else { return 0 } - │ ^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position - │ - = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') + ┌─ tests/linter/move_2024/unneeded_return_branch.move:10:35 + │ +10 │ if (cond) { return 5 } else { return 0 } + │ ^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position + │ + = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return_branch.move:13:5 + ┌─ tests/linter/move_2024/unneeded_return_branch.move:14:5 │ -13 │ return if (cond) { 5 } else { 0 } +14 │ return if (cond) { 5 } else { 0 } │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return_branch.move:17:5 + ┌─ tests/linter/move_2024/unneeded_return_branch.move:18:5 │ -17 │ return if (cond) { return 5 } else { 0 } +18 │ return if (cond) { return 5 } else { 0 } │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return_branch.move:21:5 + ┌─ tests/linter/move_2024/unneeded_return_branch.move:22:5 │ -21 │ return if (cond) { 5 } else { return 0 } +22 │ return if (cond) { 5 } else { return 0 } │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return_branch.move:30:5 + ┌─ tests/linter/move_2024/unneeded_return_branch.move:31:5 │ -30 │ ╭ return match (e) { -31 │ │ E::V0 => 0, -32 │ │ E::V1 => 1, -33 │ │ } +31 │ ╭ return match (e) { +32 │ │ E::V0 => 0, +33 │ │ E::V1 => 1, +34 │ │ } │ ╰─────^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return_branch.move:38:18 + ┌─ tests/linter/move_2024/unneeded_return_branch.move:39:18 │ -38 │ E::V0 => return 0, +39 │ E::V0 => return 0, │ ^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return_branch.move:45:18 + ┌─ tests/linter/move_2024/unneeded_return_branch.move:46:18 │ -45 │ E::V0 => return 0, +46 │ E::V0 => return 0, │ ^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return_branch.move:46:18 + ┌─ tests/linter/move_2024/unneeded_return_branch.move:47:18 │ -46 │ E::V1 => return 1, +47 │ E::V1 => return 1, │ ^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return_branch.move:52:18 + ┌─ tests/linter/move_2024/unneeded_return_branch.move:53:18 │ -52 │ E::V0 => return 0, +53 │ E::V0 => return 0, │ ^^^^^^^^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return_branch.move:58:5 + ┌─ tests/linter/move_2024/unneeded_return_branch.move:59:5 │ -58 │ ╭ return match (e) { -59 │ │ E::V0 => 0, -60 │ │ E::V1 => abort ZERO, -61 │ │ } +59 │ ╭ return match (e) { +60 │ │ E::V0 => 0, +61 │ │ E::V1 => abort ZERO, +62 │ │ } │ ╰─────^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct') warning[Lint W04004]: unneeded return - ┌─ tests/linter/move_2024/unneeded_return_branch.move:65:5 + ┌─ tests/linter/move_2024/unneeded_return_branch.move:66:5 │ -65 │ ╭ return match (e) { -66 │ │ E::V0 => if (true) { return 0 } else { 1 }, -67 │ │ E::V1 => 2, -68 │ │ } +66 │ ╭ return match (e) { +67 │ │ E::V0 => if (true) { return 0 } else { 1 }, +68 │ │ E::V1 => 2, +69 │ │ } │ ╰─────^ Remove unnecessary 'return', the expression is already in a 'return' position │ = This warning can be suppressed with '#[allow(lint(unneeded_return))]' applied to the 'module' or module member ('const', 'fun', or 'struct')