Skip to content

Commit 1629a8b

Browse files
committed
rearrange small tweaks
1 parent 0fb8dee commit 1629a8b

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/librustdoc/html/render/write_shared.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use std::rc::{Rc, Weak};
2424
use std::ffi::OsString;
2525
use std::collections::hash_map::Entry;
2626
use std::iter::once;
27-
use std::str::FromStr;
27+
use std::str::FromStr;
2828

2929
use indexmap::IndexMap;
3030
use itertools::Itertools;
@@ -69,26 +69,25 @@ pub(crate) fn write_shared(
6969
opt: &RenderOptions,
7070
tcx: TyCtxt<'_>,
7171
) -> 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+
7278
let crate_name = krate.name(cx.tcx());
7379
let crate_name = crate_name.as_str(); // rand
7480
let crate_name_json = SortedJson::serialize(crate_name); // "rand"
7581

76-
let external_crates = hack_get_external_crate_names(cx)?;
77-
7882
let sources = PartsAndLocations::<SourcesPart>::get(cx, &crate_name_json)?;
7983
let SerializedSearchIndex { index, desc } = build_index(&krate, &mut Rc::get_mut(&mut cx.shared).unwrap().cache, tcx);
8084
let search_index = PartsAndLocations::<SearchIndexPart>::get(cx, index)?;
8185
let all_crates = PartsAndLocations::<AllCratesPart>::get(crate_name_json.clone())?;
86+
let external_crates = hack_get_external_crate_names(cx)?;
8287
let crates_index = PartsAndLocations::<CratesIndexPart>::get(&crate_name, &external_crates)?;
8388
let trait_aliases = PartsAndLocations::<TraitAliasPart>::get(cx, &crate_name_json)?;
8489
let type_aliases = PartsAndLocations::<TypeAliasPart>::get(cx, krate, &crate_name_json)?;
8590

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-
9291
if let Some(parts_out_dir) = &opt.parts_out_dir {
9392
sources.write(cx, parts_out_dir)?;
9493
search_index.write(cx, parts_out_dir)?;
@@ -301,7 +300,7 @@ fn hack_get_external_crate_names(cx: &Context<'_>) -> Result<Vec<String>, Error>
301300
// they didn't emit invocation specific, so we just say there were no crates
302301
return Ok(Vec::default());
303302
};
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
305304
// dot_matches_new_line false: all crates on same line. greedy: match last bracket
306305
let regex = Regex::new(r"\[.*\]").unwrap();
307306
let Some(content) = regex.find(&content) else {
@@ -572,7 +571,6 @@ struct TraitAlias;
572571
type TraitAliasPart = Part<TraitAlias, SortedJson>;
573572
impl NamedPart for TraitAliasPart {
574573
const NAME: &'static str = "trait-impl";
575-
576574
type FileFormat = offset_template::Js;
577575
fn blank_template(_cx: &Context<'_>) -> OffsetTemplate<Self::FileFormat> {
578576
OffsetTemplate::before_after(r"(function() {

0 commit comments

Comments
 (0)