Skip to content

Commit

Permalink
give old list of abilities
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanjennings-mysten committed Nov 20, 2024
1 parent a5ef0a2 commit de081ab
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ error[Compatibility E01003]: ability mismatch
^^^^^^^^^^^^^^^^^^^^^^^^ Unexpected ability: 'copy'
= Structs are part of a module's public interface and cannot be changed during an upgrade.
= Restore the original struct's abilities for struct 'StructAbilityMismatchAdd': none.
= Restore the original abilities of the struct: none for struct 'StructAbilityMismatchAdd'.

error[Compatibility E01003]: ability mismatch
┌─ /fixtures/upgrade_errors/all_v2/sources/UpgradeErrors.move:14:19
Expand All @@ -36,7 +36,7 @@ error[Compatibility E01003]: ability mismatch
^^^^^^^^^^^^^^^^^^^^^^^^^^^ Missing ability: 'copy'
= Structs are part of a module's public interface and cannot be changed during an upgrade.
= Restore the original struct's abilities for struct 'StructAbilityMismatchRemove': 'copy'.
= Restore the original ability of the struct: 'copy' for struct 'StructAbilityMismatchRemove'.

error[Compatibility E01003]: ability mismatch
┌─ /fixtures/upgrade_errors/all_v2/sources/UpgradeErrors.move:17:19
Expand All @@ -45,7 +45,7 @@ error[Compatibility E01003]: ability mismatch
^^^^^^^^^^^^^^^^^^^^^^^^^^^ Mismatched abilities: missing 'copy', unexpected 'drop'
= Structs are part of a module's public interface and cannot be changed during an upgrade.
= Restore the original struct's abilities for struct 'StructAbilityMismatchChange': 'copy'.
= Restore the original ability of the struct: 'copy' for struct 'StructAbilityMismatchChange'.

error[Compatibility E01005]: type parameter mismatch
┌─ /fixtures/upgrade_errors/all_v2/sources/UpgradeErrors.move:20:19
Expand Down Expand Up @@ -93,7 +93,7 @@ error[Compatibility E01003]: ability mismatch
│ ^^^^^^^^^^^^^^^^^^^^^^ Unexpected ability: 'copy'
= Enums are part of a module's public interface and cannot be changed during an upgrade.
= Restore the original enum's abilities for enum 'EnumAbilityMismatchAdd': none.
= Restore the original abilities of the enum: none for enum 'EnumAbilityMismatchAdd'.

error[Compatibility E01003]: ability mismatch
┌─ /fixtures/upgrade_errors/all_v2/sources/UpgradeErrors.move:50:17
Expand All @@ -102,7 +102,7 @@ error[Compatibility E01003]: ability mismatch
│ ^^^^^^^^^^^^^^^^^^^^^^^^^ Missing ability: 'copy'
= Enums are part of a module's public interface and cannot be changed during an upgrade.
= Restore the original enum's abilities for enum 'EnumAbilityMismatchRemove': 'copy'.
= Restore the original ability of the enum: 'copy' for enum 'EnumAbilityMismatchRemove'.

error[Compatibility E01003]: ability mismatch
┌─ /fixtures/upgrade_errors/all_v2/sources/UpgradeErrors.move:55:17
Expand All @@ -111,7 +111,7 @@ error[Compatibility E01003]: ability mismatch
│ ^^^^^^^^^^^^^^^^^^^^^^^^^ Mismatched abilities: missing 'copy', unexpected 'drop'
= Enums are part of a module's public interface and cannot be changed during an upgrade.
= Restore the original enum's abilities for enum 'EnumAbilityMismatchChange': 'copy'.
= Restore the original ability of the enum: 'copy' for enum 'EnumAbilityMismatchChange'.

error[Compatibility E02001]: variant mismatch
┌─ /fixtures/upgrade_errors/all_v2/sources/UpgradeErrors.move:64:9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ error[Compatibility E01003]: ability mismatch
│ ^^^^^^^^^^^^^^ Unexpected ability: 'drop'
= Enums are part of a module's public interface and cannot be changed during an upgrade.
= Restore the original enum's abilities for enum 'EnumAddAbility': 'copy'.
= Restore the original ability of the enum: 'copy' for enum 'EnumAddAbility'.

error[Compatibility E01003]: ability mismatch
┌─ /fixtures/upgrade_errors/enum_errors_v2/sources/UpgradeErrors.move:13:17
Expand All @@ -18,7 +18,7 @@ error[Compatibility E01003]: ability mismatch
│ ^^^^^^^^^^^^^^^^^ Missing ability: 'drop'
= Enums are part of a module's public interface and cannot be changed during an upgrade.
= Restore the original enum's abilities for enum 'EnumRemoveAbility': 'copy' and 'drop'.
= Restore the original abilities of the enum: 'copy' and 'drop' for enum 'EnumRemoveAbility'.

error[Compatibility E01003]: ability mismatch
┌─ /fixtures/upgrade_errors/enum_errors_v2/sources/UpgradeErrors.move:17:17
Expand All @@ -27,7 +27,7 @@ error[Compatibility E01003]: ability mismatch
│ ^^^^^^^^^^^^^^^^^^^^^^^ Mismatched abilities: missing 'drop', unexpected 'store'
= Enums are part of a module's public interface and cannot be changed during an upgrade.
= Restore the original enum's abilities for enum 'EnumAddAndRemoveAbility': 'copy' and 'drop'.
= Restore the original abilities of the enum: 'copy' and 'drop' for enum 'EnumAddAndRemoveAbility'.

error[Compatibility E02001]: variant mismatch
┌─ /fixtures/upgrade_errors/enum_errors_v2/sources/UpgradeErrors.move:23:9
Expand Down Expand Up @@ -126,7 +126,7 @@ error[Compatibility E01003]: ability mismatch
│ ^^^^^^^^^^^^^^^^^^^^^^^ Unexpected ability: 'drop'
= Enums are part of a module's public interface and cannot be changed during an upgrade.
= Restore the original enum's abilities for enum 'EnumAddAbilityWithTypes': 'copy'.
= Restore the original ability of the enum: 'copy' for enum 'EnumAddAbilityWithTypes'.

error[Compatibility E01003]: ability mismatch
┌─ /fixtures/upgrade_errors/enum_errors_v2/sources/UpgradeErrors.move:53:17
Expand All @@ -135,7 +135,7 @@ error[Compatibility E01003]: ability mismatch
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Missing ability: 'drop'
= Enums are part of a module's public interface and cannot be changed during an upgrade.
= Restore the original enum's abilities for enum 'EnumRemoveAbilityWithTypes': 'copy' and 'drop'.
= Restore the original abilities of the enum: 'copy' and 'drop' for enum 'EnumRemoveAbilityWithTypes'.

error[Compatibility E02001]: variant mismatch
┌─ /fixtures/upgrade_errors/enum_errors_v2/sources/UpgradeErrors.move:59:9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ error[Compatibility E01003]: ability mismatch
^^^^^^^^^^^^^^^ Unexpected ability: 'copy'
= Structs are part of a module's public interface and cannot be changed during an upgrade.
= Restore the original struct's abilities for struct 'AddExtraAbility': none.
= Restore the original abilities of the struct: none for struct 'AddExtraAbility'.

error[Compatibility E01003]: ability mismatch
┌─ /fixtures/upgrade_errors/struct_errors_v2/sources/UpgradeErrors.move:11:19
Expand All @@ -18,7 +18,7 @@ error[Compatibility E01003]: ability mismatch
^^^^^^^^^^^^^ Missing ability: 'copy'
= Structs are part of a module's public interface and cannot be changed during an upgrade.
= Restore the original struct's abilities for struct 'RemoveAbility': 'copy' and 'drop'.
= Restore the original abilities of the struct: 'copy' and 'drop' for struct 'RemoveAbility'.

error[Compatibility E01003]: ability mismatch
┌─ /fixtures/upgrade_errors/struct_errors_v2/sources/UpgradeErrors.move:12:19
Expand All @@ -27,7 +27,7 @@ error[Compatibility E01003]: ability mismatch
^^^^^^^^^^^^^^^^^^^ Mismatched abilities: missing 'copy', unexpected 'store'
= Structs are part of a module's public interface and cannot be changed during an upgrade.
= Restore the original struct's abilities for struct 'AddAndRemoveAbility': 'copy' and 'drop'.
= Restore the original abilities of the struct: 'copy' and 'drop' for struct 'AddAndRemoveAbility'.

error[Compatibility E01003]: ability mismatch
┌─ /fixtures/upgrade_errors/struct_errors_v2/sources/UpgradeErrors.move:13:19
Expand All @@ -36,7 +36,7 @@ error[Compatibility E01003]: ability mismatch
^^^^^^^^^^^^^^^^^^^^^^^ Missing abilities: 'copy' and 'store'
= Structs are part of a module's public interface and cannot be changed during an upgrade.
= Restore the original struct's abilities for struct 'RemoveMultipleAbilities': 'copy', 'drop', and 'store'.
= Restore the original abilities of the struct: 'copy', 'drop', and 'store' for struct 'RemoveMultipleAbilities'.

error[Compatibility E01003]: ability mismatch
┌─ /fixtures/upgrade_errors/struct_errors_v2/sources/UpgradeErrors.move:14:19
Expand All @@ -45,7 +45,7 @@ error[Compatibility E01003]: ability mismatch
^^^^^^^^^^^^^^^^^^^^ Unexpected abilities: 'copy' and 'drop'
= Structs are part of a module's public interface and cannot be changed during an upgrade.
= Restore the original struct's abilities for struct 'AddMultipleAbilities': none.
= Restore the original abilities of the struct: none for struct 'AddMultipleAbilities'.

error[Compatibility E01002]: type mismatch
┌─ /fixtures/upgrade_errors/struct_errors_v2/sources/UpgradeErrors.move:17:19
Expand Down
22 changes: 18 additions & 4 deletions crates/sui/src/upgrade_compatibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,12 @@ fn struct_ability_mismatch_diag(
let def_loc = struct_sourcemap.definition_location;

if old_struct.abilities != new_struct.abilities {
let old_abilities: Vec<String> = old_struct
.abilities
.into_iter()
.map(|a| format!("'{:?}'", a).to_lowercase())
.collect();

diags.add(Diagnostic::new(
Declarations::AbilityMismatch,
(
Expand All @@ -1245,8 +1251,9 @@ fn struct_ability_mismatch_diag(
cannot be changed during an upgrade."
.to_string(),
format!(
"Restore the original struct's abilities \
for struct '{struct_name}': {}.",
"Restore the original {} of the struct: {} \
for struct '{struct_name}'.",
singular_or_plural(old_abilities.len(), "ability", "abilities"),
format_list(
old_struct
.abilities
Expand Down Expand Up @@ -1428,6 +1435,12 @@ fn enum_ability_mismatch_diag(
let def_loc = enum_sourcemap.definition_location;

if old_enum.abilities != new_enum.abilities {
let old_abilities: Vec<String> = old_enum
.abilities
.into_iter()
.map(|a| format!("'{:?}'", a).to_lowercase())
.collect();

diags.add(Diagnostic::new(
Declarations::AbilityMismatch,
(
Expand All @@ -1440,8 +1453,9 @@ fn enum_ability_mismatch_diag(
and cannot be changed during an upgrade."
.to_string(),
format!(
"Restore the original enum's abilities \
for enum '{enum_name}': {}.",
"Restore the original {} of the enum: {} \
for enum '{enum_name}'.",
singular_or_plural(old_abilities.len(), "ability", "abilities"),
format_list(
old_enum
.abilities
Expand Down

0 comments on commit de081ab

Please sign in to comment.