From 86d2ba4f591fc26aa1c67da9ffea4de750f0acfd Mon Sep 17 00:00:00 2001 From: steveklabnik Date: Wed, 11 Jul 2018 09:08:27 -0400 Subject: [PATCH 1/2] remove pluginmanager --- src/librustdoc/lib.rs | 21 +++++----- src/librustdoc/passes/collapse_docs.rs | 3 +- src/librustdoc/passes/mod.rs | 3 +- src/librustdoc/passes/propagate_doc_cfg.rs | 3 +- src/librustdoc/passes/strip_hidden.rs | 3 +- src/librustdoc/passes/strip_priv_imports.rs | 3 +- src/librustdoc/passes/strip_private.rs | 3 +- src/librustdoc/passes/unindent_comments.rs | 3 +- src/librustdoc/plugins.rs | 45 --------------------- 9 files changed, 18 insertions(+), 69 deletions(-) delete mode 100644 src/librustdoc/plugins.rs diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index ae64c6f1bfd7f..be7ab8804b091 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -90,7 +90,6 @@ pub mod html { } pub mod markdown; pub mod passes; -pub mod plugins; pub mod visit_ast; pub mod visit_lib; pub mod test; @@ -750,25 +749,27 @@ where R: 'static + Send, eprintln!("WARNING: --plugin-path no longer functions; see CVE-2018-1000622"); } - // Load all plugins/passes into a PluginManager - let mut pm = plugins::PluginManager::new(); + info!("Executing passes"); + for pass in &passes { - let plugin = match passes::PASSES.iter() + // determine if we know about this pass + let pass = match passes::PASSES.iter().find(|(p, ..)| p == pass) { + /* .position(|&(p, ..)| { p == *pass }) { - Some(i) => passes::PASSES[i].1, + */ + Some(pass) => pass.1, None => { error!("unknown pass {}, skipping", *pass); + continue }, }; - pm.add_plugin(plugin); - } - // Run everything! - info!("Executing passes/plugins"); - let krate = pm.run_plugins(krate); + // run it + krate = pass(krate); + } tx.send(f(Output { krate: krate, renderinfo: renderinfo, passes: passes })).unwrap(); })); diff --git a/src/librustdoc/passes/collapse_docs.rs b/src/librustdoc/passes/collapse_docs.rs index a2d651d29de93..6f70fcf1099e6 100644 --- a/src/librustdoc/passes/collapse_docs.rs +++ b/src/librustdoc/passes/collapse_docs.rs @@ -9,7 +9,6 @@ // except according to those terms. use clean::{self, DocFragment, Item}; -use plugins; use fold; use fold::DocFolder; use std::mem::replace; @@ -31,7 +30,7 @@ impl DocFragment { } } -pub fn collapse_docs(krate: clean::Crate) -> plugins::PluginResult { +pub fn collapse_docs(krate: clean::Crate) -> clean::Crate { Collapser.fold_crate(krate) } diff --git a/src/librustdoc/passes/mod.rs b/src/librustdoc/passes/mod.rs index 699ee25436a10..63b74ceafacb4 100644 --- a/src/librustdoc/passes/mod.rs +++ b/src/librustdoc/passes/mod.rs @@ -16,7 +16,6 @@ use std::mem; use clean::{self, GetDefId, Item}; use fold; use fold::FoldItem::Strip; -use plugins; mod collapse_docs; pub use self::collapse_docs::collapse_docs; @@ -37,7 +36,7 @@ mod propagate_doc_cfg; pub use self::propagate_doc_cfg::propagate_doc_cfg; type Pass = (&'static str, // name - fn(clean::Crate) -> plugins::PluginResult, // fn + fn(clean::Crate) -> clean::Crate, // fn &'static str); // description pub const PASSES: &'static [Pass] = &[ diff --git a/src/librustdoc/passes/propagate_doc_cfg.rs b/src/librustdoc/passes/propagate_doc_cfg.rs index fc8abafd4d89b..572a8d3f470f2 100644 --- a/src/librustdoc/passes/propagate_doc_cfg.rs +++ b/src/librustdoc/passes/propagate_doc_cfg.rs @@ -13,9 +13,8 @@ use std::sync::Arc; use clean::{Crate, Item}; use clean::cfg::Cfg; use fold::DocFolder; -use plugins::PluginResult; -pub fn propagate_doc_cfg(cr: Crate) -> PluginResult { +pub fn propagate_doc_cfg(cr: Crate) -> Crate { CfgPropagator { parent_cfg: None }.fold_crate(cr) } diff --git a/src/librustdoc/passes/strip_hidden.rs b/src/librustdoc/passes/strip_hidden.rs index 68c1231fc6f7c..b1545233f8a2b 100644 --- a/src/librustdoc/passes/strip_hidden.rs +++ b/src/librustdoc/passes/strip_hidden.rs @@ -13,14 +13,13 @@ use std::mem; use clean::{self, AttributesExt, NestedAttributesExt}; use clean::Item; -use plugins; use fold; use fold::DocFolder; use fold::FoldItem::Strip; use passes::ImplStripper; /// Strip items marked `#[doc(hidden)]` -pub fn strip_hidden(krate: clean::Crate) -> plugins::PluginResult { +pub fn strip_hidden(krate: clean::Crate) -> clean::Crate { let mut retained = DefIdSet(); // strip all #[doc(hidden)] items diff --git a/src/librustdoc/passes/strip_priv_imports.rs b/src/librustdoc/passes/strip_priv_imports.rs index 91f8be43c281a..c4640839923bd 100644 --- a/src/librustdoc/passes/strip_priv_imports.rs +++ b/src/librustdoc/passes/strip_priv_imports.rs @@ -10,9 +10,8 @@ use clean; use fold::DocFolder; -use plugins; use passes::ImportStripper; -pub fn strip_priv_imports(krate: clean::Crate) -> plugins::PluginResult { +pub fn strip_priv_imports(krate: clean::Crate) -> clean::Crate { ImportStripper.fold_crate(krate) } diff --git a/src/librustdoc/passes/strip_private.rs b/src/librustdoc/passes/strip_private.rs index acd735739e488..45f706590e32e 100644 --- a/src/librustdoc/passes/strip_private.rs +++ b/src/librustdoc/passes/strip_private.rs @@ -11,13 +11,12 @@ use rustc::util::nodemap::DefIdSet; use clean; -use plugins; use fold::DocFolder; use passes::{ImplStripper, ImportStripper, Stripper}; /// Strip private items from the point of view of a crate or externally from a /// crate, specified by the `xcrate` flag. -pub fn strip_private(mut krate: clean::Crate) -> plugins::PluginResult { +pub fn strip_private(mut krate: clean::Crate) -> clean::Crate { // This stripper collects all *retained* nodes. let mut retained = DefIdSet(); let access_levels = krate.access_levels.clone(); diff --git a/src/librustdoc/passes/unindent_comments.rs b/src/librustdoc/passes/unindent_comments.rs index 912c7646a06e5..2510ec011b64c 100644 --- a/src/librustdoc/passes/unindent_comments.rs +++ b/src/librustdoc/passes/unindent_comments.rs @@ -13,10 +13,9 @@ use std::string::String; use std::usize; use clean::{self, DocFragment, Item}; -use plugins; use fold::{self, DocFolder}; -pub fn unindent_comments(krate: clean::Crate) -> plugins::PluginResult { +pub fn unindent_comments(krate: clean::Crate) -> clean::Crate { CommentCleaner.fold_crate(krate) } diff --git a/src/librustdoc/plugins.rs b/src/librustdoc/plugins.rs deleted file mode 100644 index 261ff728aef60..0000000000000 --- a/src/librustdoc/plugins.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(deprecated)] - -use clean; - -pub type PluginResult = clean::Crate; -pub type PluginCallback = fn (clean::Crate) -> PluginResult; - -/// Manages loading and running of plugins -pub struct PluginManager { - callbacks: Vec , -} - -impl PluginManager { - /// Create a new plugin manager - pub fn new() -> PluginManager { - PluginManager { - callbacks: Vec::new(), - } - } - - /// Load a normal Rust function as a plugin. - /// - /// This is to run passes over the cleaned crate. Plugins run this way - /// correspond to the A-aux tag on Github. - pub fn add_plugin(&mut self, plugin: PluginCallback) { - self.callbacks.push(plugin); - } - /// Run all the loaded plugins over the crate, returning their results - pub fn run_plugins(&self, mut krate: clean::Crate) -> clean::Crate { - for &callback in &self.callbacks { - krate = callback(krate); - } - krate - } -} From 0bf2a06bc0c96efbb7ba0c6594cb8fddd5f69995 Mon Sep 17 00:00:00 2001 From: steveklabnik Date: Mon, 23 Jul 2018 09:19:30 -0400 Subject: [PATCH 2/2] remove zombie code --- src/librustdoc/lib.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index be7ab8804b091..9ebefdabbb410 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -754,11 +754,6 @@ where R: 'static + Send, for pass in &passes { // determine if we know about this pass let pass = match passes::PASSES.iter().find(|(p, ..)| p == pass) { - /* - .position(|&(p, ..)| { - p == *pass - }) { - */ Some(pass) => pass.1, None => { error!("unknown pass {}, skipping", *pass);