1
1
//! Defines a unit of change that can applied to the database to get the next
2
2
//! state. Changes are transactional.
3
- use base_db:: { salsa:: Durability , CrateGraph , FileChange , SourceDatabaseExt , SourceRoot } ;
3
+ use base_db:: {
4
+ salsa:: Durability , CrateGraph , CrateId , FileChange , SourceDatabaseExt , SourceRoot ,
5
+ TargetLayoutLoadResult , Version ,
6
+ } ;
7
+ use la_arena:: RawIdx ;
4
8
use span:: FileId ;
5
9
use triomphe:: Arc ;
6
10
@@ -10,6 +14,8 @@ use crate::{db::ExpandDatabase, proc_macro::ProcMacros};
10
14
pub struct Change {
11
15
pub source_change : FileChange ,
12
16
pub proc_macros : Option < ProcMacros > ,
17
+ pub toolchains : Option < Vec < Option < Version > > > ,
18
+ pub target_data_layouts : Option < Vec < TargetLayoutLoadResult > > ,
13
19
}
14
20
15
21
impl Change {
@@ -22,6 +28,24 @@ impl Change {
22
28
if let Some ( proc_macros) = self . proc_macros {
23
29
db. set_proc_macros_with_durability ( Arc :: new ( proc_macros) , Durability :: HIGH ) ;
24
30
}
31
+ if let Some ( target_data_layouts) = self . target_data_layouts {
32
+ for ( id, val) in target_data_layouts. into_iter ( ) . enumerate ( ) {
33
+ db. set_data_layout_with_durability (
34
+ CrateId :: from_raw ( RawIdx :: from ( id as u32 ) ) ,
35
+ val,
36
+ Durability :: HIGH ,
37
+ ) ;
38
+ }
39
+ }
40
+ if let Some ( toolchains) = self . toolchains {
41
+ for ( id, val) in toolchains. into_iter ( ) . enumerate ( ) {
42
+ db. set_toolchain_with_durability (
43
+ CrateId :: from_raw ( RawIdx :: from ( id as u32 ) ) ,
44
+ val,
45
+ Durability :: HIGH ,
46
+ ) ;
47
+ }
48
+ }
25
49
}
26
50
27
51
pub fn change_file ( & mut self , file_id : FileId , new_text : Option < Arc < str > > ) {
@@ -36,6 +60,14 @@ impl Change {
36
60
self . proc_macros = Some ( proc_macros) ;
37
61
}
38
62
63
+ pub fn set_toolchains ( & mut self , toolchains : Vec < Option < Version > > ) {
64
+ self . toolchains = Some ( toolchains) ;
65
+ }
66
+
67
+ pub fn set_target_data_layouts ( & mut self , target_data_layouts : Vec < TargetLayoutLoadResult > ) {
68
+ self . target_data_layouts = Some ( target_data_layouts) ;
69
+ }
70
+
39
71
pub fn set_roots ( & mut self , roots : Vec < SourceRoot > ) {
40
72
self . source_change . set_roots ( roots)
41
73
}
0 commit comments