Skip to content

Commit

Permalink
Cleanup: use a macro for reprs, use syn errors & fix cfg-target-arch (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhenrymantilla committed Aug 12, 2022
1 parent bbd6a92 commit 1ebf7c2
Show file tree
Hide file tree
Showing 2 changed files with 228 additions and 268 deletions.
14 changes: 5 additions & 9 deletions derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ extern crate proc_macro;
mod traits;

use proc_macro2::TokenStream;
use quote::{quote, quote_spanned};
use syn::{parse_macro_input, DeriveInput, spanned::Spanned};
use quote::quote;
use syn::{parse_macro_input, DeriveInput, Result};

use crate::traits::{
AnyBitPattern, Contiguous, Derivable, CheckedBitPattern, NoUninit, Pod, TransparentWrapper, Zeroable,
Expand Down Expand Up @@ -223,17 +223,13 @@ pub fn derive_contiguous(

/// Basic wrapper for error handling
fn derive_marker_trait<Trait: Derivable>(input: DeriveInput) -> TokenStream {
let span = input.span();
derive_marker_trait_inner::<Trait>(input).unwrap_or_else(|err| {
quote_spanned! { span =>
compile_error!(#err);
}
})
derive_marker_trait_inner::<Trait>(input)
.unwrap_or_else(|err| err.into_compile_error())
}

fn derive_marker_trait_inner<Trait: Derivable>(
input: DeriveInput,
) -> Result<TokenStream, &'static str> {
) -> Result<TokenStream> {
let name = &input.ident;

let (impl_generics, ty_generics, where_clause) =
Expand Down

0 comments on commit 1ebf7c2

Please sign in to comment.