Skip to content

Commit

Permalink
Don't use boxes in checker function
Browse files Browse the repository at this point in the history
  • Loading branch information
someguynamedjosh committed Oct 16, 2021
1 parent e40ad80 commit 14ce9fd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ouroboros_macro/src/generate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pub mod constructor;
pub mod derives;
pub mod into_heads;
pub mod struc;
pub mod summon_borrowchk;
pub mod summon_checker;
pub mod try_constructor;
pub mod type_asserts;
pub mod with_all;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use syn::Error;

use crate::info_structures::{ArgType, StructInfo};

pub fn generate_borrowchk_summoner(info: &StructInfo) -> Result<TokenStream, Error> {
pub fn generate_checker_summoner(info: &StructInfo) -> Result<TokenStream, Error> {
let mut code: Vec<TokenStream> = Vec::new();
let mut params: Vec<TokenStream> = Vec::new();
let mut value_consumers: Vec<TokenStream> = Vec::new();
Expand Down Expand Up @@ -33,9 +33,8 @@ pub fn generate_borrowchk_summoner(info: &StructInfo) -> Result<TokenStream, Err
}
code.push(quote! { let #field_name = #builder_name (#(#builder_args),*); });
}
if field.is_borrowed() {
let boxed = field.boxed();
code.push(quote! { let mut #field_name = #boxed; });
if field.is_mutably_borrowed() {
code.push(quote! { let mut #field_name = #field_name; });
};
if !field.is_mutably_borrowed() {
value_consumers.push(quote! { #field_name: &#field_name });
Expand All @@ -47,7 +46,7 @@ pub fn generate_borrowchk_summoner(info: &StructInfo) -> Result<TokenStream, Err
let generic_params = info.generic_params();
let where_clause = &info.generics.where_clause;
Ok(quote! {
fn check_if_okay_according_to_borrow_checker<#generic_params>(
fn check_if_okay_according_to_checkers<#generic_params>(
#(#params,)*
)
#where_clause
Expand Down
4 changes: 2 additions & 2 deletions ouroboros_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
generate::{
constructor::create_builder_and_constructor, derives::create_derives,
into_heads::make_into_heads, struc::create_actual_struct_def,
summon_borrowchk::generate_borrowchk_summoner,
summon_checker::generate_checker_summoner,
try_constructor::create_try_builder_and_constructor, type_asserts::make_type_asserts,
with_all::make_with_all_function, with_each::make_with_functions,
},
Expand All @@ -37,7 +37,7 @@ fn self_referencing_impl(

let actual_struct_def = create_actual_struct_def(&info)?;

let borrowchk_summoner = generate_borrowchk_summoner(&info)?;
let borrowchk_summoner = generate_checker_summoner(&info)?;

let (builder_struct_name, builder_def, constructor_def) =
create_builder_and_constructor(&info, options, false)?;
Expand Down

0 comments on commit 14ce9fd

Please sign in to comment.