@@ -8,6 +8,7 @@ use codespan_reporting::term::{
8
8
} ;
9
9
use common:: {
10
10
diagnostics:: CompleteDiagnostic ,
11
+ impl_db_traits,
11
12
indexmap:: IndexSet ,
12
13
input:: { IngotKind , Version } ,
13
14
InputDb , InputFile , InputIngot ,
@@ -28,31 +29,27 @@ use hir_analysis::{
28
29
29
30
use crate :: diagnostics:: ToCsDiag ;
30
31
31
- #[ salsa:: jar( db = DriverDb ) ]
32
- pub struct Jar ( diagnostics:: file_line_starts ) ;
33
-
32
+ #[ salsa:: db]
34
33
pub trait DriverDb :
35
- salsa:: DbWithJar < Jar > + HirAnalysisDb + HirDb + LowerHirDb + SpannedHirDb + InputDb
36
- {
37
- }
38
-
39
- impl < DB > DriverDb for DB where
40
- DB : salsa:: DbWithJar < Jar > + HirAnalysisDb + HirDb + LowerHirDb + SpannedHirDb + InputDb
34
+ salsa:: Database + HirAnalysisDb + HirDb + LowerHirDb + SpannedHirDb + InputDb
41
35
{
36
+ fn as_driver_db ( & self ) -> & dyn DriverDb ;
42
37
}
43
38
44
- #[ derive( Default ) ]
45
- #[ salsa:: db(
46
- common:: Jar ,
47
- hir:: Jar ,
48
- hir:: LowerJar ,
49
- hir:: SpannedJar ,
50
- hir_analysis:: Jar ,
51
- Jar
52
- ) ]
39
+ #[ derive( Default , Clone ) ]
40
+ #[ salsa:: db]
53
41
pub struct DriverDataBase {
54
42
storage : salsa:: Storage < Self > ,
55
43
}
44
+ impl_db_traits ! (
45
+ DriverDataBase ,
46
+ InputDb ,
47
+ HirDb ,
48
+ LowerHirDb ,
49
+ SpannedHirDb ,
50
+ HirAnalysisDb ,
51
+ DriverDb
52
+ ) ;
56
53
57
54
impl DriverDataBase {
58
55
// TODO: An temporary implementation for ui testing.
@@ -72,7 +69,7 @@ impl DriverDataBase {
72
69
DiagnosticsCollection ( pass_manager. run_on_module ( top_mod) )
73
70
}
74
71
75
- pub fn standalone ( & mut self , file_path : & path:: Path , source : & str ) -> InputFile {
72
+ pub fn standalone ( & mut self , file_path : & path:: Path , source : & str ) -> ( InputIngot , InputFile ) {
76
73
let kind = IngotKind :: StandAlone ;
77
74
78
75
// We set the ingot version to 0.0.0 for stand-alone file.
@@ -87,21 +84,17 @@ impl DriverDataBase {
87
84
) ;
88
85
89
86
let file_name = root_file. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
90
- let input_file = InputFile :: new ( self , ingot , file_name. into ( ) , source. to_string ( ) ) ;
87
+ let input_file = InputFile :: new ( self , file_name. into ( ) , source. to_string ( ) ) ;
91
88
ingot. set_root_file ( self , input_file) ;
92
89
ingot. set_files ( self , [ input_file] . into_iter ( ) . collect ( ) ) ;
93
- input_file
90
+ ( ingot , input_file)
94
91
}
95
92
96
- pub fn top_mod ( & self , input : InputFile ) -> TopLevelMod {
97
- map_file_to_mod ( self , input)
93
+ pub fn top_mod ( & self , ingot : InputIngot , input : InputFile ) -> TopLevelMod {
94
+ map_file_to_mod ( self , ingot , input)
98
95
}
99
96
}
100
97
101
- impl salsa:: Database for DriverDataBase {
102
- fn salsa_event ( & self , _: salsa:: Event ) { }
103
- }
104
-
105
98
pub struct DiagnosticsCollection < ' db > ( Vec < Box < dyn DiagnosticVoucher < ' db > + ' db > > ) ;
106
99
impl < ' db > DiagnosticsCollection < ' db > {
107
100
pub fn emit ( & self , db : & ' db DriverDataBase ) {
0 commit comments