telety_impl/alias/
error.rs1use proc_macro2::Span;
2
3
4pub struct Error {
5 span: Span,
6 pub kind: Kind,
7}
8
9pub enum Kind {
10 AssociatedType,
11 Closure,
12}
13
14impl Kind {
15 pub(crate) fn error(self, span: Span) -> Error {
16 Error::new(span, self)
17 }
18}
19
20impl Error {
21 pub(crate) fn new(span: Span, kind: Kind) -> Self {
22 Self {
23 span,
24 kind,
25 }
26 }
27}
28
29impl From<Error> for syn::Error {
30 fn from(value: Error) -> Self {
31 let Error {
32 span,
33 kind,
34 } = value;
35
36 let message = match kind {
37 Kind::AssociatedType => "Associated types are not supported".to_string(),
38 Kind::Closure => "Closure traits are not supported".to_string(),
39 };
40
41 syn::Error::new(span, message)
42 }
43}