Skip to content

Commit

Permalink
Properly generate tuple index
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron1011 committed Aug 8, 2019
1 parent 484e554 commit 799aeb0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pin-project-internal/src/pin_projectable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use quote::{quote, ToTokens};
use syn::parse::{Parse, ParseStream};
use syn::{
Fields, FieldsNamed, FieldsUnnamed, Generics, Item, ItemEnum, ItemFn, ItemStruct, Meta,
NestedMeta, Result, ReturnType, Type, TypeTuple,
NestedMeta, Result, ReturnType, Type, TypeTuple, Index
};

use crate::utils::{Nothing, VecExt};
Expand Down Expand Up @@ -174,7 +174,8 @@ fn ensure_not_packed(item: &ItemStruct) -> Result<TokenStream> {
}
Fields::Unnamed(FieldsUnnamed { unnamed, .. }) => {
for (i, _) in unnamed.iter().enumerate() {
field_refs.push(quote!(&val.#i;));
let index = Index::from(i);
field_refs.push(quote!(&val.#index;));
}
}
Fields::Unit => {}
Expand Down

0 comments on commit 799aeb0

Please sign in to comment.