Skip to content

Commit

Permalink
Merge #118
Browse files Browse the repository at this point in the history
118: Update derive_utils to 0.11 r=taiki-e a=taiki-e



Co-authored-by: Taiki Endo <te316e89@gmail.com>
  • Loading branch information
bors[bot] and taiki-e authored Nov 6, 2020
2 parents 24465a0 + 9a6670b commit 51e3e1b
Show file tree
Hide file tree
Showing 22 changed files with 108 additions and 183 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ This project adheres to [Semantic Versioning](https://semver.org).

## [Unreleased]

* Update `derive_utils` to 0.11.

## [0.7.8] - 2020-10-16

* [Add support for `tokio03::{AsyncRead, AsyncWrite, AsyncSeek, AsyncBufRead}`.](https://github.com/taiki-e/auto_enums/pull/114)
Expand Down
2 changes: 1 addition & 1 deletion core/src/auto_enum/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ mod kw {
syn::custom_keyword!(marker);
}

#[allow(dead_code)] // https://github.com/rust-lang/rust/issues/56750
#[allow(dead_code)] // false positive that fixed in Rust 1.39
struct Args {
args: Vec<Path>,
marker: Option<Ident>,
Expand Down
2 changes: 1 addition & 1 deletion derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ trusted_len = []
autocfg = "1"

[dependencies]
derive_utils = { version = "0.10" }
derive_utils = { version = "0.11" }
proc-macro2 = "1"
quote = "1"
syn = { version = "1", features = ["full"] }
8 changes: 4 additions & 4 deletions derive/src/derive/core/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ pub(crate) mod as_ref {
pub(crate) const NAME: &[&str] = &["AsRef"];

pub(crate) fn derive(data: &Data) -> Result<TokenStream> {
derive_trait(data, parse_quote!(::core::convert::AsRef), None, parse_quote! {
Ok(derive_trait(data, parse_quote!(::core::convert::AsRef), None, parse_quote! {
trait AsRef<__T: ?Sized> {
#[inline]
fn as_ref(&self) -> &__T;
}
})
}))
}
}

Expand All @@ -19,11 +19,11 @@ pub(crate) mod as_mut {
pub(crate) const NAME: &[&str] = &["AsMut"];

pub(crate) fn derive(data: &Data) -> Result<TokenStream> {
derive_trait(data, parse_quote!(::core::convert::AsMut), None, parse_quote! {
Ok(derive_trait(data, parse_quote!(::core::convert::AsMut), None, parse_quote! {
trait AsMut<__T: ?Sized> {
#[inline]
fn as_mut(&mut self) -> &mut __T;
}
})
}))
}
}
9 changes: 4 additions & 5 deletions derive/src/derive/core/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ macro_rules! derive_fmt {
pub(crate) const NAME: &[&str] = &[$($name),*];

pub(crate) fn derive(data: &Data) -> Result<TokenStream> {
derive_trait(data, parse_quote!(::core::fmt::$Trait), None, parse_quote! {
Ok(derive_trait(data, parse_quote!(::core::fmt::$Trait), None, parse_quote! {
trait $Trait {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result;
}
})

}))
}
}
};
Expand Down Expand Up @@ -42,7 +41,7 @@ pub(crate) mod write {
pub(crate) const NAME: &[&str] = &["fmt::Write"];

pub(crate) fn derive(data: &Data) -> Result<TokenStream> {
derive_trait(data, parse_quote!(::core::fmt::Write), None, parse_quote! {
Ok(derive_trait(data, parse_quote!(::core::fmt::Write), None, parse_quote! {
trait Write {
#[inline]
fn write_str(&mut self, s: &str) -> ::core::fmt::Result;
Expand All @@ -51,6 +50,6 @@ pub(crate) mod write {
#[inline]
fn write_fmt(&mut self, args: ::core::fmt::Arguments<'_>) -> ::core::fmt::Result;
}
})
}))
}
}
4 changes: 2 additions & 2 deletions derive/src/derive/core/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::utils::*;
pub(crate) const NAME: &[&str] = &["Future"];

pub(crate) fn derive(data: &Data) -> Result<TokenStream> {
derive_trait(data, parse_quote!(::core::future::Future), None, parse_quote! {
Ok(derive_trait(data, parse_quote!(::core::future::Future), None, parse_quote! {
trait Future {
type Output;
#[inline]
Expand All @@ -12,5 +12,5 @@ pub(crate) fn derive(data: &Data) -> Result<TokenStream> {
cx: &mut ::core::task::Context<'_>,
) -> ::core::task::Poll<Self::Output>;
}
})
}))
}
24 changes: 12 additions & 12 deletions derive/src/derive/core/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub(crate) mod iterator {
__F: ::core::ops::FnMut(Self::Item) -> ::core::option::Option<__U>;
};

derive_trait(data, parse_quote!(::core::iter::Iterator), None, parse_quote! {
Ok(derive_trait(data, parse_quote!(::core::iter::Iterator), None, parse_quote! {
trait Iterator {
type Item;
#[inline]
Expand All @@ -38,7 +38,7 @@ pub(crate) mod iterator {
fn collect<__U: ::core::iter::FromIterator<Self::Item>>(self) -> __U;
#try_trait
}
})
}))
}
}

Expand All @@ -62,7 +62,7 @@ pub(crate) mod double_ended_iterator {
__P: ::core::ops::FnMut(&Self::Item) -> bool;
};

derive_trait(
Ok(derive_trait(
data,
parse_quote!(::core::iter::DoubleEndedIterator),
Some(format_ident!("Item")),
Expand All @@ -73,7 +73,7 @@ pub(crate) mod double_ended_iterator {
#try_trait
}
},
)
))
}
}

Expand All @@ -85,7 +85,7 @@ pub(crate) mod exact_size_iterator {
pub(crate) fn derive(data: &Data) -> Result<TokenStream> {
// TODO: When `exact_size_is_empty` stabilized, add `is_empty` conditionally.

derive_trait(
Ok(derive_trait(
data,
parse_quote!(::core::iter::ExactSizeIterator),
Some(format_ident!("Item")),
Expand All @@ -95,7 +95,7 @@ pub(crate) mod exact_size_iterator {
fn len(&self) -> usize;
}
},
)
))
}
}

Expand All @@ -105,14 +105,14 @@ pub(crate) mod fused_iterator {
pub(crate) const NAME: &[&str] = &["FusedIterator"];

pub(crate) fn derive(data: &Data) -> Result<TokenStream> {
derive_trait(
Ok(derive_trait(
data,
parse_quote!(::core::iter::FusedIterator),
Some(format_ident!("Item")),
parse_quote! {
trait FusedIterator: ::core::iter::Iterator {}
},
)
))
}
}

Expand All @@ -123,14 +123,14 @@ pub(crate) mod trusted_len {
pub(crate) const NAME: &[&str] = &["TrustedLen"];

pub(crate) fn derive(data: &Data) -> Result<TokenStream> {
derive_trait(
Ok(derive_trait(
data,
parse_quote!(::core::iter::TrustedLen),
Some(format_ident!("Item")),
parse_quote! {
unsafe trait TrustedLen: ::core::iter::Iterator {}
},
)
))
}
}

Expand All @@ -140,11 +140,11 @@ pub(crate) mod extend {
pub(crate) const NAME: &[&str] = &["Extend"];

pub(crate) fn derive(data: &Data) -> Result<TokenStream> {
derive_trait(data, parse_quote!(::core::iter::Extend), None, parse_quote! {
Ok(derive_trait(data, parse_quote!(::core::iter::Extend), None, parse_quote! {
trait Extend<__A> {
#[inline]
fn extend<__T: ::core::iter::IntoIterator<Item = __A>>(&mut self, iter: __T);
}
})
}))
}
}
30 changes: 15 additions & 15 deletions derive/src/derive/core/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ pub(crate) mod deref {
pub(crate) const NAME: &[&str] = &["Deref"];

pub(crate) fn derive(data: &Data) -> Result<TokenStream> {
derive_trait(data, parse_quote!(::core::ops::Deref), None, parse_quote! {
Ok(derive_trait(data, parse_quote!(::core::ops::Deref), None, parse_quote! {
trait Deref {
type Target;
#[inline]
fn deref(&self) -> &Self::Target;
}
})
}))
}
}

Expand All @@ -22,7 +22,7 @@ pub(crate) mod deref_mut {
pub(crate) const NAME: &[&str] = &["DerefMut"];

pub(crate) fn derive(data: &Data) -> Result<TokenStream> {
derive_trait(
Ok(derive_trait(
data,
parse_quote!(::core::ops::DerefMut),
Some(format_ident!("Target")),
Expand All @@ -32,7 +32,7 @@ pub(crate) mod deref_mut {
fn deref_mut(&mut self) -> &mut Self::Target;
}
},
)
))
}
}

Expand All @@ -43,13 +43,13 @@ pub(crate) mod index {
pub(crate) const NAME: &[&str] = &["Index"];

pub(crate) fn derive(data: &Data) -> Result<TokenStream> {
derive_trait(data, parse_quote!(::core::ops::Index), None, parse_quote! {
Ok(derive_trait(data, parse_quote!(::core::ops::Index), None, parse_quote! {
trait Index<__Idx> {
type Output;
#[inline]
fn index(&self, index: __Idx) -> &Self::Output;
}
})
}))
}
}

Expand All @@ -60,7 +60,7 @@ pub(crate) mod index_mut {
pub(crate) const NAME: &[&str] = &["IndexMut"];

pub(crate) fn derive(data: &Data) -> Result<TokenStream> {
derive_trait(
Ok(derive_trait(
data,
parse_quote!(::core::ops::IndexMut),
Some(format_ident!("Output")),
Expand All @@ -70,7 +70,7 @@ pub(crate) mod index_mut {
fn index_mut(&mut self, index: __Idx) -> &mut Self::Output;
}
},
)
))
}
}

Expand All @@ -81,14 +81,14 @@ pub(crate) mod range_bounds {
pub(crate) const NAME: &[&str] = &["RangeBounds"];

pub(crate) fn derive(data: &Data) -> Result<TokenStream> {
derive_trait(data, parse_quote!(::core::ops::RangeBounds), None, parse_quote! {
Ok(derive_trait(data, parse_quote!(::core::ops::RangeBounds), None, parse_quote! {
trait RangeBounds<__T: ?Sized> {
#[inline]
fn start_bound(&self) -> ::core::ops::Bound<&__T>;
#[inline]
fn end_bound(&self) -> ::core::ops::Bound<&__T>;
}
})
}))
}
}

Expand All @@ -99,7 +99,7 @@ pub(crate) mod generator {
pub(crate) const NAME: &[&str] = &["Generator"];

pub(crate) fn derive(data: &Data) -> Result<TokenStream> {
derive_trait(data, parse_quote!(::core::ops::Generator), None, parse_quote! {
Ok(derive_trait(data, parse_quote!(::core::ops::Generator), None, parse_quote! {
trait Generator<R> {
type Yield;
type Return;
Expand All @@ -109,7 +109,7 @@ pub(crate) mod generator {
arg: R,
) -> ::core::ops::GeneratorState<Self::Yield, Self::Return>;
}
})
}))
}
}

Expand Down Expand Up @@ -140,7 +140,7 @@ pub(crate) mod fn_ {
impl_.push_method(parse_quote! {
#[inline]
extern "rust-call" fn call(&self, args: (__T,)) -> Self::Output;
})?;
});

Ok(impl_.build())
}
Expand Down Expand Up @@ -173,7 +173,7 @@ pub(crate) mod fn_mut {
impl_.push_method(parse_quote! {
#[inline]
extern "rust-call" fn call_mut(&mut self, args: (__T,)) -> Self::Output;
})?;
});

Ok(impl_.build())
}
Expand Down Expand Up @@ -209,7 +209,7 @@ pub(crate) mod fn_once {
#[inline]
extern "rust-call" fn call_once(self, args: (__T,)) -> Self::Output;
}
})?;
});

Ok(impl_.build())
}
Expand Down
12 changes: 6 additions & 6 deletions derive/src/derive/external/futures01.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ pub(crate) mod future {
pub(crate) const NAME: &[&str] = &["futures01::Future"];

pub(crate) fn derive(data: &Data) -> Result<TokenStream> {
derive_trait(data, parse_quote!(::futures::future::Future), None, parse_quote! {
Ok(derive_trait(data, parse_quote!(::futures::future::Future), None, parse_quote! {
trait Future {
type Item;
type Error;
#[inline]
fn poll(&mut self) -> ::futures::Poll<Self::Item, Self::Error>;
}
})
}))
}
}

Expand All @@ -21,7 +21,7 @@ pub(crate) mod stream {
pub(crate) const NAME: &[&str] = &["futures01::Stream"];

pub(crate) fn derive(data: &Data) -> Result<TokenStream> {
derive_trait(data, parse_quote!(::futures::stream::Stream), None, parse_quote! {
Ok(derive_trait(data, parse_quote!(::futures::stream::Stream), None, parse_quote! {
trait Stream {
type Item;
type Error;
Expand All @@ -30,7 +30,7 @@ pub(crate) mod stream {
&mut self,
) -> ::futures::Poll<::core::option::Option<Self::Item>, Self::Error>;
}
})
}))
}
}

Expand All @@ -40,7 +40,7 @@ pub(crate) mod sink {
pub(crate) const NAME: &[&str] = &["futures01::Sink"];

pub(crate) fn derive(data: &Data) -> Result<TokenStream> {
derive_trait(data, parse_quote!(::futures::sink::Sink), None, parse_quote! {
Ok(derive_trait(data, parse_quote!(::futures::sink::Sink), None, parse_quote! {
trait Sink {
type SinkItem;
type SinkError;
Expand All @@ -54,6 +54,6 @@ pub(crate) mod sink {
#[inline]
fn close(&mut self) -> ::futures::Poll<(), Self::SinkError>;
}
})
}))
}
}
Loading

0 comments on commit 51e3e1b

Please sign in to comment.