Skip to content

Commit 7b10f6f

Browse files
committed
Re-export traits
This is blocked until [trait aliases are allowed][1]. Because right new we'd also export any derives from std with the same name. This showed up with the Debug derive. But if rust starts implementing more derives for their built in types in std, then the same issue would occur for other traits. [1]: rust-lang/rust#41517
1 parent fdf7fe1 commit 7b10f6f

22 files changed

+104
-55
lines changed

impl/src/add_like.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn expand(input: &DeriveInput, trait_name: &str) -> TokenStream {
4242

4343
quote! {
4444
#[automatically_derived]
45-
impl #impl_generics ::core::ops::#trait_ident for #input_type #ty_generics #where_clause {
45+
impl #impl_generics ::derive_more::#trait_ident for #input_type #ty_generics #where_clause {
4646
type Output = #output_type;
4747

4848
#[inline]

impl/src/as_mut.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pub fn expand(input: &DeriveInput, trait_name: &'static str) -> Result<TokenStre
1010
let state = State::with_type_bound(
1111
input,
1212
trait_name,
13-
quote! { ::core::convert },
1413
"as_mut".into(),
1514
AttrParams::ignore_and_forward(),
1615
false,

impl/src/as_ref.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pub fn expand(input: &DeriveInput, trait_name: &'static str) -> Result<TokenStre
1010
let state = State::with_type_bound(
1111
input,
1212
trait_name,
13-
quote! { ::core::convert },
1413
"as_ref".into(),
1514
AttrParams::ignore_and_forward(),
1615
false,

impl/src/deref.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ pub fn expand(input: &DeriveInput, trait_name: &'static str) -> Result<TokenStre
88
let state = State::with_field_ignore_and_forward(
99
input,
1010
trait_name,
11-
quote! { ::core::ops },
1211
trait_name.to_lowercase(),
1312
)?;
1413
let SingleFieldData {

impl/src/deref_mut.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ pub fn expand(input: &DeriveInput, trait_name: &'static str) -> Result<TokenStre
88
let state = State::with_field_ignore_and_forward(
99
input,
1010
trait_name,
11-
quote! { ::core::ops },
1211
"deref_mut".into(),
1312
)?;
1413
let SingleFieldData {

impl/src/error.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ pub fn expand(
1818
let state = State::with_attr_params(
1919
input,
2020
trait_name,
21-
quote! { ::derive_more::__private::Error },
2221
trait_name.to_lowercase(),
2322
allowed_attr_params(),
2423
)?;
@@ -39,7 +38,7 @@ pub fn expand(
3938

4039
let source = source.map(|source| {
4140
quote! {
42-
fn source(&self) -> Option<&(dyn ::derive_more::__private::Error + 'static)> {
41+
fn source(&self) -> Option<&(dyn ::derive_more::Error + 'static)> {
4342
use ::derive_more::__private::AsDynError;
4443
#source
4544
}
@@ -73,7 +72,7 @@ pub fn expand(
7372
&generics,
7473
quote! {
7574
where
76-
#(#bounds: ::core::fmt::Debug + ::core::fmt::Display + ::derive_more::__private::Error + 'static),*
75+
#(#bounds: ::core::fmt::Debug + ::core::fmt::Display + ::derive_more::Error + 'static),*
7776
},
7877
);
7978
}
@@ -82,7 +81,7 @@ pub fn expand(
8281

8382
let render = quote! {
8483
#[automatically_derived]
85-
impl #impl_generics ::derive_more::__private::Error for #ident #ty_generics #where_clause {
84+
impl #impl_generics ::derive_more::Error for #ident #ty_generics #where_clause {
8685
#source
8786
#provide
8887
}
@@ -120,7 +119,6 @@ fn render_enum(
120119
let state = State::from_variant(
121120
state.input,
122121
state.trait_name,
123-
state.trait_module.clone(),
124122
state.trait_attr.clone(),
125123
allowed_attr_params(),
126124
variant,
@@ -207,7 +205,7 @@ impl<'input, 'state> ParsedFields<'input, 'state> {
207205
let source_provider = self.source.map(|source| {
208206
let source_expr = &self.data.members[source];
209207
quote! {
210-
::derive_more::__private::Error::provide(&#source_expr, demand);
208+
::derive_more::Error::provide(&#source_expr, demand);
211209
}
212210
});
213211
let backtrace_provider = self
@@ -237,7 +235,7 @@ impl<'input, 'state> ParsedFields<'input, 'state> {
237235
let pattern = self.data.matcher(&[source], &[quote! { source }]);
238236
Some(quote! {
239237
#pattern => {
240-
::derive_more::__private::Error::provide(source, demand);
238+
::derive_more::Error::provide(source, demand);
241239
}
242240
})
243241
}
@@ -249,7 +247,7 @@ impl<'input, 'state> ParsedFields<'input, 'state> {
249247
Some(quote! {
250248
#pattern => {
251249
demand.provide_ref::<::std::backtrace::Backtrace>(backtrace);
252-
::derive_more::__private::Error::provide(source, demand);
250+
::derive_more::Error::provide(source, demand);
253251
}
254252
})
255253
}

impl/src/from_str.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ pub fn expand(input: &DeriveInput, trait_name: &'static str) -> Result<TokenStre
99
let state = State::new(
1010
input,
1111
trait_name,
12-
quote! { ::core::str },
1312
trait_name.to_lowercase(),
1413
)?;
1514

impl/src/index.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ pub fn expand(input: &DeriveInput, trait_name: &'static str) -> Result<TokenStre
99
let mut state = State::with_field_ignore(
1010
input,
1111
trait_name,
12-
quote! { ::core::ops },
1312
trait_name.to_lowercase(),
1413
)?;
1514
state.add_trait_path_type_param(quote! { #index_type });

impl/src/index_mut.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ pub fn expand(input: &DeriveInput, trait_name: &'static str) -> Result<TokenStre
99
let mut state = State::with_field_ignore(
1010
input,
1111
trait_name,
12-
quote! { ::core::ops },
1312
"index_mut".into(),
1413
)?;
1514
state.add_trait_path_type_param(quote! { #index_type });

impl/src/into_iterator.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pub fn expand(input: &DeriveInput, trait_name: &'static str) -> Result<TokenStre
1010
let state = State::with_field_ignore_and_refs(
1111
input,
1212
trait_name,
13-
quote! { ::core::iter },
1413
"into_iterator".into(),
1514
)?;
1615
let SingleFieldData {

0 commit comments

Comments
 (0)