diff --git a/Cargo.lock b/Cargo.lock index 6d75d44..bbca116 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -448,7 +448,7 @@ dependencies = [ [[package]] name = "savefile" -version = "0.17.2" +version = "0.17.3" dependencies = [ "arrayvec", "bit-set", @@ -471,7 +471,7 @@ dependencies = [ [[package]] name = "savefile-abi" -version = "0.17.2" +version = "0.17.3" dependencies = [ "byteorder", "libloading", @@ -511,7 +511,7 @@ dependencies = [ [[package]] name = "savefile-derive" -version = "0.17.2" +version = "0.17.3" dependencies = [ "proc-macro-error", "proc-macro2", diff --git a/compile_tests/Cargo.lock b/compile_tests/Cargo.lock index e8bfd7b..921c47c 100644 --- a/compile_tests/Cargo.lock +++ b/compile_tests/Cargo.lock @@ -463,7 +463,7 @@ checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "savefile" -version = "0.17.1" +version = "0.17.2" dependencies = [ "arrayvec", "bit-set", @@ -479,7 +479,7 @@ dependencies = [ [[package]] name = "savefile-abi" -version = "0.17.1" +version = "0.17.2" dependencies = [ "byteorder", "libloading", @@ -489,7 +489,7 @@ dependencies = [ [[package]] name = "savefile-derive" -version = "0.17.1" +version = "0.17.2" dependencies = [ "proc-macro-error", "proc-macro2", diff --git a/compile_tests/tests/compile-fail/bad_export.rs b/compile_tests/tests/compile-fail/bad_export.rs index 0794278..ce62bde 100644 --- a/compile_tests/tests/compile-fail/bad_export.rs +++ b/compile_tests/tests/compile-fail/bad_export.rs @@ -14,6 +14,7 @@ use savefile_derive::savefile_abi_export; pub trait ExampleTrait { fn get(&mut self, x: u32) -> u32; } +#[derive(Default)] struct ExampleImpl { } @@ -24,6 +25,7 @@ impl ExampleTrait for ExampleImpl { } // Test what happens when you mix up the ordering of trait and impl: savefile_abi_export!(ExampleTrait, ExampleImpl); -//~^ 26:1: 26:48: expected trait, found struct `ExampleImpl` [E0404] +//~^ 27:22: 27:34: trait objects must include the `dyn` keyword [E0782] +//~^^ 27:36: 27:47: expected trait, found struct `ExampleImpl` [E0404] fn main() {} \ No newline at end of file diff --git a/compile_tests/tests/compile-fail/bad_export2.rs b/compile_tests/tests/compile-fail/bad_export2.rs index 7be080f..f478f3b 100644 --- a/compile_tests/tests/compile-fail/bad_export2.rs +++ b/compile_tests/tests/compile-fail/bad_export2.rs @@ -21,6 +21,6 @@ struct ExampleImpl { // Forgot to implement trait savefile_abi_export!(ExampleImpl, ExampleTrait); -//~^ 23:1: 23:48: the trait bound `ExampleImpl: ExampleTrait` is not satisfied [E0277] +//~^ 23:22: 23:47: the trait bound `ExampleImpl: ExampleTrait` is not satisfied [E0277] fn main() {} \ No newline at end of file diff --git a/compile_tests/tests/tests.rs b/compile_tests/tests/tests.rs index 0ba7059..ab92c37 100644 --- a/compile_tests/tests/tests.rs +++ b/compile_tests/tests/tests.rs @@ -1,6 +1,5 @@ extern crate compiletest_rs as compiletest; -use std::env; use std::path::PathBuf; fn run_mode(mode: &'static str, custom_dir: Option<&'static str>) { @@ -11,14 +10,9 @@ fn run_mode(mode: &'static str, custom_dir: Option<&'static str>) { let dir = custom_dir.unwrap_or(mode); config.src_base = PathBuf::from(format!("tests/{}", dir)); - config.target_rustcflags = Some("-L target/debug -L target/debug/deps".to_string()); - config.llvm_filecheck = Some( - env::var("FILECHECK") - .unwrap_or("FileCheck".to_string()) - .into(), - ); - //config.clean_rmeta(); - //config.clean_rlib(); + config.target_rustcflags = Some("-L target/debug -L target/debug/deps --edition 2021".to_string()); + config.llvm_filecheck = Some("FileCheck".to_string().into()); + config.strict_headers = true; compiletest::run_tests(&config); diff --git a/savefile-abi/CHANGELOG.md b/savefile-abi/CHANGELOG.md index f5b3c42..1c334ad 100644 --- a/savefile-abi/CHANGELOG.md +++ b/savefile-abi/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.17.3](https://github.com/avl/savefile/compare/savefile-abi-v0.17.2...savefile-abi-v0.17.3) - 2024-05-09 + +### Other +- format + ## [0.17.2](https://github.com/avl/savefile/compare/savefile-abi-v0.17.1...savefile-abi-v0.17.2) - 2024-05-05 ### Other diff --git a/savefile-abi/Cargo.toml b/savefile-abi/Cargo.toml index 1a8d7fc..d9d2ea6 100644 --- a/savefile-abi/Cargo.toml +++ b/savefile-abi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "savefile-abi" -version = "0.17.2" +version = "0.17.3" edition = "2021" authors = ["Anders Musikka "] documentation = "https://docs.rs/savefile-abi/" @@ -16,7 +16,7 @@ keywords = ["dylib", "dlopen", "ffi"] license = "MIT/Apache-2.0" [dependencies] -savefile = { path="../savefile", version = "=0.17.2" } -savefile-derive = { path="../savefile-derive", version = "=0.17.2" } +savefile = { path="../savefile", version = "=0.17.3" } +savefile-derive = { path="../savefile-derive", version = "=0.17.3" } byteorder = "1.4" libloading = "0.8" diff --git a/savefile-abi/src/lib.rs b/savefile-abi/src/lib.rs index 214bb9c..caca641 100644 --- a/savefile-abi/src/lib.rs +++ b/savefile-abi/src/lib.rs @@ -303,6 +303,7 @@ use savefile::{ diff_schema, load_file_noschema, load_noschema, save_file_noschema, AbiMethodInfo, AbiTraitDefinition, Deserialize, Deserializer, LittleEndian, SavefileError, Schema, Serializer, CURRENT_SAVEFILE_LIB_VERSION, }; +use std::any::TypeId; use std::collections::hash_map::Entry; use std::collections::HashMap; use std::hash::Hash; @@ -314,7 +315,6 @@ use std::path::Path; use std::ptr::null; use std::sync::{Mutex, MutexGuard}; use std::{ptr, slice}; -use std::any::TypeId; use byteorder::ReadBytesExt; use libloading::{Library, Symbol}; @@ -853,7 +853,7 @@ pub fn parse_return_value_impl( /// Parse an RawAbiCallResult instance into a `Result, SavefileError>` . /// This is used on the caller side, and the type T will always be statically known. /// TODO: There's some duplicated code here, compare parse_return_value -pub fn parse_return_boxed_trait(outcome: &RawAbiCallResult) -> Result>, SavefileError> +pub fn parse_return_boxed_trait(outcome: &RawAbiCallResult) -> Result>, SavefileError> where T: AbiExportable + ?Sized, { @@ -875,7 +875,7 @@ static ENTRY_CACHE: Mutex< > = Mutex::new(None); static ABI_CONNECTION_TEMPLATES: Mutex< - Option>, + Option>, > = Mutex::new(None); struct Guard<'a, K: Hash + Eq, V> { @@ -972,8 +972,10 @@ pub unsafe extern "C" fn abi_result_receiver( /// Raw entry point for receiving return values from other shared libraries #[doc(hidden)] -pub unsafe extern "C" fn abi_boxed_trait_receiver(outcome: *const RawAbiCallResult, result_receiver: *mut ()) -where +pub unsafe extern "C" fn abi_boxed_trait_receiver( + outcome: *const RawAbiCallResult, + result_receiver: *mut (), +) where T: AbiExportable + ?Sized, { let outcome = unsafe { &*outcome }; @@ -1402,7 +1404,7 @@ impl AbiConnection { // In principle, it would be enough to key 'templates' based on 'remote_entry'. // However, if we do, and the user ever uses AbiConnection with the _wrong_ entry point, // we risk poisoning the cache with erroneous data. - let template = match templates.entry((typeid,remote_entry)) { + let template = match templates.entry((typeid, remote_entry)) { Entry::Occupied(template) => template.get().clone(), Entry::Vacant(vacant) => { let own_version = T::get_latest_version(); diff --git a/savefile-derive/CHANGELOG.md b/savefile-derive/CHANGELOG.md index 73eee14..87a95f1 100644 --- a/savefile-derive/CHANGELOG.md +++ b/savefile-derive/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.17.3](https://github.com/avl/savefile/compare/savefile-derive-v0.17.2...savefile-derive-v0.17.3) - 2024-05-09 + +### Other +- Merge remote-tracking branch 'origin/master' into minor_v19 + ## [0.17.2](https://github.com/avl/savefile/compare/savefile-derive-v0.17.1...savefile-derive-v0.17.2) - 2024-05-05 ### Other diff --git a/savefile-derive/Cargo.toml b/savefile-derive/Cargo.toml index 44697d4..28a51cc 100644 --- a/savefile-derive/Cargo.toml +++ b/savefile-derive/Cargo.toml @@ -1,7 +1,8 @@ [package] name = "savefile-derive" -version = "0.17.2" +version = "0.17.3" authors = ["Anders Musikka "] +repository = "https://github.com/avl/savefile" description = "Custom derive macros for savefile crate - simple, convenient, fast, versioned, binary serialization/deserialization library." @@ -13,6 +14,8 @@ categories = ["encoding"] license = "MIT/Apache-2.0" +edition = "2021" + [features] default = [] nightly = [] diff --git a/savefile-derive/src/deserialize.rs b/savefile-derive/src/deserialize.rs index e6acc23..f2d78ee 100644 --- a/savefile-derive/src/deserialize.rs +++ b/savefile-derive/src/deserialize.rs @@ -1,5 +1,5 @@ -use common::{check_is_remove, get_extra_where_clauses, parse_attr_tag, FieldInfo, RemovedType}; -use get_enum_size; +use crate::common::{check_is_remove, get_extra_where_clauses, parse_attr_tag, FieldInfo, RemovedType}; +use crate::get_enum_size; use proc_macro2::{Literal, TokenStream}; use syn::spanned::Spanned; use syn::DeriveInput; diff --git a/savefile-derive/src/lib.rs b/savefile-derive/src/lib.rs index af4c0ab..022bbf6 100644 --- a/savefile-derive/src/lib.rs +++ b/savefile-derive/src/lib.rs @@ -26,7 +26,7 @@ use common::{ check_is_remove, compile_time_check_reprc, compile_time_size, get_extra_where_clauses, parse_attr_tag, path_to_string, FieldInfo, }; -use proc_macro2::Span; +use proc_macro2::{Span, TokenTree}; use proc_macro2::TokenStream; use quote::ToTokens; use std::collections::{HashMap, HashSet}; @@ -34,12 +34,9 @@ use std::collections::{HashMap, HashSet}; use std::iter::IntoIterator; use syn::__private::bool; use syn::spanned::Spanned; -use syn::token::Paren; +use syn::token::{Paren}; use syn::Type::Tuple; -use syn::{ - DeriveInput, FnArg, GenericParam, Generics, Ident, ImplGenerics, Index, ItemTrait, Pat, ReturnType, TraitItem, - Type, TypeGenerics, TypeParamBound, TypeTuple, -}; +use syn::{DeriveInput, FnArg, GenericParam, Generics, Ident, ImplGenerics, Index, ItemTrait, Pat, ReturnType, TraitItem, Type, TypeGenerics, TypeParamBound, TypeTuple}; fn implement_fields_serialize( field_infos: Vec, implicit_self: bool, @@ -564,21 +561,41 @@ pub fn savefile_abi_exportable( } #[proc_macro_error] #[proc_macro] -pub fn savefile_abi_export(item: proc_macro::TokenStream) -> proc_macro::TokenStream { - let input = item.to_string(); - let symbols: Vec<_> = input.split(',').map(|x| x.trim()).collect(); - if symbols.len() != 2 { - abort!(input.span(), "savefile_abi_export requires two parameters. The first parameter is the implementing type, the second is the trait it implements."); + pub fn savefile_abi_export(item: proc_macro::TokenStream) -> proc_macro::TokenStream { + let tokens = proc_macro2::TokenStream::from(item); + + let mut tokens_iter = tokens.into_iter(); + + let Some(implementing_type) = tokens_iter.next() else { + abort!(Span::call_site(), "The macro savefile_abi_export! requires two parameters. The first parameter must be the implementing type, the second is the trait it implements."); + }; + let Some(comma) = tokens_iter.next() else { + abort!(Span::call_site(), "The macro savefile_abi_export! requires two parameters. The first parameter must be the implementing type, the second is the trait it implements."); + }; + if let TokenTree::Punct(p) = comma { + if p.as_char() != ',' { + abort!(p.span(), "Expected a comma (','). The macro savefile_abi_export! requires two parameters. The first parameter must be the implementing type, the second is the trait it implements, and these must be separated by a comma."); + } + } else { + abort!(comma.span(), "Expected a comma (','). The macro savefile_abi_export! requires two parameters. The first parameter must be the implementing type, the second is the trait it implements, and these must be separated by a comma."); + + } + let Some(trait_type) = tokens_iter.next() else { + abort!(Span::call_site(), "The macro savefile_abi_export! requires two parameters. The first parameter must be the implementing type, the second is the trait it implements. Expected trait name."); + }; + + if let Some(extra) = tokens_iter.next() { + abort!(extra.span(), "Unexpected token. The macro savefile_abi_export! requires exactly two parameters. The first parameter must be the implementing type, the second is the trait it implements."); } + + let defspan = Span::call_site(); let uses = quote_spanned! { defspan => extern crate savefile_abi; use savefile_abi::{AbiProtocol, AbiExportableImplementation, abi_entry,parse_return_value_impl}; }; - let implementing_type = Ident::new(symbols[0], Span::call_site()); - let trait_type = Ident::new(symbols[1], Span::call_site()); - let abi_entry = Ident::new(("abi_entry_".to_string() + symbols[1]).as_str(), Span::call_site()); + let abi_entry = Ident::new(("abi_entry_".to_string() + &trait_type.to_string()).as_str(), Span::call_site()); let expanded = quote! { #[allow(clippy::double_comparisons)] diff --git a/savefile-derive/src/savefile_abi.rs b/savefile-derive/src/savefile_abi.rs index 95cc4b1..a4618ab 100644 --- a/savefile-derive/src/savefile_abi.rs +++ b/savefile-derive/src/savefile_abi.rs @@ -1,4 +1,4 @@ -use common::{compile_time_check_reprc, compile_time_size}; +use crate::common::{compile_time_check_reprc, compile_time_size}; use proc_macro2::{Ident, Literal, Span, TokenStream}; use quote::ToTokens; use std::collections::HashMap; diff --git a/savefile-derive/src/serialize.rs b/savefile-derive/src/serialize.rs index 0071025..701976e 100644 --- a/savefile-derive/src/serialize.rs +++ b/savefile-derive/src/serialize.rs @@ -1,9 +1,9 @@ use proc_macro2::{Span, TokenStream}; use syn::DeriveInput; -use common::{get_extra_where_clauses, parse_attr_tag, FieldInfo}; -use get_enum_size; -use implement_fields_serialize; +use crate::common::{get_extra_where_clauses, parse_attr_tag, FieldInfo}; +use crate::get_enum_size; +use crate::implement_fields_serialize; use syn::spanned::Spanned; pub(super) fn savefile_derive_crate_serialize(input: DeriveInput) -> TokenStream { diff --git a/savefile-min-build/src/lib.rs b/savefile-min-build/src/lib.rs index 8b71a03..2b4ca7c 100644 --- a/savefile-min-build/src/lib.rs +++ b/savefile-min-build/src/lib.rs @@ -1,14 +1,9 @@ - use savefile_derive::Savefile; - #[derive(Debug, Savefile, PartialEq)] pub enum TestStructEnum { Variant2 { a: u8, b: u8 }, } #[test] -fn test() { - -} - +fn test() {} diff --git a/savefile-test/Cargo.toml b/savefile-test/Cargo.toml index bf64b8a..a8127a9 100644 --- a/savefile-test/Cargo.toml +++ b/savefile-test/Cargo.toml @@ -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.2" } +savefile-derive = { path = "../savefile-derive", version = "=0.17.3" } savefile-abi = { path = "../savefile-abi" } bit-vec = "0.6" arrayvec="0.7" diff --git a/savefile-test/src/enum_variant_versioning.rs b/savefile-test/src/enum_variant_versioning.rs index 3b1a87e..bdb50fd 100644 --- a/savefile-test/src/enum_variant_versioning.rs +++ b/savefile-test/src/enum_variant_versioning.rs @@ -1,5 +1,5 @@ use assert_roundtrip_version; -use savefile::{Removed, Packed}; +use savefile::{Packed, Removed}; use {assert_roundtrip, assert_roundtrip_to_new_version}; #[repr(u8)] diff --git a/savefile-test/src/ext_benchmark.rs b/savefile-test/src/ext_benchmark.rs index c1a4c1b..35d6eda 100644 --- a/savefile-test/src/ext_benchmark.rs +++ b/savefile-test/src/ext_benchmark.rs @@ -1,7 +1,7 @@ +use rand::Rng; use std::hint::black_box; #[cfg(feature = "nightly")] use test::Bencher; -use rand::Rng; mod savefile_test_bad_schema { use savefile::prelude::*; @@ -175,13 +175,13 @@ mod savefile_benchmark_no_reprc { } } -#[derive(Savefile,PartialEq,Default)] +#[derive(Savefile, PartialEq, Default)] pub struct Vector3 { pub x: f32, pub y: f32, pub z: f32, } -#[derive(Savefile,PartialEq,Default)] +#[derive(Savefile, PartialEq, Default)] pub struct Triangle { pub v0: Vector3, pub v1: Vector3, @@ -189,16 +189,13 @@ pub struct Triangle { pub normal: Vector3, } -#[derive(Savefile,PartialEq)] +#[derive(Savefile, PartialEq)] pub struct Mesh { pub triangles: Vec, } #[cfg(test)] pub fn generate_mesh() -> Mesh { - - let mut mesh = Mesh { - triangles: vec![] - }; + let mut mesh = Mesh { triangles: vec![] }; const TRIANGLES: usize = 125_000; for _ in 0..TRIANGLES { mesh.triangles.push(Triangle::default()) @@ -219,10 +216,10 @@ fn bench_ext_triangle(b: &mut Bencher) { #[test] fn test_triangle() { use savefile::Packed; - assert!( unsafe { Triangle::repr_c_optimization_safe(0).is_yes() } ); + assert!(unsafe { Triangle::repr_c_optimization_safe(0).is_yes() }); let mesh = generate_mesh(); let mut encoded = Vec::new(); encoded.clear(); savefile::save_noschema(black_box(&mut encoded), 0, black_box(&mesh)).unwrap(); -} \ No newline at end of file +} diff --git a/savefile-test/src/lib.rs b/savefile-test/src/lib.rs index bec40a0..368ebd7 100644 --- a/savefile-test/src/lib.rs +++ b/savefile-test/src/lib.rs @@ -1357,9 +1357,11 @@ pub fn test_verify_cow_deserialize_not_borrowed() { } f.set_position(0); { - let roundtripped:Cow = Deserializer::load(&mut f, 0).unwrap(); + let roundtripped: Cow = Deserializer::load(&mut f, 0).unwrap(); match roundtripped { - Cow::Borrowed(_) => {panic!("Roundtripped Cow should not be borrowed!")} + Cow::Borrowed(_) => { + panic!("Roundtripped Cow should not be borrowed!") + } Cow::Owned(_) => {} } } diff --git a/savefile-test/src/savefile_abi_test/argument_backward_compatibility.rs b/savefile-test/src/savefile_abi_test/argument_backward_compatibility.rs index 02c741c..b104091 100644 --- a/savefile-test/src/savefile_abi_test/argument_backward_compatibility.rs +++ b/savefile-test/src/savefile_abi_test/argument_backward_compatibility.rs @@ -39,8 +39,7 @@ mod v1 { EnumArgument::Variant2 => "Variant2".into(), } } - fn function_existing_in_v1(&self) { - } + fn function_existing_in_v1(&self) {} } } @@ -85,8 +84,7 @@ mod v2 { a.data3 + a.data2 + b.data2 + b.data3 } - fn function_existing_in_v2(&self) { - } + fn function_existing_in_v2(&self) {} } } @@ -200,7 +198,7 @@ pub fn test_caller_has_newer_version_calling_non_existing_function() { iface1, ) } - .unwrap(); + .unwrap(); conn1.function_existing_in_v2(); } @@ -214,18 +212,18 @@ pub fn test_caller_has_older_version_calling_non_existing_function() { iface2, ) } - .unwrap(); + .unwrap(); conn.function_existing_in_v1(); } #[test] fn test_calling_function_that_is_later_removed() { - let boxed: Box = Box::new(Implementation1{}); + let boxed: Box = Box::new(Implementation1 {}); let conn = AbiConnection::from_boxed_trait(boxed).unwrap(); conn.function_existing_in_v1(); } #[test] fn test_calling_function_that_is_added_in_later_version() { - let boxed: Box = Box::new(Implementation2{}); + let boxed: Box = Box::new(Implementation2 {}); let conn = AbiConnection::from_boxed_trait(boxed).unwrap(); conn.function_existing_in_v2(); } diff --git a/savefile-test/src/savefile_abi_test/basic_abi_tests.rs b/savefile-test/src/savefile_abi_test/basic_abi_tests.rs index 5b30573..423b07c 100644 --- a/savefile-test/src/savefile_abi_test/basic_abi_tests.rs +++ b/savefile-test/src/savefile_abi_test/basic_abi_tests.rs @@ -292,7 +292,6 @@ fn test_cow_smuggler() { assert_eq!(conn.smuggle2("hej".into()), "hej"); assert_eq!(conn.smuggle2("hej".to_string().into()), "hej"); - let static_ret : Cow<'static, str> = conn.smuggle2("hej".into()); + let static_ret: Cow<'static, str> = conn.smuggle2("hej".into()); assert_eq!(static_ret, "hej"); - -} \ No newline at end of file +} diff --git a/savefile/CHANGELOG.md b/savefile/CHANGELOG.md index 4fda70d..38d46ce 100644 --- a/savefile/CHANGELOG.md +++ b/savefile/CHANGELOG.md @@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.17.3](https://github.com/avl/savefile/compare/savefile-v0.17.2...savefile-v0.17.3) - 2024-05-09 + +### Fixed +- Silence warning on newer rustc, since TryFrom and TryInto are now part of prelude. Use still needed to keep working on old rustc. + +### Other +- Merge remote-tracking branch 'origin/master' into minor_v19 + ## [0.17.2](https://github.com/avl/savefile/compare/savefile-v0.17.1...savefile-v0.17.2) - 2024-05-05 ### Fixed diff --git a/savefile/Cargo.toml b/savefile/Cargo.toml index 723317c..e9b2d17 100644 --- a/savefile/Cargo.toml +++ b/savefile/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "savefile" -version = "0.17.2" +version = "0.17.3" authors = ["Anders Musikka "] documentation = "https://docs.rs/savefile/" homepage = "https://github.com/avl/savefile/" @@ -20,7 +20,7 @@ categories = ["encoding"] license = "MIT/Apache-2.0" -edition = "2018" +edition = "2021" [features] default = ["indexmap", "arrayvec", "smallvec", "bit-vec", "parking_lot","bit-set"] @@ -31,8 +31,7 @@ serde_derive = ["dep:serde_derive","serde"] # This is mostly to be able to run fuzzers against the deserializers without them being guaranteed to easily find out-of-memory crashes. size_sanity_checks = [] # Use features only available on the nightly rust-compiler. -# Enabling this means serialization of vectors of simple types will be much faster. -# It also enables serialization of arbitrary size arrays (arbitrary size Vec always work, regardless of features) +# Enabling this provides slightly better introspection support. nightly=[] compression = ["bzip2"] @@ -54,13 +53,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.2", optional = true } +savefile-derive = {path="../savefile-derive", version = "=0.17.3", 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.2" } +savefile-derive = { path="../savefile-derive", version = "=0.17.3" } [build-dependencies] rustc_version="0.2" diff --git a/savefile/src/lib.rs b/savefile/src/lib.rs index 30999b5..b441971 100644 --- a/savefile/src/lib.rs +++ b/savefile/src/lib.rs @@ -1,7 +1,6 @@ #![allow(incomplete_features)] #![recursion_limit = "256"] #![cfg_attr(feature = "nightly", feature(specialization))] -#![cfg_attr(feature = "nightly", feature(trait_alias))] #![deny(missing_docs)] #![deny(warnings)] #![allow(clippy::box_default)] @@ -1158,7 +1157,7 @@ impl<'a, TR: Read> Deserializer<'a, TR> { pub struct IsPacked(bool); #[doc(hidden)] -#[deprecated(since="0.17", note="The 'IsReprC' type has been renamed to 'IsPacked'.")] +#[deprecated(since = "0.17", note = "The 'IsReprC' type has been renamed to 'IsPacked'.")] pub type IsReprC = IsPacked; impl std::ops::BitAnd for IsPacked { @@ -1242,20 +1241,21 @@ pub trait Packed { /// 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{ +#[deprecated(since = "0.17", note = "The 'ReprC' trait has been renamed to 'Packed'.")] +pub struct DeliberatelyUnimplementable { #[allow(dead_code)] - private: () + private: (), } -#[deprecated(since="0.17", note="The 'ReprC' trait has been renamed to 'Packed'.")] +#[deprecated(since = "0.17", note = "The 'ReprC' trait has been renamed to 'Packed'.")] #[doc(hidden)] pub trait ReprC { - #[deprecated(since="0.17", note="The 'ReprC' trait has been renamed to 'Packed'.")] + #[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; + 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() } @@ -2401,7 +2401,6 @@ impl<'a> IntrospectItem<'a> for str { } } - impl<'a> IntrospectItem<'a> for String { fn key(&self) -> &str { self @@ -3701,8 +3700,16 @@ impl Deserialize for SchemaStruct { let l = deserializer.read_usize()?; Ok(SchemaStruct { dbg_name, - size: if deserializer.file_version > 0 {<_ as Deserialize>::deserialize(deserializer)?} else {None}, - alignment: if deserializer.file_version > 0 {<_ as Deserialize>::deserialize(deserializer)?} else {None}, + size: if deserializer.file_version > 0 { + <_ as Deserialize>::deserialize(deserializer)? + } else { + None + }, + alignment: if deserializer.file_version > 0 { + <_ as Deserialize>::deserialize(deserializer)? + } else { + None + }, fields: { let mut ret = Vec::new(); for _ in 0..l { @@ -4160,7 +4167,6 @@ impl Packed for String {} impl Packed for str {} - impl Deserialize for String { fn deserialize(deserializer: &mut Deserializer) -> Result { deserializer.read_string() diff --git a/savefile/src/prelude.rs b/savefile/src/prelude.rs index fbba9ba..49443e1 100644 --- a/savefile/src/prelude.rs +++ b/savefile/src/prelude.rs @@ -4,7 +4,7 @@ pub use { super::save_file_noschema, super::save_noschema, super::save_to_mem, super::AbiRemoved, super::Canary1, super::Deserialize, super::Deserializer, super::Field, super::Introspect, super::IntrospectItem, super::IntrospectedElementKey, super::IntrospectionResult, super::Introspector, super::IntrospectorNavCommand, - super::IsPacked, super::Removed, super::Packed, super::SavefileError, super::Schema, super::SchemaEnum, + super::IsPacked, super::Packed, super::Removed, super::SavefileError, super::Schema, super::SchemaEnum, super::SchemaPrimitive, super::SchemaStruct, super::Serialize, super::Serializer, super::Variant, super::WithSchema, super::WithSchemaContext, };