diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index a97dd95dcb66..8ef5fabb9017 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -258,11 +258,7 @@ impl Iterator for PeekIter<'a> { type Item = (TokenKind, &'a str); fn next(&mut self) -> Option { self.peek_pos = 0; - if let Some(first) = self.stored.pop_front() { - Some(first) - } else { - self.iter.next() - } + if let Some(first) = self.stored.pop_front() { Some(first) } else { self.iter.next() } } } diff --git a/src/librustdoc/html/highlight/tests.rs b/src/librustdoc/html/highlight/tests.rs index 405bdf0d8108..3fa386dded9b 100644 --- a/src/librustdoc/html/highlight/tests.rs +++ b/src/librustdoc/html/highlight/tests.rs @@ -60,7 +60,7 @@ fn test_union_highlighting() { create_default_session_globals_then(|| { let src = include_str!("fixtures/union.rs"); let mut html = Buffer::new(); - write_code(&mut html, src, Edition::Edition2018, None); + write_code(&mut html, src, Edition::Edition2018, None, None); expect_file!["fixtures/union.html"].assert_eq(&html.into_inner()); }); } diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index cd5316240d00..2454ae492b21 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -2465,7 +2465,7 @@ const MAX_FULL_EXAMPLES: usize = 5; /// Generates the HTML for example call locations generated via the --scrape-examples flag. fn render_call_locations(w: &mut Buffer, cx: &Context<'_>, def_id: DefId, item: &clean::Item) { let tcx = cx.tcx(); - let key = crate::scrape_examples::def_id_call_key(tcx, def_id); + let key = tcx.def_path_hash(def_id); let call_locations = match cx.shared.call_locations.get(&key) { Some(call_locations) => call_locations, _ => { @@ -2474,13 +2474,14 @@ fn render_call_locations(w: &mut Buffer, cx: &Context<'_>, def_id: DefId, item: }; // Generate a unique ID so users can link to this section for a given method + // FIXME: this should use init_id_map instead of derive let id = cx.id_map.borrow_mut().derive("scraped-examples"); write!( w, - r##"
-

- Examples found in repository -

"##, + "
\ +

\ + Examples found in repository\ +

", id ); @@ -2533,11 +2534,11 @@ fn render_call_locations(w: &mut Buffer, cx: &Context<'_>, def_id: DefId, item: write!( w, - r#"
-
- {name} ({line_range}) -
-
"#, + "
\ +
\ + {name} ({line_range})\ +
\ +
", root = cx.root_path(), url = call_data.url, name = call_data.display_name, @@ -2625,14 +2626,13 @@ fn render_call_locations(w: &mut Buffer, cx: &Context<'_>, def_id: DefId, item: if it.peek().is_some() { write!( w, - r#"
- - More examples - -
-
-
-"# + "
\ + \ + More examples\ + \ +
\ +
\ +
" ); // Only generate inline code for MAX_FULL_EXAMPLES number of examples. Otherwise we could @@ -2643,10 +2643,7 @@ fn render_call_locations(w: &mut Buffer, cx: &Context<'_>, def_id: DefId, item: // For the remaining examples, generate a
    containing links to the source files. if it.peek().is_some() { - write!( - w, - r#"