Skip to content

Commit

Permalink
Fix clippy and rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Sep 4, 2019
1 parent 426683b commit 3225597
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pin-project-internal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use syn::parse::Nothing;
/// type, and returns a projection struct. This is the method
/// you'll usually want to use - since it takes a mutable reference,
/// it can be called multiple times, and allows you to use
/// the original Pin type later on (e.g. to call Pin::set)
/// the original Pin type later on (e.g. to call [`Pin::set`])
///
/// The `project_into` type takes a pinned type by value (consuming it),
/// and returns a projection struct. The difference between this and the `project`
Expand Down
1 change: 0 additions & 1 deletion pin-project-internal/src/pin_project/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ pub(super) fn parse(cx: &mut Context, mut item: ItemEnum) -> Result<TokenStream>
let proj_generics = cx.proj_generics();
let where_clause = item.generics.split_for_impl().2;


let mut proj_items = quote! {
#[allow(clippy::mut_mut)]
#[allow(dead_code)]
Expand Down
14 changes: 9 additions & 5 deletions pin-project-internal/src/pin_project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use syn::{

use crate::utils::{
self, crate_path, proj_ident, proj_lifetime_name, proj_trait_ident, DEFAULT_LIFETIME_NAME,
TRAIT_LIFETIME_NAME
TRAIT_LIFETIME_NAME,
};

mod enums;
Expand Down Expand Up @@ -68,7 +68,7 @@ struct Context {

/// Lifetime added to projected type.
lifetime: Lifetime,

/// Lifetime on the generated projection trait
trait_lifetime: Lifetime,

Expand Down Expand Up @@ -130,7 +130,11 @@ impl Context {
/// Creates an implementation of the projection trait.
/// The provided TokenStream will be used as the body of the
/// 'project' and 'project_into' implementations
fn make_trait_impl(&self, project_body: &TokenStream, project_into_body: &TokenStream) -> TokenStream {
fn make_trait_impl(
&self,
project_body: &TokenStream,
project_into_body: &TokenStream,
) -> TokenStream {
let Context { proj_ident, proj_trait, orig_ident, lifetime, trait_lifetime, .. } = &self;
let proj_generics = self.proj_generics();

Expand All @@ -140,7 +144,6 @@ impl Context {
let (impl_generics, project_into_ty_generics, _) = project_into_generics.split_for_impl();
let (_, ty_generics, where_clause) = self.generics.split_for_impl();


quote! {
impl #impl_generics #proj_trait #project_into_ty_generics for ::core::pin::Pin<&#trait_lifetime mut #orig_ident #ty_generics> #where_clause {
fn project<#lifetime>(&#lifetime mut self) -> #proj_ident #proj_ty_generics #where_clause {
Expand Down Expand Up @@ -392,7 +395,8 @@ impl Context {
let mut trait_generics = self.generics.clone();
utils::proj_generics(&mut trait_generics, self.trait_lifetime.clone());

let (trait_generics, trait_ty_generics, orig_where_clause) = trait_generics.split_for_impl();
let (trait_generics, trait_ty_generics, orig_where_clause) =
trait_generics.split_for_impl();

quote! {
trait #proj_trait #trait_generics {
Expand Down
1 change: 0 additions & 1 deletion pin-project-internal/src/pin_project/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ pub(super) fn parse(cx: &mut Context, mut item: ItemStruct) -> Result<TokenStrea
struct #proj_ident #proj_generics #where_clause #proj_fields
};


let project_body = quote! {
unsafe {
let this = self.as_mut().get_unchecked_mut();
Expand Down
4 changes: 2 additions & 2 deletions tests/pin_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ fn test_lifetime_project() {
#[pin]
pinned: T,
unpinned: U,
}
},
}

impl<T, U> Struct<T, U> {
Expand All @@ -290,7 +290,7 @@ fn test_lifetime_project() {
impl<T, U> Enum<T, U> {
fn get_pin_mut<'a>(self: Pin<&'a mut Self>) -> Pin<&'a mut T> {
match self.project_into() {
__EnumProjection::Variant { pinned, .. } => pinned
__EnumProjection::Variant { pinned, .. } => pinned,
}
}
}
Expand Down

0 comments on commit 3225597

Please sign in to comment.