Fix span locations in ifmt and components (#3823)

* Fix span locations in ifmt

* Fix component spans

* Blame extra children on the first child element

* fix clippy
This commit is contained in:
Evan Almloff authored and GitHub committed 2025-03-04 12:25:07 -06:00
1 parent 0251221c69
commit f4c59e1188
3 files changed
+38 -9

No files matched your search

+9 -1
View File
@@ -56,7 +56,7 @@
use self::location::DynIdx;
use crate::innerlude::Attribute;
use crate::*;
use proc_macro2::TokenStream as TokenStream2;
use proc_macro2::{Span, TokenStream as TokenStream2};
use proc_macro2_diagnostics::SpanDiagnosticExt;
use syn::parse_quote;
@@ -386,4 +386,12 @@ impl TemplateBody {
)
}
}
/// Get the span of the first root of this template
pub(crate) fn first_root_span(&self) -> Span {
match self.roots.first() {
Some(root) => root.span(),
_ => Span::call_site(),
}
}
}