11//! Defines a unit of change that can applied to the database to get the next
22//! 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 ;
48use span:: FileId ;
59use triomphe:: Arc ;
610
@@ -10,6 +14,8 @@ use crate::{db::ExpandDatabase, proc_macro::ProcMacros};
1014pub struct Change {
1115 pub source_change : FileChange ,
1216 pub proc_macros : Option < ProcMacros > ,
17+ pub toolchains : Option < Vec < Option < Version > > > ,
18+ pub target_data_layouts : Option < Vec < TargetLayoutLoadResult > > ,
1319}
1420
1521impl Change {
@@ -22,6 +28,24 @@ impl Change {
2228 if let Some ( proc_macros) = self . proc_macros {
2329 db. set_proc_macros_with_durability ( Arc :: new ( proc_macros) , Durability :: HIGH ) ;
2430 }
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+ }
2549 }
2650
2751 pub fn change_file ( & mut self , file_id : FileId , new_text : Option < Arc < str > > ) {
@@ -36,6 +60,14 @@ impl Change {
3660 self . proc_macros = Some ( proc_macros) ;
3761 }
3862
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+
3971 pub fn set_roots ( & mut self , roots : Vec < SourceRoot > ) {
4072 self . source_change . set_roots ( roots)
4173 }
0 commit comments