rune/compile/
compile_visitor.rs1use crate::ast::Spanned;
2use crate::compile::{Located, MetaError, MetaRef};
3use crate::{Hash, Item, SourceId};
4
5pub trait CompileVisitor {
7 fn register_meta(&mut self, _meta: MetaRef<'_>) -> Result<(), MetaError> {
9 Ok(())
10 }
11
12 fn visit_meta(&mut self, _location: &dyn Located, _meta: MetaRef<'_>) -> Result<(), MetaError> {
14 Ok(())
15 }
16
17 fn visit_variable_use(
19 &mut self,
20 _source_id: SourceId,
21 _var_span: &dyn Spanned,
22 _span: &dyn Spanned,
23 ) -> Result<(), MetaError> {
24 Ok(())
25 }
26
27 fn visit_mod(&mut self, _location: &dyn Located) -> Result<(), MetaError> {
29 Ok(())
30 }
31
32 fn visit_doc_comment(
41 &mut self,
42 _location: &dyn Located,
43 _item: &Item,
44 _hash: Hash,
45 _docstr: &str,
46 ) -> Result<(), MetaError> {
47 Ok(())
48 }
49
50 fn visit_field_doc_comment(
56 &mut self,
57 _location: &dyn Located,
58 _item: &Item,
59 _hash: Hash,
60 _field: &str,
61 _docstr: &str,
62 ) -> Result<(), MetaError> {
63 Ok(())
64 }
65}
66
67#[cfg(all(feature = "std", feature = "anyhow"))]
69pub(crate) struct NoopCompileVisitor(());
70
71#[cfg(all(feature = "std", feature = "anyhow"))]
72impl NoopCompileVisitor {
73 pub(crate) const fn new() -> Self {
75 Self(())
76 }
77}
78
79#[cfg(all(feature = "std", feature = "anyhow"))]
80impl CompileVisitor for NoopCompileVisitor {}