@@ -366,6 +366,7 @@ impl ModuleDeps {
366366struct ModuleData {
367367 handle : Handle ,
368368 config : ArcId < ConfigFile > ,
369+ effective_sys_info : SysInfo ,
369370 state : ModuleState ,
370371 imports : HashMap < ModuleName , FindingOrError < ModulePath > , BuildNoHash > ,
371372 deps : HashMap < Handle , ModuleDeps > ,
@@ -376,6 +377,7 @@ struct ModuleData {
376377struct ModuleDataMut {
377378 handle : Handle ,
378379 config : RwLock < ArcId < ConfigFile > > ,
380+ effective_sys_info : RwLock < SysInfo > ,
379381 state : ModuleStateMut ,
380382 /// Import resolution cache: module names from import statements → resolved paths.
381383 /// Only contains deps that were resolved via `find_import`.
@@ -404,6 +406,7 @@ impl ModuleData {
404406 ModuleDataMut {
405407 handle : self . handle . dupe ( ) ,
406408 config : RwLock :: new ( self . config . dupe ( ) ) ,
409+ effective_sys_info : RwLock :: new ( self . effective_sys_info . dupe ( ) ) ,
407410 state : self . state . clone_for_mutation ( ) ,
408411 imports : RwLock :: new ( self . imports . clone ( ) ) ,
409412 deps : RwLock :: new ( self . deps . clone ( ) ) ,
@@ -414,9 +417,11 @@ impl ModuleData {
414417
415418impl ModuleDataMut {
416419 fn new ( handle : Handle , require : Require , config : ArcId < ConfigFile > , now : Epoch ) -> Self {
420+ let effective_sys_info = handle. sys_info ( ) . dupe ( ) ;
417421 Self {
418422 handle,
419423 config : RwLock :: new ( config) ,
424+ effective_sys_info : RwLock :: new ( effective_sys_info) ,
420425 state : ModuleStateMut :: new ( require, now) ,
421426 imports : Default :: default ( ) ,
422427 deps : Default :: default ( ) ,
@@ -430,6 +435,7 @@ impl ModuleDataMut {
430435 let ModuleDataMut {
431436 handle,
432437 config,
438+ effective_sys_info,
433439 state,
434440 imports,
435441 deps,
@@ -442,13 +448,26 @@ impl ModuleDataMut {
442448 ModuleData {
443449 handle : handle. dupe ( ) ,
444450 config : config. read ( ) . dupe ( ) ,
451+ effective_sys_info : effective_sys_info. read ( ) . dupe ( ) ,
445452 state,
446453 imports,
447454 deps,
448455 rdeps,
449456 }
450457 }
451458
459+ fn effective_sys_info ( & self ) -> SysInfo {
460+ if let Some ( ast) = self . state . get_ast ( ) . as_deref ( ) {
461+ let base = self . handle . sys_info ( ) ;
462+ let effective =
463+ module_sys_info_override ( base, Some ( ast) ) . unwrap_or_else ( || base. dupe ( ) ) ;
464+ * self . effective_sys_info . write ( ) = effective. dupe ( ) ;
465+ effective
466+ } else {
467+ self . effective_sys_info . read ( ) . dupe ( )
468+ }
469+ }
470+
452471 /// Look up how this module depends on a specific source handle.
453472 /// Returns the `ModuleDep` if this module depends on `source_handle`, or `None` if not found.
454473 fn get_depends_on ( & self , source_handle : & Handle ) -> Option < ModuleDeps > {
@@ -1023,18 +1042,12 @@ impl<'a> Transaction<'a> {
10231042 let require = guard. require ( ) ;
10241043 let stdlib = self . get_stdlib ( & module_data. handle ) ;
10251044 let config = module_data. config . read ( ) ;
1026- let sys_info_override = module_sys_info_override (
1027- module_data. handle . sys_info ( ) ,
1028- module_data. state . get_ast ( ) . as_deref ( ) ,
1029- ) ;
1030- let sys_info = sys_info_override
1031- . as_ref ( )
1032- . unwrap_or ( module_data. handle . sys_info ( ) ) ;
1045+ let sys_info = module_data. effective_sys_info ( ) ;
10331046 let ctx = Context {
10341047 require,
10351048 module : module_data. handle . module ( ) ,
10361049 path : module_data. handle . path ( ) ,
1037- sys_info,
1050+ sys_info : & sys_info ,
10381051 memory : & self . memory_lookup ( ) ,
10391052 uniques : & self . data . state . uniques ,
10401053 stdlib : & stdlib,
@@ -2003,13 +2016,7 @@ impl<'a> TransactionHandle<'a> {
20032016 path : Option < & ModulePath > ,
20042017 dep : ModuleDep ,
20052018 ) -> FindingOrError < ArcId < ModuleDataMut > > {
2006- let sys_info_override = module_sys_info_override (
2007- self . module_data . handle . sys_info ( ) ,
2008- self . module_data . state . get_ast ( ) . as_deref ( ) ,
2009- ) ;
2010- let sys_info = sys_info_override
2011- . as_ref ( )
2012- . unwrap_or ( self . module_data . handle . sys_info ( ) ) ;
2019+ let sys_info = self . module_data . effective_sys_info ( ) ;
20132020 let handle = match path {
20142021 Some ( path) => {
20152022 // Explicit path — already resolved. Bypass imports entirely.
0 commit comments