Skip to content

Commit

Permalink
fix Fields::iter_member doesn't compile
Browse files Browse the repository at this point in the history
the span of unnamed field member will fallback to `Span::call_site` if `Spanned` trait is not available
  • Loading branch information
Fancyflame committed Aug 9, 2024
1 parent 5e3c70d commit fec821f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::expr::Expr;
use crate::ident::Ident;
use crate::punctuated::{self, Punctuated};
use crate::restriction::{FieldMutability, Visibility};
use crate::spanned::Spanned;
use crate::token;
use crate::ty::Type;

Expand Down Expand Up @@ -145,7 +144,13 @@ mod iter_member {
None => {
let m = Member::Unnamed(crate::Index {
index: self.unnamed_counter,
span: field.ty.span(),
span: {
#[cfg(all(feature = "parsing", feature = "printing"))]
let span = crate::spanned::Spanned::span(&field.ty);
#[cfg(not(all(feature = "parsing", feature = "printing")))]
let span = proc_macro2::Span::call_site();
span
},
});
self.unnamed_counter += 1;
Some(m)
Expand Down

0 comments on commit fec821f

Please sign in to comment.