Skip to content

Commit

Permalink
Pass DeriveInput by reference
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 8, 2024
1 parent cdb1c11 commit 2f599f1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use syn::{
#[proc_macro_derive(RefCast, attributes(trivial))]
pub fn derive_ref_cast(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput);
expand_ref_cast(input)
expand_ref_cast(&input)
.unwrap_or_else(Error::into_compile_error)
.into()
}
Expand All @@ -72,7 +72,7 @@ pub fn derive_ref_cast(input: TokenStream) -> TokenStream {
#[proc_macro_derive(RefCastCustom, attributes(trivial))]
pub fn derive_ref_cast_custom(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput);
expand_ref_cast_custom(input)
expand_ref_cast_custom(&input)
.unwrap_or_else(Error::into_compile_error)
.into()
}
Expand Down Expand Up @@ -211,14 +211,14 @@ struct Function {
semi_token: Token![;],
}

fn expand_ref_cast(input: DeriveInput) -> Result<TokenStream2> {
check_repr(&input)?;
fn expand_ref_cast(input: &DeriveInput) -> Result<TokenStream2> {
check_repr(input)?;

let name = &input.ident;
let name_str = name.to_string();
let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();

let fields = fields(&input)?;
let fields = fields(input)?;
let from = only_field_ty(fields)?;
let trivial = trivial_fields(fields)?;

Expand Down Expand Up @@ -280,14 +280,14 @@ fn expand_ref_cast(input: DeriveInput) -> Result<TokenStream2> {
})
}

fn expand_ref_cast_custom(input: DeriveInput) -> Result<TokenStream2> {
check_repr(&input)?;
fn expand_ref_cast_custom(input: &DeriveInput) -> Result<TokenStream2> {
check_repr(input)?;

let vis = &input.vis;
let name = &input.ident;
let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();

let fields = fields(&input)?;
let fields = fields(input)?;
let from = only_field_ty(fields)?;
let trivial = trivial_fields(fields)?;

Expand Down

0 comments on commit 2f599f1

Please sign in to comment.