From 611866f3cfb129202bc229659c1e8f4f313b330e Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Thu, 28 Dec 2017 10:52:40 -0600 Subject: [PATCH] cleanup --- src/librustc/hir/lowering.rs | 8 ++++---- src/librustc_driver/driver.rs | 9 +++++---- src/librustdoc/clean/mod.rs | 6 +++--- src/librustdoc/html/markdown.rs | 10 ++++++++-- src/librustdoc/html/render.rs | 22 ++++++++++++++++++---- src/librustdoc/lib.rs | 2 +- src/librustdoc/visit_ast.rs | 8 ++++---- src/librustdoc/visit_lib.rs | 8 ++++---- 8 files changed, 47 insertions(+), 26 deletions(-) diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index b7a7fcd9872..f2154f885fa 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -152,9 +152,9 @@ pub trait Resolver { /// This should only return `None` during testing. fn definitions(&mut self) -> &mut Definitions; - /// Given suffix ["b","c","d"], returns path `::cratename::b::c::d` when - /// The path is also resolved according to `is_value`. - fn std_path(&mut self, span: Span, crate_root: Option<&str>, + /// Given suffix ["b","c","d"], creates a HIR path for `[::crate_root]::b::c::d` and resolves + /// it based on `is_value`. + fn resolve_str_path(&mut self, span: Span, crate_root: Option<&str>, components: &[&str], is_value: bool) -> hir::Path { let mut path = hir::Path { span, @@ -3641,7 +3641,7 @@ fn pat(&mut self, span: Span, pat: hir::PatKind) -> P { /// `fld.cx.use_std`, and `::core::b::c::d` otherwise. /// The path is also resolved according to `is_value`. fn std_path(&mut self, span: Span, components: &[&str], is_value: bool) -> hir::Path { - self.resolver.std_path(span, self.crate_root, components, is_value) + self.resolver.resolve_str_path(span, self.crate_root, components, is_value) } fn signal_block_expr(&mut self, diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 31e7b361799..b2897bd4548 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -576,8 +576,8 @@ pub struct InnerExpansionResult<'a> { /// standard library and prelude, and name resolution. /// /// Returns `None` if we're aborting after handling -W help. -pub fn phase_2_configure_and_expand<'a, F>(sess: &'a Session, - cstore: &'a CStore, +pub fn phase_2_configure_and_expand(sess: &Session, + cstore: &CStore, krate: ast::Crate, registry: Option, crate_name: &str, @@ -593,8 +593,9 @@ pub fn phase_2_configure_and_expand<'a, F>(sess: &'a Session, // this back at some point. let mut crate_loader = CrateLoader::new(sess, &cstore, &crate_name); let resolver_arenas = Resolver::arenas(); - let result = phase_2_configure_and_expand_inner(sess, cstore, krate, registry, crate_name, addl_plugins, - make_glob_map, &resolver_arenas, &mut crate_loader, after_expand); + let result = phase_2_configure_and_expand_inner(sess, cstore, krate, registry, crate_name, + addl_plugins, make_glob_map, &resolver_arenas, + &mut crate_loader, after_expand); match result { Ok(InnerExpansionResult {expanded_crate, resolver, hir_forest}) => { Ok(ExpansionResult { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index c91be9ad7b8..ed072331847 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -127,7 +127,7 @@ pub struct Crate { pub masked_crates: FxHashSet, } -impl<'a, 'b, 'tcx, 'rcx> Clean for visit_ast::RustdocVisitor<'a, 'b, 'tcx, 'rcx> { +impl<'a, 'tcx, 'rcx> Clean for visit_ast::RustdocVisitor<'a, 'tcx, 'rcx> { fn clean(&self, cx: &DocContext) -> Crate { use ::visit_lib::LibEmbargoVisitor; @@ -836,11 +836,11 @@ fn clean(&self, cx: &DocContext) -> Attributes { } let path = { - // This allocation could be avoided if std_path could take an iterator; + // This allocation could be avoided if resolve_str_path could take an iterator; // but it can't because that would break object safety. This can still be // fixed. let components = link.split("::").skip(1).collect::>(); - cx.resolver.borrow_mut().std_path(DUMMY_SP, None, &components, false) + cx.resolver.borrow_mut().resolve_str_path(DUMMY_SP, None, &components, false) }; if path.def != Def::Err { diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 9e875a7c280..86657aa000b 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -269,7 +269,8 @@ impl<'a, 'b, I: Iterator>> Iterator for LinkReplacer<'a, 'b, I> fn next(&mut self) -> Option { let event = self.inner.next(); if let Some(Event::Start(Tag::Link(dest, text))) = event { - if let Some(&(_, ref replace)) = self.links.into_iter().find(|link| &*link.0 == &*dest) { + if let Some(&(_, ref replace)) = self.links.into_iter().find(|link| &*link.0 == &*dest) + { Some(Event::Start(Tag::Link(replace.to_owned().into(), text))) } else { Some(Event::Start(Tag::Link(dest, text))) @@ -1045,7 +1046,11 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { let mut s = String::with_capacity(md.len() * 3 / 2); html::push_html(&mut s, - Footnotes::new(CodeBlocks::new(LinkReplacer::new(HeadingLinks::new(p, None), links)))); + Footnotes::new( + CodeBlocks::new( + LinkReplacer::new( + HeadingLinks::new(p, None), + links)))); fmt.write_str(&s) } @@ -1233,6 +1238,7 @@ pub fn markdown_links(md: &str, render_type: RenderType) -> Vec { hoedown_document_free(document); hoedown_html_renderer_free(renderer); + hoedown_buffer_free(ob); opaque.links.unwrap() } diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 52200f5afd7..5dea05cedbe 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1867,7 +1867,8 @@ fn render_markdown(w: &mut fmt::Formatter, prefix: &str, scx: &SharedContext) -> fmt::Result { - let (hoedown_output, pulldown_output) = render_text(|ty| format!("{}", Markdown(md_text, &links, ty))); + let (hoedown_output, pulldown_output) = + render_text(|ty| format!("{}", Markdown(md_text, &links, ty))); let mut differences = html_diff::get_differences(&pulldown_output, &hoedown_output); differences.retain(|s| { match *s { @@ -1899,7 +1900,13 @@ fn document_short(w: &mut fmt::Formatter, item: &clean::Item, link: AssocItemLin } else { format!("{}", &plain_summary_line(Some(s))) }; - render_markdown(w, &markdown, item.links(), item.source.clone(), cx.render_type, prefix, &cx.shared)?; + render_markdown(w, + &markdown, + item.links(), + item.source.clone(), + cx.render_type, + prefix, + &cx.shared)?; } else if !prefix.is_empty() { write!(w, "
{}
", prefix)?; } @@ -1925,7 +1932,13 @@ fn document_full(w: &mut fmt::Formatter, item: &clean::Item, cx: &Context, prefix: &str) -> fmt::Result { if let Some(s) = cx.shared.maybe_collapsed_doc_value(item) { debug!("Doc block: =====\n{}\n=====", s); - render_markdown(w, &*s, item.links(), item.source.clone(), cx.render_type, prefix, &cx.shared)?; + render_markdown(w, + &*s, + item.links(), + item.source.clone(), + cx.render_type, + prefix, + &cx.shared)?; } else if !prefix.is_empty() { write!(w, "
{}
", prefix)?; } @@ -3339,7 +3352,8 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi write!(w, "")?; write!(w, "\n")?; if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) { - write!(w, "
{}
", Markdown(&*dox, &i.impl_item.links(), cx.render_type))?; + write!(w, "
{}
", + Markdown(&*dox, &i.impl_item.links(), cx.render_type))?; } } diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 5206c3667b0..01c2a5620da 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -12,7 +12,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/")] - +#![deny(warnings)] #![feature(ascii_ctype)] #![feature(rustc_private)] diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index d2f7da29b33..7b208465369 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -40,11 +40,11 @@ // also, is there some reason that this doesn't use the 'visit' // framework from syntax? -pub struct RustdocVisitor<'a, 'b: 'a, 'tcx: 'b, 'rcx: 'b> { +pub struct RustdocVisitor<'a, 'tcx: 'a, 'rcx: 'a> { cstore: &'a CrateStore, pub module: Module, pub attrs: hir::HirVec, - pub cx: &'a core::DocContext<'b, 'tcx, 'rcx>, + pub cx: &'a core::DocContext<'a, 'tcx, 'rcx>, view_item_stack: FxHashSet, inlining: bool, /// Is the current module and all of its parents public? @@ -52,9 +52,9 @@ pub struct RustdocVisitor<'a, 'b: 'a, 'tcx: 'b, 'rcx: 'b> { reexported_macros: FxHashSet, } -impl<'a, 'b, 'tcx, 'rcx> RustdocVisitor<'a, 'b, 'tcx, 'rcx> { +impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> { pub fn new(cstore: &'a CrateStore, - cx: &'a core::DocContext<'b, 'tcx, 'rcx>) -> RustdocVisitor<'a, 'b, 'tcx, 'rcx> { + cx: &'a core::DocContext<'a, 'tcx, 'rcx>) -> RustdocVisitor<'a, 'tcx, 'rcx> { // If the root is re-exported, terminate all recursion. let mut stack = FxHashSet(); stack.insert(ast::CRATE_NODE_ID); diff --git a/src/librustdoc/visit_lib.rs b/src/librustdoc/visit_lib.rs index 55f3fdefd1b..15a8b58d0f6 100644 --- a/src/librustdoc/visit_lib.rs +++ b/src/librustdoc/visit_lib.rs @@ -22,8 +22,8 @@ /// Similar to `librustc_privacy::EmbargoVisitor`, but also takes /// specific rustdoc annotations into account (i.e. `doc(hidden)`) -pub struct LibEmbargoVisitor<'a, 'b: 'a, 'tcx: 'b, 'rcx: 'b> { - cx: &'a ::core::DocContext<'b, 'tcx, 'rcx>, +pub struct LibEmbargoVisitor<'a, 'tcx: 'a, 'rcx: 'a> { + cx: &'a ::core::DocContext<'a, 'tcx, 'rcx>, // Accessibility levels for reachable nodes access_levels: RefMut<'a, AccessLevels>, // Previous accessibility level, None means unreachable @@ -32,8 +32,8 @@ pub struct LibEmbargoVisitor<'a, 'b: 'a, 'tcx: 'b, 'rcx: 'b> { visited_mods: FxHashSet, } -impl<'a, 'b, 'tcx, 'rcx> LibEmbargoVisitor<'a, 'b, 'tcx, 'rcx> { - pub fn new(cx: &'a ::core::DocContext<'b, 'tcx, 'rcx>) -> LibEmbargoVisitor<'a, 'b, 'tcx, 'rcx> { +impl<'a, 'tcx, 'rcx> LibEmbargoVisitor<'a, 'tcx, 'rcx> { + pub fn new(cx: &'a ::core::DocContext<'a, 'tcx, 'rcx>) -> LibEmbargoVisitor<'a, 'tcx, 'rcx> { LibEmbargoVisitor { cx, access_levels: cx.access_levels.borrow_mut(), -- 2.44.0