]> git.lizzy.rs Git - rust.git/commitdiff
cleanup
authorQuietMisdreavus <grey@quietmisdreavus.net>
Thu, 28 Dec 2017 16:52:40 +0000 (10:52 -0600)
committerManish Goregaokar <manishsmail@gmail.com>
Mon, 22 Jan 2018 09:54:27 +0000 (15:24 +0530)
src/librustc/hir/lowering.rs
src/librustc_driver/driver.rs
src/librustdoc/clean/mod.rs
src/librustdoc/html/markdown.rs
src/librustdoc/html/render.rs
src/librustdoc/lib.rs
src/librustdoc/visit_ast.rs
src/librustdoc/visit_lib.rs

index b7a7fcd9872e0fd9b0f18ec22a45d2cd21b25c5e..f2154f885fa4a22fa05f0493bb422a54ff57cf36 100644 (file)
@@ -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<hir::Pat> {
     /// `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,
index 31e7b3617990fc143a2597281f72209590a4eac7..b2897bd454839cf77ff1f8aaf8334dcd9b2601b7 100644 (file)
@@ -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<F>(sess: &Session,
+                                       cstore: &CStore,
                                        krate: ast::Crate,
                                        registry: Option<Registry>,
                                        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 {
index c91be9ad7b8f4667289e9e253be641cf84202736..ed072331847403d2109681716a6c0ff5f8203456 100644 (file)
@@ -127,7 +127,7 @@ pub struct Crate {
     pub masked_crates: FxHashSet<CrateNum>,
 }
 
-impl<'a, 'b, 'tcx, 'rcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'b, 'tcx, 'rcx> {
+impl<'a, 'tcx, 'rcx> Clean<Crate> 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::<Vec<_>>();
-                    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 {
index 9e875a7c280599758563e764ba6616a5c9e64c0d..86657aa000b0daff87f9aa1d39fdacb998067c95 100644 (file)
@@ -269,7 +269,8 @@ impl<'a, 'b, I: Iterator<Item = Event<'a>>> Iterator for LinkReplacer<'a, 'b, I>
     fn next(&mut self) -> Option<Self::Item> {
         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<String> {
                 hoedown_document_free(document);
 
                 hoedown_html_renderer_free(renderer);
+                hoedown_buffer_free(ob);
 
                 opaque.links.unwrap()
             }
index 52200f5afd79aa826ef91e6116cfac0990242da0..5dea05cedbeaf2d53536bfc3e3e7bb0cab7c5219 100644 (file)
@@ -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, "<div class='docblock'>{}</div>", 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, "<div class='docblock'>{}</div>", prefix)?;
     }
@@ -3339,7 +3352,8 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi
         write!(w, "</span>")?;
         write!(w, "</h3>\n")?;
         if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) {
-            write!(w, "<div class='docblock'>{}</div>", Markdown(&*dox, &i.impl_item.links(), cx.render_type))?;
+            write!(w, "<div class='docblock'>{}</div>",
+                   Markdown(&*dox, &i.impl_item.links(), cx.render_type))?;
         }
     }
 
index 5206c3667b006f4a50598edf93537a9e30de336e..01c2a5620da25af332a813e9b8857f01b3c72f8a 100644 (file)
@@ -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)]
index d2f7da29b33ab1a2b97e3db2ff2c668894fa983a..7b208465369fc128388914aff1245c4618e92122 100644 (file)
 // 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<ast::Attribute>,
-    pub cx: &'a core::DocContext<'b, 'tcx, 'rcx>,
+    pub cx: &'a core::DocContext<'a, 'tcx, 'rcx>,
     view_item_stack: FxHashSet<ast::NodeId>,
     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<DefId>,
 }
 
-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);
index 55f3fdefd1b4193e2fe31a7070d3438dd5c77579..15a8b58d0f6b92297010c63aea500bf6e241ec98 100644 (file)
@@ -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<DefId>>,
     // Previous accessibility level, None means unreachable
@@ -32,8 +32,8 @@ pub struct LibEmbargoVisitor<'a, 'b: 'a, 'tcx: 'b, 'rcx: 'b> {
     visited_mods: FxHashSet<DefId>,
 }
 
-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(),