abi_stable_derive/
set_span_visitor.rs
1use syn::{spanned::Spanned, visit_mut::VisitMut, Ident};
2
3use proc_macro2::Span;
4
5#[derive(Debug, Clone, Copy)]
7pub struct SetSpanVisitor {
8 pub span: Span,
9}
10
11impl SetSpanVisitor {
12 pub fn new(span: Span) -> Self {
13 Self { span }
14 }
15 #[allow(dead_code)]
16 pub fn span_of<T>(thing: &T) -> Self
17 where
18 T: Spanned,
19 {
20 Self { span: thing.span() }
21 }
22}
23
24impl VisitMut for SetSpanVisitor {
25 fn visit_ident_mut(&mut self, i: &mut Ident) {
26 i.set_span(self.span);
27 }
28}