From 799aeb0fc4a6189ec99917afb85142d55481045a Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Wed, 7 Aug 2019 21:30:23 -0400 Subject: [PATCH] Properly generate tuple index See https://github.com/rust-lang/rust/issues/60210 --- pin-project-internal/src/pin_projectable/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pin-project-internal/src/pin_projectable/mod.rs b/pin-project-internal/src/pin_projectable/mod.rs index aed2e788..3136e4ae 100644 --- a/pin-project-internal/src/pin_projectable/mod.rs +++ b/pin-project-internal/src/pin_projectable/mod.rs @@ -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}; @@ -174,7 +174,8 @@ fn ensure_not_packed(item: &ItemStruct) -> Result { } 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 => {}