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
use std::path::PathBuf;
use {Span, Row, Column, OneIndexed};
#[cfg_attr(feature = "serialize-serde", derive(Deserialize))]
#[derive(Debug, Clone)]
pub struct DiagnosticSpan {
pub file_name: String,
pub byte_start: u32,
pub byte_end: u32,
pub line_start: usize,
pub line_end: usize,
pub column_start: usize,
pub column_end: usize,
pub is_primary: bool,
pub text: Vec<DiagnosticSpanLine>,
pub label: Option<String>,
pub suggested_replacement: Option<String>,
pub expansion: Option<Box<DiagnosticSpanMacroExpansion>>,
}
impl DiagnosticSpan {
pub fn rls_span(&self) -> Span<OneIndexed> {
Span::new(Row::new(self.line_start as u32),
Row::new(self.line_end as u32),
Column::new(self.column_start as u32),
Column::new(self.column_end as u32),
PathBuf::from(&self.file_name))
}
}
#[cfg_attr(feature = "serialize-serde", derive(Deserialize))]
#[derive(Debug, Clone)]
pub struct DiagnosticSpanLine {
pub text: String,
pub highlight_start: usize,
pub highlight_end: usize,
}
#[cfg_attr(feature = "serialize-serde", derive(Deserialize))]
#[derive(Debug, Clone)]
pub struct DiagnosticSpanMacroExpansion {
pub span: DiagnosticSpan,
pub macro_decl_name: String,
pub def_site_span: Option<DiagnosticSpan>,
}