forked from cryspen/hax
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinter.rs
More file actions
38 lines (34 loc) · 829 Bytes
/
linter.rs
File metadata and controls
38 lines (34 loc) · 829 Bytes
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
use hax_lint::Type;
use rustc_driver::{Callbacks, Compilation};
use rustc_interface::{
interface::{self, Compiler},
Queries,
};
pub(crate) struct LinterCallbacks {
ltype: Type,
}
impl LinterCallbacks {
pub(crate) fn new(ltype: Type) -> Self {
Self { ltype }
}
}
impl Callbacks for LinterCallbacks {
fn after_crate_root_parsing<'tcx>(
&mut self,
_compiler: &Compiler,
queries: &'tcx Queries<'tcx>,
) -> Compilation {
Compilation::Continue
}
fn after_expansion<'tcx>(
&mut self,
compiler: &Compiler,
queries: &'tcx Queries<'tcx>,
) -> Compilation {
queries
.global_ctxt()
.unwrap()
.enter(|tcx| hax_lint::Linter::register(tcx, self.ltype));
Compilation::Continue
}
}