Skip to content

Commit

Permalink
Release 0.6.2
Browse files Browse the repository at this point in the history
Fixes the context generic being placed after const parameters and
renames the lifetime parameter to `check_bytes` to avoid name
conflicts
  • Loading branch information
djkoloski committed Jul 14, 2021
1 parent 120a9c1 commit 248669c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions bytecheck/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bytecheck"
version = "0.6.1"
version = "0.6.2"
authors = ["David Koloski <djkoloski@gmail.com>"]
edition = "2018"
description = "Derive macro for bytecheck"
Expand All @@ -14,7 +14,7 @@ readme = "crates-io.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bytecheck_derive = { version = "=0.6.1", path = "../bytecheck_derive", default-features = false }
bytecheck_derive = { version = "=0.6.2", path = "../bytecheck_derive", default-features = false }
ptr_meta = "0.1"
simdutf8 = { version = "0.1", default-features = false }

Expand Down
2 changes: 1 addition & 1 deletion bytecheck_derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bytecheck_derive"
version = "0.6.1"
version = "0.6.2"
authors = ["David Koloski <djkoloski@gmail.com>"]
edition = "2018"
description = "Derive macro for bytecheck"
Expand Down
10 changes: 5 additions & 5 deletions bytecheck_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn derive_check_bytes(mut input: DeriveInput) -> Result<TokenStream, Error> {
}
impl_input_generics
.params
.push(parse_quote! { __C: ?Sized });
.insert(0, parse_quote! { __C: ?Sized });

This comment has been minimized.

Copy link
@PonasKovas

PonasKovas Jul 14, 2021

won't this insert this type parameter before the lifetime parameters if there are any?

This comment has been minimized.

Copy link
@djkoloski

djkoloski Jul 14, 2021

Author Collaborator

Yes, but syn explicitly tokenizes lifetime parameters before other parameters (see here and here). The problem is that it doesn't tokenize type parameters before const parameters because the ordering rules is not yet final.


let name = &input.ident;

Expand Down Expand Up @@ -178,7 +178,7 @@ fn derive_check_bytes(mut input: DeriveInput) -> Result<TokenStream, Error> {
impl #impl_generics CheckBytes<__C> for #name #ty_generics #check_where {
type Error = StructCheckError;

unsafe fn check_bytes<'a>(value: *const Self, context: &mut __C) -> Result<&'a Self, Self::Error> {
unsafe fn check_bytes<'__bytecheck>(value: *const Self, context: &mut __C) -> Result<&'__bytecheck Self, Self::Error> {
let bytes = value.cast::<u8>();
#(#field_checks)*
Ok(&*value)
Expand Down Expand Up @@ -217,7 +217,7 @@ fn derive_check_bytes(mut input: DeriveInput) -> Result<TokenStream, Error> {
impl #impl_generics CheckBytes<__C> for #name #ty_generics #check_where {
type Error = TupleStructCheckError;

unsafe fn check_bytes<'a>(value: *const Self, context: &mut __C) -> Result<&'a Self, Self::Error> {
unsafe fn check_bytes<'__bytecheck>(value: *const Self, context: &mut __C) -> Result<&'__bytecheck Self, Self::Error> {
let bytes = value.cast::<u8>();
#(#field_checks)*
Ok(&*value)
Expand All @@ -230,7 +230,7 @@ fn derive_check_bytes(mut input: DeriveInput) -> Result<TokenStream, Error> {
impl #impl_generics CheckBytes<__C> for #name #ty_generics #impl_where_clause {
type Error = Infallible;

unsafe fn check_bytes<'a>(value: *const Self, context: &mut __C) -> Result<&'a Self, Self::Error> {
unsafe fn check_bytes<'__bytecheck>(value: *const Self, context: &mut __C) -> Result<&'__bytecheck Self, Self::Error> {
Ok(&*value)
}
}
Expand Down Expand Up @@ -420,7 +420,7 @@ fn derive_check_bytes(mut input: DeriveInput) -> Result<TokenStream, Error> {
impl #impl_generics CheckBytes<__C> for #name #ty_generics #check_where {
type Error = EnumCheckError<#repr>;

unsafe fn check_bytes<'a>(value: *const Self, context: &mut __C) -> Result<&'a Self, Self::Error> {
unsafe fn check_bytes<'__bytecheck>(value: *const Self, context: &mut __C) -> Result<&'__bytecheck Self, Self::Error> {
let tag = *value.cast::<#repr>();
match tag {
#(#tag_variant_values => #check_arms)*
Expand Down

0 comments on commit 248669c

Please sign in to comment.