diff --git a/CHANGELOG.md b/CHANGELOG.md index a494ac8..3744876 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,12 @@ -# 6.1.1 +# 6.1.1 (api=1.0.0, abi=1.0.0) - Add support for multi-fields variants in `repr(C, u*)` enums. - Deprecate support for `repr(C)` by deprecating any enum that uses it without also specifying a determinant size. -- Remove `CompilerVersion_X_Y_Z` types and their `CurrentCompilerVersion` type alias: the former were hard to keep up to date and the latter could break your code if you upgraded to a version of the compiler that `stabby` didn't know of. +- Add support for `Result`, which is fully identical to `T` down to its reports. +- Remove `CompilerVersion_X_Y_Z` types: keeping them up to date with new compiler release was too much maintenance. +- Remove `CurrentCompilerVersion` type alias: as it could break your code if you upgraded to a version of the compiler that `stabby` didn't know of. - Prepare integration of `stabby` and [`safer-ffi`](https://crates.io/crates/safer-ffi) by adding `CType` and `is_invalid` to `IStable`. +- Switch versioning system to [SemVer Prime](https://p-avital.github.io/semver-prime), using the `api, abi` as the key. +- [RFC 3633](https://github.com/rust-lang/rfcs/pull/3633) which seeks to address the breaking change in Rust 1.78 is scheduled to be discussed in July 2024. # 5.1.0 - Introducing `stabby::collections::arc_btree`, a set of copy-on-write btrees: diff --git a/Cargo.toml b/Cargo.toml index e057819..f64fa8b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,12 +33,12 @@ license = " EPL-2.0 OR Apache-2.0" categories = ["development-tools::ffi", "no-std::no-alloc"] repository = "https://github.com/ZettaScaleLabs/stabby" readme = "stabby/README.md" -version = "6.1.1" +version = "6.1.1" # Track [workspace.dependencies] -stabby-macros = { path = "./stabby-macros/", version = "6.1.1", default-features = false } -stabby-abi = { path = "./stabby-abi/", version = "6.1.1", default-features = false } -stabby = { path = "./stabby/", version = "6.1.1", default-features = false } +stabby-macros = { path = "./stabby-macros/", version = "6.1.1", default-features = false } # Track +stabby-abi = { path = "./stabby-abi/", version = "6.1.1", default-features = false } # Track +stabby = { path = "./stabby/", version = "6.1.1", default-features = false } # Track abi_stable = "0.11.2" criterion = "0.5.1" diff --git a/README.md b/README.md index 77e51fb..b300445 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ My hope with `stabby` comes in two flavors: # `stabby`'s SemVer policy Stabby includes all of its `stabby_abi::IStable` implementation in its public API: any change to an `IStable` type's memory representation is a breaking change which will lead to a `MAJOR` version change. -From `6.1.1` onwards, Stabby follows [SemVer Prime](https://p-avital.github.io/semver-prime), using the `api, abi` key. Here's a few ways you can interpret that: +From `6.1.1` onwards, Stabby follows [SemVer Prime](https://p-avital.github.io/semver-prime), using the `api, abi` as the key. Here's a few ways you can interpret that: - `stabby.version[level] = 2^(api[level]) * 3^(abi[level])` lets you compute the exact versions of stabby's ABI and API. - When upgrading stabby, you can check what has changed by dividing the new version by the previous one: if the division result is a multiple of 2, the change affected API; and it affected ABI if it's a multiple of 3. - ABI versioning: diff --git a/examples/dynlinkage/Cargo.toml b/examples/dynlinkage/Cargo.toml index 12729a9..b675eef 100644 --- a/examples/dynlinkage/Cargo.toml +++ b/examples/dynlinkage/Cargo.toml @@ -18,5 +18,5 @@ version = "0.1.0" edition = "2021" [dependencies] -stabby = { path = "../../stabby/" } -library = { path = "../library/" } # This ensures proper compilation order +stabby.workspace = true +library = { path = "../library/" } # This ensures proper compilation order diff --git a/examples/libloading/Cargo.toml b/examples/libloading/Cargo.toml index 5a38ae4..a33e64d 100644 --- a/examples/libloading/Cargo.toml +++ b/examples/libloading/Cargo.toml @@ -20,5 +20,5 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -stabby = { path = "../../stabby/", features = ["libloading"] } +stabby = { workspace = true, features = ["libloading"] } libloading = "0.8" diff --git a/examples/library/Cargo.toml b/examples/library/Cargo.toml index d8a801f..ab3564a 100644 --- a/examples/library/Cargo.toml +++ b/examples/library/Cargo.toml @@ -22,4 +22,4 @@ crate-type = ["cdylib", "staticlib"] [dependencies] -stabby = { path = "../../stabby/" } +stabby.workspace = true diff --git a/release.py b/release.py index a079750..582963c 100644 --- a/release.py +++ b/release.py @@ -1,6 +1,17 @@ import sys, os, re ws_root = os.path.dirname(__file__) crates = ["stabby-macros", "stabby-abi", "stabby"] + +def factor(x, base): + n = 0 + while x > 1 and x % base == 0: + x /= base + n += 1 + return n + +def factor_version(version, base): + return ".".join([str(factor(int(x), base)) for x in version.split(".")]) + if __name__ == "__main__": if len(sys.argv) > 1 and sys.argv[1] == "publish": for crate in crates: @@ -9,19 +20,28 @@ raise f"Failed to release {crate}, stopping publication" else: changelog = f"{ws_root}/CHANGELOG.md" + print("Close the CHANGELOG to continue, the topmost version will be picked") os.system(f"code --wait {changelog}") version = None + changelog_text = None with open(changelog) as clog: - while version is None: - line = clog.readline() - versions = re.findall("^#\s+([^:\n]+)", line) + changelog_text = clog.read() + for line in changelog_text.splitlines(): + versions = re.findall(r"^#\s+([\d\.]+)", line) version = versions[0] if len(versions) else None + if version is not None: + break + header = f"# {version} (api={factor_version(version, 2)}, abi={factor_version(version, 3)})" + print(header) + changelog_text = re.sub(r"^#\s+([\d\.]+)\s*(\(api[^\)]+\))?", header, changelog_text) + with open(changelog, "w") as clog: + clog.write(changelog_text) + print(f"Updating Cargo.tomls with version={version}") - for crate in crates: - vupdate = f"""sed -i -E 's/^version\s*=.*/version = \"{version}\"/g' {ws_root}/{crate}/Cargo.toml""" - os.system(vupdate) - print(vupdate) - dupdate = f"""sed -i -E 's/(stabby-.*version\s*=\s*)\"[^\"]*\"(.*)/\\1\"{version}\"\\2/g' {ws_root}/{crate}/Cargo.toml""" - print(dupdate) - os.system(dupdate) + ws_toml = None + with open(f"{ws_root}/Cargo.toml") as toml: + ws_toml = toml.read() + ws_toml = re.sub(r"version\s*=\s*\"[^\"]+(?P\".*Track)", f"version = \"{version}\\g", ws_toml) + with open(f"{ws_root}/Cargo.toml", "w") as toml: + toml.write(ws_toml) \ No newline at end of file diff --git a/stabby-abi/src/stable_impls/abi_stable.rs b/stabby-abi/src/stable_impls/abi_stable.rs index 711ca3d..42e2397 100644 --- a/stabby-abi/src/stable_impls/abi_stable.rs +++ b/stabby-abi/src/stable_impls/abi_stable.rs @@ -23,6 +23,7 @@ unsafe impl IStable for abi_stable::std_types::RVec { type UnusedBits = End; type HasExactlyOneNiche = B1; type ContainsIndirections = B1; + type CType = [*const T; 4]; primitive_report!("abi_stable::std_types::RVec", T); } check!(abi_stable::std_types::RVec); @@ -41,6 +42,7 @@ unsafe impl<'a, T: IStable> IStable for abi_stable::std_types::RSlice<'a, T> { type UnusedBits = End; type HasExactlyOneNiche = B0; type ContainsIndirections = B1; + type CType = [*const T; 2]; primitive_report!("abi_stable::std_types::RSlice", T); } check!(abi_stable::std_types::RSlice); @@ -59,6 +61,7 @@ unsafe impl<'a, T: IStable> IStable for abi_stable::std_types::RSliceMut<'a, T> type UnusedBits = End; type HasExactlyOneNiche = B0; type ContainsIndirections = B1; + type CType = [*const T; 2]; primitive_report!("abi_stable::std_types::RSliceMut", T); } check!(abi_stable::std_types::RSliceMut); @@ -73,6 +76,7 @@ where type UnusedBits = End; type HasExactlyOneNiche = B1; type ContainsIndirections = B1; + type CType = [*const (); 3]; primitive_report!("abi_stable::std_types::RHashMap", Tuple); } check!(abi_stable::std_types::RHashMap); @@ -91,6 +95,7 @@ unsafe impl IStable for abi_stable::std_types::RBox { type UnusedBits = End; type HasExactlyOneNiche = B1; type ContainsIndirections = B1; + type CType = [*const T; 2]; primitive_report!("abi_stable::std_types::RBox", T); } check!(abi_stable::std_types::RBox); @@ -102,6 +107,7 @@ unsafe impl IStable for abi_stable::std_types::RBoxError { type UnusedBits = End; type HasExactlyOneNiche = B1; type ContainsIndirections = B1; + type CType = [*const (); 3]; primitive_report!("abi_stable::std_types::RBoxError"); } check!(abi_stable::std_types::RBoxError); diff --git a/stabby-abi/src/stable_impls/mod.rs b/stabby-abi/src/stable_impls/mod.rs index cbbe790..e8f15e4 100644 --- a/stabby-abi/src/stable_impls/mod.rs +++ b/stabby-abi/src/stable_impls/mod.rs @@ -528,6 +528,14 @@ unsafe impl IStable for HasExactlyOneNiche, }; const ID: u64 = crate::report::gen_id(Self::REPORT); } + +unsafe impl IStable for core::result::Result { + same_as!(T); + type ContainsIndirections = T::ContainsIndirections; + const REPORT: &'static report::TypeReport = T::REPORT; + const ID: u64 = T::ID; +} + unsafe impl IStable for core::result::Result where HasExactlyOneNiche: IStable, diff --git a/stabby/README.md b/stabby/README.md index d1277f2..b300445 100644 --- a/stabby/README.md +++ b/stabby/README.md @@ -154,8 +154,8 @@ My hope with `stabby` comes in two flavors: # `stabby`'s SemVer policy Stabby includes all of its `stabby_abi::IStable` implementation in its public API: any change to an `IStable` type's memory representation is a breaking change which will lead to a `MAJOR` version change. -From `6.1.1` onwards, Stabby follows [SemVer Prime](https://p-avital.github.io/semver-prime), using the `api, abi` key. Here's a few ways you can interpret that: -- `stabby.version[level] = 2^(api[level]) * 3^(abi[level])` lets you compute the exact versions of stabby's ABI and API, there's a decoder for that [here](https://p-avital.github.io/semver-prime#:~:text=semver%20prime%20translation). +From `6.1.1` onwards, Stabby follows [SemVer Prime](https://p-avital.github.io/semver-prime), using the `api, abi` as the key. Here's a few ways you can interpret that: +- `stabby.version[level] = 2^(api[level]) * 3^(abi[level])` lets you compute the exact versions of stabby's ABI and API. - When upgrading stabby, you can check what has changed by dividing the new version by the previous one: if the division result is a multiple of 2, the change affected API; and it affected ABI if it's a multiple of 3. - ABI versioning: - Adding a new type to the set of ABI stable type will bump ABI patch.