1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use std::fmt;
use crate::common::score::Result;
use crate::common::source::{Span, Spanned};
use crate::hir::visit::Visitor;
use crate::score::ResolvableName;
pub trait FromAst<'t>: Sized {
type AllocInput: 't;
type LatentInput: 't;
type Context: 't;
type Latent;
fn alloc_slot(input: Self::AllocInput, context: Self::Context) -> Result<Self::Latent>;
fn from_ast(input: Self::LatentInput, context: Self::Context) -> Result<Self>;
}
pub trait Node<'t>: fmt::Debug {
fn span(&self) -> Span;
fn desc_kind(&self) -> String;
fn desc_name(&self) -> String {
self.desc_kind()
}
fn accept(&'t self, visitor: &mut Visitor<'t>);
fn walk(&'t self, visitor: &mut Visitor<'t>);
}
impl<'a, T: Node<'a>> From<&'a T> for &'a Node<'a> {
fn from(t: &'a T) -> &'a Node<'a> {
t
}
}
pub trait LatentNode<'t, T: 't + ?Sized>: fmt::Debug {
fn poll(&self) -> Result<&'t T>;
fn accept(&self, visitor: &mut Visitor<'t>);
fn walk(&self, visitor: &mut Visitor<'t>);
}
pub trait Decl2<'t>: Node<'t> {
fn name(&self) -> Spanned<ResolvableName>;
}
impl<'a, T: Decl2<'a>> From<&'a T> for &'a Decl2<'a> {
fn from(t: &'a T) -> &'a Decl2<'a> {
t
}
}