From 8b5a317d48eb26c3af875a409e4a16587aec7544 Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Tue, 17 Dec 2013 11:19:14 -0500 Subject: [PATCH] Fix rustdoc HTML rendering By returning the items to process and storing them in a queue, we were losing the context that was setup for that item during the recursion. This is an easy fix, rather than hoisting out the state that it needs. --- src/librustdoc/html/render.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 82122c4c32f..cf12eecd914 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -648,9 +648,13 @@ impl Context { self.root_path.push_str("../"); self.current.push(s); + info!("Recursing into {}", self.dst.display()); + mkdir(&self.dst); let ret = f(self); + info!("Recursed; leaving {}", self.dst.display()); + // Go back to where we were at self.dst = prev; let len = self.root_path.len(); @@ -674,13 +678,7 @@ impl Context { // using a rwarc makes this parallelizable in the future local_data::set(cache_key, Arc::new(cache)); - let mut work = ~[item]; - while work.len() > 0 { - let item = work.pop(); - self.item(item, |_cx, item| { - work.push(item); - }) - } + self.item(item); } /// Non-parellelized version of rendering an item. This will take the input @@ -688,9 +686,10 @@ impl Context { /// all sub-items which need to be rendered. /// /// The rendering driver uses this closure to queue up more work. - fn item(&mut self, item: clean::Item, f: |&mut Context, clean::Item|) { + fn item(&mut self, item: clean::Item) { fn render(w: io::File, cx: &mut Context, it: &clean::Item, pushname: bool) { + info!("Rendering an item to {}", w.path().display()); // A little unfortunate that this is done like this, but it sure // does make formatting *a lot* nicer. local_data::set(current_location_key, cx.current.clone()); @@ -734,7 +733,7 @@ impl Context { }; this.sidebar = build_sidebar(&m); for item in m.items.move_iter() { - f(this, item); + this.item(item); } }) }