Skip to content

Commit

Permalink
[move] Add Move 2024 (non-beta) edition and make it the default editi…
Browse files Browse the repository at this point in the history
…on (#20242)

## Description 

Add Move `2024` edition and make it the default edition. 

## Test plan 

Updated existing tests.

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [X] CLI: Added the Move `2024` edition, and set it as the default Move
edition both when creating a new Move package and when migrating from an
existing package. Existing `2024.beta` and `2024.alpha` editions remain
supported.
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
tzakian authored Nov 13, 2024
1 parent 8f21cd7 commit 313bf8b
Show file tree
Hide file tree
Showing 69 changed files with 244 additions and 144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async fn test_manage_package_update() {
[move.toolchain-version]
compiler-version = "0.0.1"
edition = "2024.beta"
edition = "2024"
flavor = "sui"
[env]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[package]
name = "A"
edition = "2024.beta"
edition = "2024"

# this is a comment
[addresses]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package toml does not specify an edition. As of 2024, Move requires all packages

Please select one of the following editions:

1) 2024.beta
1) 2024
2) legacy

Selection (default=1):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[package]
name = "A"
edition = "2024.beta"
edition = "2024"

# this is a comment
[addresses]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package toml does not specify an edition. As of 2024, Move requires all packages

Please select one of the following editions:

1) 2024.beta
1) 2024
2) legacy

Selection (default=1):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ Command `build`:
Error: Error parsing '[package]' section of manifest

Caused by:
Invalid 'edition'. Unsupported edition "2024.migration". Current supported editions include: "legacy", "2024.alpha", and "2024.beta"
Invalid 'edition'. Unsupported edition "2024.migration". Current supported editions include: "legacy", "2024.alpha", "2024.beta", and "2024"
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[package]
name = "A"
edition = "2024.beta"
edition = "2024"

# this is a comment
[addresses]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package toml does not specify an edition. As of 2024, Move requires all packages

Please select one of the following editions:

1) 2024.beta
1) 2024
2) legacy

Selection (default=1):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[package]
name = "A"
edition = "2024.beta"
edition = "2024"

# this is a comment
[addresses]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package toml does not specify an edition. As of 2024, Move requires all packages

Please select one of the following editions:

1) 2024.beta
1) 2024
2) legacy

Selection (default=1):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[package]
name = "A"
edition = "2024.beta"
edition = "2024"

# this is a comment
[addresses]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package toml does not specify an edition. As of 2024, Move requires all packages

Please select one of the following editions:

1) 2024.beta
1) 2024
2) legacy

Selection (default=1):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[package]
name = "migration"
edition = "2024.beta"
edition = "2024"

# this is a comment
[addresses]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package toml does not specify an edition. As of 2024, Move requires all packages

Please select one of the following editions:

1) 2024.beta
1) 2024
2) legacy

Selection (default=1):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Package toml does not specify an edition. As of 2024, Move requires all packages

Please select one of the following editions:

1) 2024.beta
1) 2024
2) legacy

Selection (default=1):
Expand Down
56 changes: 42 additions & 14 deletions external-crates/move/crates/move-compiler/src/editions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,19 @@ pub fn feature_edition_error_msg(edition: Edition, feature: FeatureGate) -> Opti
feature.error_prefix()
)
} else {
format!(
"{} not supported by current edition '{edition}', \
only {} support this feature",
feature.error_prefix(),
format_oxford_list!("and", "'{}'", valid_editions)
valid_editions.last().map_or(
format!(
"{} not supported by any current edition '{edition}', \
the feature is still in development",
feature.error_prefix()
),
|supporting_edition| {
format!(
"{} not supported by current edition '{edition}'; \
the '{supporting_edition}' edition supports this feature",
feature.error_prefix(),
)
},
)
};
Some(message)
Expand Down Expand Up @@ -136,7 +144,13 @@ static SUPPORTED_FEATURES: Lazy<BTreeMap<Edition, BTreeSet<FeatureGate>>> =

const E2024_ALPHA_FEATURES: &[FeatureGate] = &[];

const E2024_BETA_FEATURES: &[FeatureGate] = &[
const E2024_BETA_FEATURES: &[FeatureGate] = &[];

const DEVELOPMENT_FEATURES: &[FeatureGate] = &[];

const E2024_MIGRATION_FEATURES: &[FeatureGate] = &[FeatureGate::Move2024Migration];

const E2024_FEATURES: &[FeatureGate] = &[
FeatureGate::NestedUse,
FeatureGate::PublicPackage,
FeatureGate::PostFixAbilities,
Expand All @@ -159,10 +173,6 @@ const E2024_BETA_FEATURES: &[FeatureGate] = &[
FeatureGate::Enums,
];

const DEVELOPMENT_FEATURES: &[FeatureGate] = &[];

const E2024_MIGRATION_FEATURES: &[FeatureGate] = &[FeatureGate::Move2024Migration];

impl Edition {
pub const LEGACY: Self = Self {
edition: symbol!("legacy"),
Expand All @@ -184,6 +194,10 @@ impl Edition {
edition: symbol!("development"),
release: None,
};
pub const E2024: Self = Self {
edition: symbol!("2024"),
release: None,
};

const SEP: &'static str = ".";

Expand All @@ -193,8 +207,16 @@ impl Edition {
Self::E2024_BETA,
Self::E2024_MIGRATION,
Self::DEVELOPMENT,
Self::E2024,
];
// NB: This is the list of editions that are considered "valid" for the purposes of the Move.
// This list should be kept in order from oldest edition to newest.
pub const VALID: &'static [Self] = &[
Self::LEGACY,
Self::E2024_ALPHA,
Self::E2024_BETA,
Self::E2024,
];
pub const VALID: &'static [Self] = &[Self::LEGACY, Self::E2024_ALPHA, Self::E2024_BETA];

pub fn supports(&self, feature: FeatureGate) -> bool {
SUPPORTED_FEATURES.get(self).unwrap().contains(&feature)
Expand All @@ -205,8 +227,9 @@ impl Edition {
match *self {
Self::LEGACY => None,
Self::E2024_ALPHA => Some(Self::E2024_BETA),
Self::E2024_BETA => Some(Self::LEGACY),
Self::E2024_MIGRATION => Some(Self::E2024_BETA),
Self::E2024_BETA => Some(Self::E2024),
Self::E2024 => Some(Self::LEGACY),
Self::E2024_MIGRATION => Some(Self::E2024),
Self::DEVELOPMENT => Some(Self::E2024_ALPHA),
_ => self.unknown_edition_panic(),
}
Expand All @@ -227,6 +250,11 @@ impl Edition {
features.extend(E2024_BETA_FEATURES);
features
}
Self::E2024 => {
let mut features = self.prev().unwrap().features();
features.extend(E2024_FEATURES);
features
}
Self::E2024_MIGRATION => {
let mut features = self.prev().unwrap().features();
features.extend(E2024_MIGRATION_FEATURES);
Expand Down Expand Up @@ -397,6 +425,6 @@ impl Serialize for Flavor {

impl Default for Edition {
fn default() -> Self {
Edition::E2024_BETA
Edition::E2024
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ error[E13001]: feature is not supported in specified edition
┌─ tests/move_check/expansion/invalid_unpack_assign_lhs_other_value.move:5:9
5 │ foo() = 0;
│ ^^^^^ Positional fields are not supported by current edition 'legacy', only '2024.alpha' and '2024.beta' support this feature
│ ^^^^^ Positional fields are not supported by current edition 'legacy'; the '2024' edition supports this feature
= You can update the edition in the 'Move.toml', or via command line flag if invoking the compiler directly.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ error[E13001]: feature is not supported in specified edition
┌─ tests/move_check/expansion/invalid_unpack_assign_mdot_no_struct.move:4:9
4 │ Self::f() = 0;
│ ^^^^^^^^^ Positional fields are not supported by current edition 'legacy', only '2024.alpha' and '2024.beta' support this feature
│ ^^^^^^^^^ Positional fields are not supported by current edition 'legacy'; the '2024' edition supports this feature
= You can update the edition in the 'Move.toml', or via command line flag if invoking the compiler directly.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ error[E13001]: feature is not supported in specified edition
┌─ tests/move_check/expansion/mdot_with_non_address_exp.move:17:9
17 │ foo().bar().X::bar()
│ ^^^^^^^^^^^ Method syntax is not supported by current edition 'legacy', only '2024.alpha' and '2024.beta' support this feature
│ ^^^^^^^^^^^ Method syntax is not supported by current edition 'legacy'; the '2024' edition supports this feature
= You can update the edition in the 'Move.toml', or via command line flag if invoking the compiler directly.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ error[E13001]: feature is not supported in specified edition
┌─ tests/move_check/expansion/pack_no_fields_single_block_other_expr.move:8:18
8 │ let _g = G ();
│ ^^^^ Positional fields are not supported by current edition 'legacy', only '2024.alpha' and '2024.beta' support this feature
│ ^^^^ Positional fields are not supported by current edition 'legacy'; the '2024' edition supports this feature
= You can update the edition in the 'Move.toml', or via command line flag if invoking the compiler directly.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E13001]: feature is not supported in specified edition
┌─ tests/move_check/expansion/type_arguments_on_field_access.move:6:9
6 │ x.f<u64>;
│ ^^^^^^^^ Method syntax is not supported by current edition 'legacy', only '2024.alpha' and '2024.beta' support this feature
│ ^^^^^^^^ Method syntax is not supported by current edition 'legacy'; the '2024' edition supports this feature
= You can update the edition in the 'Move.toml', or via command line flag if invoking the compiler directly.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ error[E13001]: feature is not supported in specified edition
┌─ tests/move_check/expansion/unpack_assign_other_expr.move:6:9
6 │ S ( f ) = S { f: 0 };
│ ^^^^^^^ Positional fields are not supported by current edition 'legacy', only '2024.alpha' and '2024.beta' support this feature
│ ^^^^^^^ Positional fields are not supported by current edition 'legacy'; the '2024' edition supports this feature
= You can update the edition in the 'Move.toml', or via command line flag if invoking the compiler directly.

Expand Down Expand Up @@ -65,7 +65,7 @@ error[E13001]: feature is not supported in specified edition
┌─ tests/move_check/expansion/unpack_assign_other_expr.move:11:9
11 │ G () = G {};
│ ^^^^ Positional fields are not supported by current edition 'legacy', only '2024.alpha' and '2024.beta' support this feature
│ ^^^^ Positional fields are not supported by current edition 'legacy'; the '2024' edition supports this feature
= You can update the edition in the 'Move.toml', or via command line flag if invoking the compiler directly.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,55 @@ error[E13001]: feature is not supported in specified edition
┌─ tests/move_check/feature_gate/dot_call.move:4:5
4 │ public use fun imm as S.f;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Method syntax is not supported by current edition 'legacy', only '2024.alpha' and '2024.beta' support this feature
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Method syntax is not supported by current edition 'legacy'; the '2024' edition supports this feature
= You can update the edition in the 'Move.toml', or via command line flag if invoking the compiler directly.

error[E13001]: feature is not supported in specified edition
┌─ tests/move_check/feature_gate/dot_call.move:13:9
13 │ use fun mut as S.g;
│ ^^^^^^^^^^^^^^^^^^^ Method syntax is not supported by current edition 'legacy', only '2024.alpha' and '2024.beta' support this feature
│ ^^^^^^^^^^^^^^^^^^^ Method syntax is not supported by current edition 'legacy'; the '2024' edition supports this feature
= You can update the edition in the 'Move.toml', or via command line flag if invoking the compiler directly.

error[E13001]: feature is not supported in specified edition
┌─ tests/move_check/feature_gate/dot_call.move:14:9
14 │ s.imm();
│ ^^^^^^^ Method syntax is not supported by current edition 'legacy', only '2024.alpha' and '2024.beta' support this feature
│ ^^^^^^^ Method syntax is not supported by current edition 'legacy'; the '2024' edition supports this feature
= You can update the edition in the 'Move.toml', or via command line flag if invoking the compiler directly.

error[E13001]: feature is not supported in specified edition
┌─ tests/move_check/feature_gate/dot_call.move:15:9
15 │ s.f();
│ ^^^^^ Method syntax is not supported by current edition 'legacy', only '2024.alpha' and '2024.beta' support this feature
│ ^^^^^ Method syntax is not supported by current edition 'legacy'; the '2024' edition supports this feature
= You can update the edition in the 'Move.toml', or via command line flag if invoking the compiler directly.

error[E13001]: feature is not supported in specified edition
┌─ tests/move_check/feature_gate/dot_call.move:16:9
16 │ s.mut();
│ ^^^^^^^ Method syntax is not supported by current edition 'legacy', only '2024.alpha' and '2024.beta' support this feature
│ ^^^^^^^ Method syntax is not supported by current edition 'legacy'; the '2024' edition supports this feature
= You can update the edition in the 'Move.toml', or via command line flag if invoking the compiler directly.

error[E13001]: feature is not supported in specified edition
┌─ tests/move_check/feature_gate/dot_call.move:17:9
17 │ s.g();
│ ^^^^^ Method syntax is not supported by current edition 'legacy', only '2024.alpha' and '2024.beta' support this feature
│ ^^^^^ Method syntax is not supported by current edition 'legacy'; the '2024' edition supports this feature
= You can update the edition in the 'Move.toml', or via command line flag if invoking the compiler directly.

error[E13001]: feature is not supported in specified edition
┌─ tests/move_check/feature_gate/dot_call.move:18:9
18 │ s.val();
│ ^^^^^^^ Method syntax is not supported by current edition 'legacy', only '2024.alpha' and '2024.beta' support this feature
│ ^^^^^^^ Method syntax is not supported by current edition 'legacy'; the '2024' edition supports this feature
= You can update the edition in the 'Move.toml', or via command line flag if invoking the compiler directly.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ error[E13001]: feature is not supported in specified edition
┌─ tests/move_check/feature_gate/macro_call.move:4:12
4 │ foo!(|| ())
│ ^ 'macro' functions are not supported by current edition 'legacy', only '2024.alpha' and '2024.beta' support this feature
│ ^ 'macro' functions are not supported by current edition 'legacy'; the '2024' edition supports this feature
= You can update the edition in the 'Move.toml', or via command line flag if invoking the compiler directly.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ error[E13001]: feature is not supported in specified edition
┌─ tests/move_check/feature_gate/macro_definition.move:2:12
2 │ public macro fun do($f: || ()) { $f() }
│ ^^^^^ 'macro' functions are not supported by current edition 'legacy', only '2024.alpha' and '2024.beta' support this feature
│ ^^^^^ 'macro' functions are not supported by current edition 'legacy'; the '2024' edition supports this feature
= You can update the edition in the 'Move.toml', or via command line flag if invoking the compiler directly.

error[E13001]: feature is not supported in specified edition
┌─ tests/move_check/feature_gate/macro_definition.move:2:38
2 │ public macro fun do($f: || ()) { $f() }
│ ^^^^ lambda expressions are not supported by current edition 'legacy', only '2024.alpha' and '2024.beta' support this feature
│ ^^^^ lambda expressions are not supported by current edition 'legacy'; the '2024' edition supports this feature
= You can update the edition in the 'Move.toml', or via command line flag if invoking the compiler directly.

Loading

0 comments on commit 313bf8b

Please sign in to comment.