Skip to content

Commit 1479abd

Browse files
committed
---
yaml --- r: 149359 b: refs/heads/try2 c: 429ef87 h: refs/heads/master i: 149357: fa9e05d 149355: 5321b22 149351: 7b7d9b5 149343: e4cd2d8 v: v3
1 parent f017f5d commit 1479abd

File tree

3 files changed

+34
-16
lines changed

3 files changed

+34
-16
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: cac9107f38c1d28ed263759040b5411b0db47824
8+
refs/heads/try2: 429ef870f67b02664b6ac35b08f3b36b71e8bd00
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustdoc/html/render.rs

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ pub struct Cache {
157157
priv parent_stack: ~[ast::NodeId],
158158
priv search_index: ~[IndexItem],
159159
priv privmod: bool,
160+
priv public_items: HashSet<ast::NodeId>,
160161
}
161162

162163
/// Helper struct to render all source code to HTML pages
@@ -231,18 +232,23 @@ pub fn run(mut krate: clean::Crate, dst: Path) -> io::IoResult<()> {
231232
}
232233

233234
// Crawl the crate to build various caches used for the output
234-
let mut cache = Cache {
235-
impls: HashMap::new(),
236-
typarams: HashMap::new(),
237-
paths: HashMap::new(),
238-
traits: HashMap::new(),
239-
implementors: HashMap::new(),
240-
stack: ~[],
241-
parent_stack: ~[],
242-
search_index: ~[],
243-
extern_locations: HashMap::new(),
244-
privmod: false,
245-
};
235+
let mut cache = local_data::get(::analysiskey, |analysis| {
236+
let public_items = analysis.map(|a| a.public_items.clone());
237+
let public_items = public_items.unwrap_or(HashSet::new());
238+
Cache {
239+
impls: HashMap::new(),
240+
typarams: HashMap::new(),
241+
paths: HashMap::new(),
242+
traits: HashMap::new(),
243+
implementors: HashMap::new(),
244+
stack: ~[],
245+
parent_stack: ~[],
246+
search_index: ~[],
247+
extern_locations: HashMap::new(),
248+
privmod: false,
249+
public_items: public_items,
250+
}
251+
});
246252
cache.stack.push(krate.name.clone());
247253
krate = cache.fold_crate(krate);
248254

@@ -566,7 +572,16 @@ impl DocFolder for Cache {
566572
clean::TypedefItem(..) | clean::TraitItem(..) |
567573
clean::FunctionItem(..) | clean::ModuleItem(..) |
568574
clean::ForeignFunctionItem(..) => {
569-
self.paths.insert(item.id, (self.stack.clone(), shortty(&item)));
575+
// Reexported items mean that the same id can show up twice in
576+
// the rustdoc ast that we're looking at. We know, however, that
577+
// a reexported item doesn't show up in the `public_items` map,
578+
// so we can skip inserting into the paths map if there was
579+
// already an entry present and we're not a public item.
580+
if !self.paths.contains_key(&item.id) ||
581+
self.public_items.contains(&item.id) {
582+
self.paths.insert(item.id,
583+
(self.stack.clone(), shortty(&item)));
584+
}
570585
}
571586
// link variants to their parent enum because pages aren't emitted
572587
// for each variant

branches/try2/src/libstd/macros.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ macro_rules! log_enabled(
130130
/// # Example
131131
///
132132
/// ```should_fail
133+
/// # #[allow(unreachable_code)];
133134
/// fail!();
134135
/// fail!("this is a terrible mistake!");
135136
/// fail!(4); // fail with the value of 4 to be collected elsewhere
@@ -228,13 +229,15 @@ macro_rules! assert_eq(
228229
/// # Example
229230
///
230231
/// ~~~rust
232+
/// struct Item { weight: uint }
233+
///
231234
/// fn choose_weighted_item(v: &[Item]) -> Item {
232235
/// assert!(!v.is_empty());
233236
/// let mut so_far = 0u;
234237
/// for item in v.iter() {
235238
/// so_far += item.weight;
236239
/// if so_far > 100 {
237-
/// return item;
240+
/// return *item;
238241
/// }
239242
/// }
240243
/// // The above loop always returns, so we must hint to the
@@ -336,7 +339,7 @@ macro_rules! println(
336339
/// local_data_key!(my_integer: int)
337340
///
338341
/// local_data::set(my_integer, 2);
339-
/// local_data::get(my_integer, |val| println!("{}", val));
342+
/// local_data::get(my_integer, |val| println!("{}", val.map(|i| *i)));
340343
/// ```
341344
#[macro_export]
342345
macro_rules! local_data_key(

0 commit comments

Comments
 (0)