Skip to content

Commit

Permalink
Use fully qualified path in Box derive code
Browse files Browse the repository at this point in the history
  • Loading branch information
althonos committed Mar 3, 2024
1 parent 068c767 commit 4674e0f
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions src/derive/box.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
use syn::{parse_quote, spanned::Spanned};

use crate::{
items::derive_impl,
utils::{
deref_expr, generics_declaration_to_generics, signature_to_associated_function_call,
signature_to_method_call, trait_to_generic_ident,
},
};
use crate::items::derive_impl;

use super::WrapperType;

pub struct BoxType;

impl WrapperType for BoxType {
fn wrap(ty: &syn::Ident) -> syn::Type {
parse_quote!(Box<#ty>)
parse_quote!(std::boxed::Box<#ty>)
}
}

Expand Down Expand Up @@ -53,7 +47,7 @@ mod tests {
derived,
parse_quote!(
#[automatically_derived]
impl<MT: MyTrait + ?Sized> MyTrait for Box<MT> {}
impl<MT: MyTrait + ?Sized> MyTrait for std::boxed::Box<MT> {}
)
);
}
Expand All @@ -69,7 +63,7 @@ mod tests {
super::super::derive(&trait_).unwrap(),
parse_quote!(
#[automatically_derived]
impl<MT: MyTrait + ?Sized> MyTrait for Box<MT> {
impl<MT: MyTrait + ?Sized> MyTrait for std::boxed::Box<MT> {
#[inline]
fn my_method(&self) {
(*(*self)).my_method()
Expand All @@ -90,7 +84,7 @@ mod tests {
super::super::derive(&trait_).unwrap(),
parse_quote!(
#[automatically_derived]
impl<MT: MyTrait + ?Sized> MyTrait for Box<MT> {
impl<MT: MyTrait + ?Sized> MyTrait for std::boxed::Box<MT> {
#[inline]
fn my_method(&mut self) {
(*(*self)).my_method()
Expand All @@ -111,7 +105,7 @@ mod tests {
super::super::derive(&trait_).unwrap(),
parse_quote!(
#[automatically_derived]
impl<MT: MyTrait> MyTrait for Box<MT> {
impl<MT: MyTrait> MyTrait for std::boxed::Box<MT> {
#[inline]
fn my_method(self) {
(*self).my_method()
Expand All @@ -125,7 +119,7 @@ mod tests {
fn receiver_arbitrary() {
let trait_ = parse_quote!(
trait MyTrait {
fn my_method(self: Box<Self>);
fn my_method(self: std::boxed::Box<Self>);
}
);
assert!(super::super::derive(&trait_).is_err());
Expand All @@ -142,7 +136,7 @@ mod tests {
derived,
parse_quote!(
#[automatically_derived]
impl<T, MT: MyTrait<T> + ?Sized> MyTrait<T> for Box<MT> {}
impl<T, MT: MyTrait<T> + ?Sized> MyTrait<T> for std::boxed::Box<MT> {}
)
);
}
Expand All @@ -158,7 +152,7 @@ mod tests {
derived,
parse_quote!(
#[automatically_derived]
impl<T: 'static + Send, MT: MyTrait<T> + ?Sized> MyTrait<T> for Box<MT> {}
impl<T: 'static + Send, MT: MyTrait<T> + ?Sized> MyTrait<T> for std::boxed::Box<MT> {}
)
);
}
Expand All @@ -175,7 +169,7 @@ mod tests {
parse_quote!(
#[automatically_derived]
impl<'a, 'b: 'a, T: 'static + Send, MT: MyTrait<'a, 'b, T> + ?Sized>
MyTrait<'a, 'b, T> for Box<MT>
MyTrait<'a, 'b, T> for std::boxed::Box<MT>
{
}
)
Expand All @@ -195,7 +189,7 @@ mod tests {
derived,
parse_quote!(
#[automatically_derived]
impl<MT: MyTrait + ?Sized> MyTrait for Box<MT> {
impl<MT: MyTrait + ?Sized> MyTrait for std::boxed::Box<MT> {
type Return = <MT as MyTrait>::Return;
}
)
Expand All @@ -215,7 +209,7 @@ mod tests {
derived,
parse_quote!(
#[automatically_derived]
impl<MT: MyTrait + ?Sized> MyTrait for Box<MT> {
impl<MT: MyTrait + ?Sized> MyTrait for std::boxed::Box<MT> {
type Return = <MT as MyTrait>::Return;
}
)
Expand All @@ -235,7 +229,7 @@ mod tests {
derived,
parse_quote!(
#[automatically_derived]
impl<MT: MyTrait + ?Sized> MyTrait for Box<MT> {
impl<MT: MyTrait + ?Sized> MyTrait for std::boxed::Box<MT> {
type r#type = <MT as MyTrait>::r#type;
}
)
Expand All @@ -258,7 +252,7 @@ mod tests {
derived,
parse_quote!(
#[automatically_derived]
impl<MT: MyTrait + ?Sized> MyTrait for Box<MT> {
impl<MT: MyTrait + ?Sized> MyTrait for std::boxed::Box<MT> {
#[cfg(target_arch = "wasm32")]
type Return = <MT as MyTrait>::Return;
#[cfg(not(target_arch = "wasm32"))]
Expand All @@ -281,7 +275,7 @@ mod tests {
derived,
parse_quote!(
#[automatically_derived]
impl<T, MT: MyTrait<T> + ?Sized> MyTrait<T> for Box<MT> {
impl<T, MT: MyTrait<T> + ?Sized> MyTrait<T> for std::boxed::Box<MT> {
type Return = <MT as MyTrait<T>>::Return;
}
)
Expand All @@ -301,7 +295,7 @@ mod tests {
derived,
parse_quote!(
#[automatically_derived]
impl<MT: MyTrait + ?Sized> MyTrait for Box<MT> {
impl<MT: MyTrait + ?Sized> MyTrait for std::boxed::Box<MT> {
type Return<T> = <MT as MyTrait>::Return<T>;
}
)
Expand All @@ -321,7 +315,7 @@ mod tests {
derived,
parse_quote!(
#[automatically_derived]
impl<MT: MyTrait + ?Sized> MyTrait for Box<MT> {
impl<MT: MyTrait + ?Sized> MyTrait for std::boxed::Box<MT> {
type Return<T: 'static + Send> = <MT as MyTrait>::Return<T>;
}
)
Expand All @@ -343,7 +337,7 @@ mod tests {
derived,
parse_quote!(
#[automatically_derived]
impl<MT: MyTrait + ?Sized> MyTrait for Box<MT> {
impl<MT: MyTrait + ?Sized> MyTrait for std::boxed::Box<MT> {
type Return<'a> = <MT as MyTrait>::Return<'a>
where
Self: 'a;
Expand Down

0 comments on commit 4674e0f

Please sign in to comment.