@@ -24,7 +24,7 @@ use std::rc::{Rc, Weak};
24
24
use std:: ffi:: OsString ;
25
25
use std:: collections:: hash_map:: Entry ;
26
26
use std:: iter:: once;
27
- use std:: str:: FromStr ;
27
+ use std:: str:: FromStr ;
28
28
29
29
use indexmap:: IndexMap ;
30
30
use itertools:: Itertools ;
@@ -69,26 +69,25 @@ pub(crate) fn write_shared(
69
69
opt : & RenderOptions ,
70
70
tcx : TyCtxt < ' _ > ,
71
71
) -> Result < ( ) , Error > {
72
+ // NOTE(EtomicBomb): I don't think we need sync here because no read-after-write?
73
+ Rc :: get_mut ( & mut cx. shared ) . unwrap ( ) . fs . set_sync_only ( true ) ;
74
+ let lock_file = cx. dst . join ( ".lock" ) ;
75
+ // Write shared runs within a flock; disable thread dispatching of IO temporarily.
76
+ let _lock = try_err ! ( flock:: Lock :: new( & lock_file, true , true , true ) , & lock_file) ;
77
+
72
78
let crate_name = krate. name ( cx. tcx ( ) ) ;
73
79
let crate_name = crate_name. as_str ( ) ; // rand
74
80
let crate_name_json = SortedJson :: serialize ( crate_name) ; // "rand"
75
81
76
- let external_crates = hack_get_external_crate_names ( cx) ?;
77
-
78
82
let sources = PartsAndLocations :: < SourcesPart > :: get ( cx, & crate_name_json) ?;
79
83
let SerializedSearchIndex { index, desc } = build_index ( & krate, & mut Rc :: get_mut ( & mut cx. shared ) . unwrap ( ) . cache , tcx) ;
80
84
let search_index = PartsAndLocations :: < SearchIndexPart > :: get ( cx, index) ?;
81
85
let all_crates = PartsAndLocations :: < AllCratesPart > :: get ( crate_name_json. clone ( ) ) ?;
86
+ let external_crates = hack_get_external_crate_names ( cx) ?;
82
87
let crates_index = PartsAndLocations :: < CratesIndexPart > :: get ( & crate_name, & external_crates) ?;
83
88
let trait_aliases = PartsAndLocations :: < TraitAliasPart > :: get ( cx, & crate_name_json) ?;
84
89
let type_aliases = PartsAndLocations :: < TypeAliasPart > :: get ( cx, krate, & crate_name_json) ?;
85
90
86
- // NOTE(EtomicBomb): I don't think we need sync here because no read-after-write?
87
- Rc :: get_mut ( & mut cx. shared ) . unwrap ( ) . fs . set_sync_only ( true ) ;
88
- let lock_file = cx. dst . join ( ".lock" ) ;
89
- // Write shared runs within a flock; disable thread dispatching of IO temporarily.
90
- let _lock = try_err ! ( flock:: Lock :: new( & lock_file, true , true , true ) , & lock_file) ;
91
-
92
91
if let Some ( parts_out_dir) = & opt. parts_out_dir {
93
92
sources. write ( cx, parts_out_dir) ?;
94
93
search_index. write ( cx, parts_out_dir) ?;
@@ -301,7 +300,7 @@ fn hack_get_external_crate_names(cx: &Context<'_>) -> Result<Vec<String>, Error>
301
300
// they didn't emit invocation specific, so we just say there were no crates
302
301
return Ok ( Vec :: default ( ) ) ;
303
302
} ;
304
- // this is run only run once so it's fine not to cache it
303
+ // this is only run once so it's fine not to cache it
305
304
// dot_matches_new_line false: all crates on same line. greedy: match last bracket
306
305
let regex = Regex :: new ( r"\[.*\]" ) . unwrap ( ) ;
307
306
let Some ( content) = regex. find ( & content) else {
@@ -572,7 +571,6 @@ struct TraitAlias;
572
571
type TraitAliasPart = Part < TraitAlias , SortedJson > ;
573
572
impl NamedPart for TraitAliasPart {
574
573
const NAME : & ' static str = "trait-impl" ;
575
-
576
574
type FileFormat = offset_template:: Js ;
577
575
fn blank_template ( _cx : & Context < ' _ > ) -> OffsetTemplate < Self :: FileFormat > {
578
576
OffsetTemplate :: before_after ( r"(function() {
0 commit comments