Skip to content

Commit

Permalink
Fix failing test new rustc (#55)
Browse files Browse the repository at this point in the history
* fix: Improve doc comments

* Minor cleanup, fix of benchmark

* Fix failing test for new rustc
  • Loading branch information
avl authored May 5, 2024
1 parent be1fa1a commit 734b46f
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 168 deletions.
34 changes: 3 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions compile_tests/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions savefile-abi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.17.2](https://github.com/avl/savefile/compare/savefile-abi-v0.17.1...savefile-abi-v0.17.2) - 2024-05-05

### Other
- updated the following local packages: savefile, savefile-derive

## [0.17.1](https://github.com/avl/savefile/compare/savefile-abi-v0.17.0...savefile-abi-v0.17.1) - 2024-05-01

### Other
Expand Down
6 changes: 3 additions & 3 deletions savefile-abi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "savefile-abi"
version = "0.17.1"
version = "0.17.2"
edition = "2021"
authors = ["Anders Musikka <[email protected]>"]
documentation = "https://docs.rs/savefile-abi/"
Expand All @@ -16,7 +16,7 @@ keywords = ["dylib", "dlopen", "ffi"]
license = "MIT/Apache-2.0"

[dependencies]
savefile = { path="../savefile", version = "=0.17.1" }
savefile-derive = { path="../savefile-derive", version = "=0.17.1" }
savefile = { path="../savefile", version = "=0.17.2" }
savefile-derive = { path="../savefile-derive", version = "=0.17.2" }
byteorder = "1.4"
libloading = "0.8"
5 changes: 5 additions & 0 deletions savefile-derive/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.17.2](https://github.com/avl/savefile/compare/savefile-derive-v0.17.1...savefile-derive-v0.17.2) - 2024-05-05

### Other
- Fix failing test for new rustc

## [0.17.0-beta.15](https://github.com/avl/savefile/compare/savefile-derive-v0.17.0-beta.14...savefile-derive-v0.17.0-beta.15) - 2024-04-30

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion savefile-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "savefile-derive"
version = "0.17.1"
version = "0.17.2"
authors = ["Anders Musikka <[email protected]>"]

description = "Custom derive macros for savefile crate - simple, convenient, fast, versioned, binary serialization/deserialization library."
Expand Down
2 changes: 1 addition & 1 deletion savefile-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ pub fn savefile_abi_export(item: proc_macro::TokenStream) -> proc_macro::TokenSt
const _:() = {
#uses
#[automatically_derived]
unsafe impl AbiExportableImplementation for #implementing_type {
unsafe impl AbiExportableImplementation for #implementing_type where #implementing_type: Default + #trait_type {
const ABI_ENTRY: unsafe extern "C" fn (AbiProtocol) = #abi_entry;
type AbiInterface = dyn #trait_type;

Expand Down
1 change: 0 additions & 1 deletion savefile-min-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ edition = "2021"
savefile = { path = "../savefile", default-features = false }
savefile-abi = { path = "../savefile-abi" }
savefile-derive = {path = "../savefile-derive"}
alkahest = { version = "0.1", features=["derive"] }
127 changes: 5 additions & 122 deletions savefile-min-build/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,131 +1,14 @@
/*#![allow(soft_unstable)]
#![feature(test)]
extern crate alkahest;
extern crate test;
use std::hint::black_box;
use test::Bencher;

use savefile_derive::Savefile;
use savefile::Packed;

#[derive(Clone, Copy, Debug, PartialEq,Default)]
#[derive(alkahest::Schema)]
#[derive(Savefile)]
pub struct Vector3 {
pub x: f32,
pub y: f32,
pub z: f32,
}

impl alkahest::Pack<Vector3> for Vector3 {
#[inline]
fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed<Self>, usize) {
Vector3Pack {
x: self.x,
y: self.y,
z: self.z,
}
.pack(offset, output)
}
}
#[derive(Clone, Copy, Debug, PartialEq,Default)]
#[derive(alkahest::Schema)]
#[derive(Savefile)]
pub struct Triangle {
pub v0: Vector3,
pub v1: Vector3,
pub v2: Vector3,
pub normal: Vector3,
}
impl alkahest::Pack<Triangle> for &'_ Triangle {
#[inline]
fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed<Triangle>, usize) {
TrianglePack {
v0: self.v0,
v1: self.v1,
v2: self.v2,
normal: self.normal,
}
.pack(offset, output)
}
#[derive(Debug, Savefile, PartialEq)]
pub enum TestStructEnum {
Variant2 { a: u8, b: u8 },
}
#[derive(Clone, Debug, PartialEq,Default)]
#[derive(Savefile)]
pub struct Mesh {
pub triangles: Vec<Triangle>,
}
#[derive(alkahest::Schema)]
pub struct MeshSchema {
pub triangles: alkahest::Seq<Triangle>,
}
impl alkahest::Pack<MeshSchema> for &'_ Mesh {
#[inline]
fn pack(self, offset: usize, output: &mut [u8]) -> (alkahest::Packed<MeshSchema>, usize) {
MeshSchemaPack {
triangles: self.triangles.iter(),
}
.pack(offset, output)
}
}
pub fn generate_mesh() -> Mesh {

let mut mesh = Mesh {
triangles: vec![]
};
const TRIANGLES: usize = 125_000;
for _ in 0..TRIANGLES {
mesh.triangles.push(Triangle::default())
}
mesh
}
#[bench]
fn bench_alkahest(b: &mut Bencher) {
const BUFFER_LEN: usize = 10_000_000;
let mesh = generate_mesh();
let mut buffer = vec![0; BUFFER_LEN];
b.iter(move || {
alkahest::write::<MeshSchema, _>(black_box(&mut buffer), black_box(&mesh));
});
}
#[bench]
fn bench_savefile(b: &mut Bencher) {
let mesh = generate_mesh();
let mut encoded: Vec<u8> = Vec::with_capacity(10_000_000);
assert!(unsafe { Triangle::repr_c_optimization_safe(0).is_yes() } );
b.iter(move || {
/*let l = mesh.triangles.len();
let data_ptr = mesh.triangles.as_ptr() as *const u8;
let data_len = l * std::mem::size_of::<Triangle>();
encoded
serializer.write_buf(std::slice::from_raw_parts(
self.as_ptr() as *const u8,
std::mem::size_of::<T>() * l,
))*/
encoded.clear();
#[test]
fn test() {

savefile::save_noschema(black_box(&mut encoded), 0, black_box(&mesh)).unwrap();
})
}

/*
fn stuff<T>() -> T {
todo!()
}
*/
#[test]
fn dummy() {
}*/
2 changes: 1 addition & 1 deletion savefile-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ nightly=["savefile/nightly"]

[dependencies]
savefile = { path = "../savefile", features = ["size_sanity_checks", "encryption", "compression","bit-set","bit-vec","rustc-hash","serde_derive", "quickcheck"]}
savefile-derive = { path = "../savefile-derive", version = "=0.17.1" }
savefile-derive = { path = "../savefile-derive", version = "=0.17.2" }
savefile-abi = { path = "../savefile-abi" }
bit-vec = "0.6"
arrayvec="0.7"
Expand Down
1 change: 1 addition & 0 deletions savefile-test/src/ext_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ fn bench_ext_triangle(b: &mut Bencher) {
let mesh = generate_mesh();
let mut encoded: Vec<u8> = Vec::new();
b.iter(move || {
encoded.clear();
savefile::save_noschema(black_box(&mut encoded), 0, black_box(&mesh)).unwrap();
})
}
Expand Down
7 changes: 6 additions & 1 deletion savefile/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.17.2](https://github.com/avl/savefile/compare/savefile-v0.17.1...savefile-v0.17.2) - 2024-05-05

### Fixed
- Make comment clearer

## [0.17.1](https://github.com/avl/savefile/compare/savefile-v0.17.0...savefile-v0.17.1) - 2024-05-01

### Other
Expand Down Expand Up @@ -34,4 +39,4 @@ These CHANGELOG-files are experimental.
## [0.17.0-beta.12](https://github.com/avl/savefile/compare/savefile-v0.17.0-beta.11...savefile-v0.17.0-beta.12) - 2024-04-27

### Other
- Unspecified work
- Unspecified work
6 changes: 3 additions & 3 deletions savefile/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "savefile"
version = "0.17.1"
version = "0.17.2"
authors = ["Anders Musikka <[email protected]>"]
documentation = "https://docs.rs/savefile/"
homepage = "https://github.com/avl/savefile/"
Expand Down Expand Up @@ -54,13 +54,13 @@ bit-set = {version = "0.5", optional = true}
rustc-hash = {version = "1.1", optional = true}
memoffset = "0.9"
byteorder = "1.4"
savefile-derive = {path="../savefile-derive", version = "=0.17.1", optional = true }
savefile-derive = {path="../savefile-derive", version = "=0.17.2", optional = true }
serde_derive = {version= "1.0", optional = true}
serde = {version= "1.0", optional = true}
quickcheck = {version= "1.0", optional = true}

[dev-dependencies]
savefile-derive = { path="../savefile-derive", version = "=0.17.1" }
savefile-derive = { path="../savefile-derive", version = "=0.17.2" }

[build-dependencies]
rustc_version="0.2"
Expand Down
4 changes: 3 additions & 1 deletion savefile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1240,8 +1240,9 @@ pub trait Packed {
}
}

/// This just exists to make sure that no one can implement the ReprC-trait placeholder.
/// This just exists to make sure that no one can actually implement the ReprC-trait placeholder.
#[doc(hidden)]
#[deprecated(since="0.17", note="The 'ReprC' trait has been renamed to 'Packed'.")]
pub struct DeliberatelyUnimplementable{
#[allow(dead_code)]
private: ()
Expand All @@ -1253,6 +1254,7 @@ pub trait ReprC {
#[deprecated(since="0.17", note="The 'ReprC' trait has been renamed to 'Packed'.")]
#[doc(hidden)]
#[allow(non_snake_case)]
#[allow(deprecated)]
fn this_is_a_placeholder__if_you_see_this_it_is_likely_that_you_have_code_that_refers_to_ReprC_trait__this_trait_has_been_renamed_to__Packed() -> DeliberatelyUnimplementable;
unsafe fn repr_c_optimization_safe(_version: u32) -> IsPacked {
IsPacked::no()
Expand Down

0 comments on commit 734b46f

Please sign in to comment.