Skip to content

Commit a5aa2e4

Browse files
committed
fix: use unsuffixed numeric literal for tuple index
See <rust-lang/rust#60210> for more context. This has been a future-incompatibility warning since Rust 1.27, where tuple index subexpressions with invalid suffixes (in this case, `.0usize`) was erroneously accidentally accepted. This will become a hard error in Rust 1.91 after <rust-lang/rust#145463> rejects the remaining carve-outs.
1 parent 256af3c commit a5aa2e4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

validates_derive/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use syn::Data;
1111
use syn::DeriveInput;
1212
use syn::Fields;
1313
use syn::Ident;
14+
use syn::Index;
1415
use syn::Lit;
1516
use syn::LitStr;
1617
use syn::Meta;
@@ -54,6 +55,7 @@ pub fn derive_validates(input: TokenStream) -> TokenStream {
5455
Fields::Unnamed(d) => {
5556
let ctor_fields: Vec<_> = d.unnamed.iter().enumerate().map(|(name, f)| {
5657
let mangle = compute_mangle_expr(&f.attrs, format!("#{}", name));
58+
let name = Index::from(name);
5759
return quote! {
5860
::validates::Validates::validate(self.#name) #mangle ?,
5961
};
@@ -68,6 +70,7 @@ pub fn derive_validates(input: TokenStream) -> TokenStream {
6870
}).collect();
6971
struct_args = quote! { ( #( #struct_fields )* ); };
7072
let clone_fields: Vec<_> = d.unnamed.iter().enumerate().map(|(name, _f)| {
73+
let name = Index::from(name);
7174
return quote! {
7275
::std::clone::Clone::clone(&self.#name),
7376
};

0 commit comments

Comments
 (0)