diff options
Diffstat (limited to 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/core.rs | 22 | ||||
| -rw-r--r-- | src/librustdoc/html/render.rs | 4 | ||||
| -rw-r--r-- | src/librustdoc/lib.rs | 59 | ||||
| -rw-r--r-- | src/librustdoc/test.rs | 6 |
4 files changed, 43 insertions, 48 deletions
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index db98ec5d0a7..a222920c7d2 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -225,7 +225,7 @@ pub fn new_handler( /// * Vector of tuples of lints' name and their associated "max" level /// * HashMap of lint id with their associated "max" level pub fn init_lints<F>( - mut whitelisted_lints: Vec<String>, + mut allowed_lints: Vec<String>, lint_opts: Vec<(String, lint::Level)>, filter_call: F, ) -> (Vec<(String, lint::Level)>, FxHashMap<lint::LintId, lint::Level>) @@ -234,8 +234,8 @@ where { let warnings_lint_name = lint::builtin::WARNINGS.name; - whitelisted_lints.push(warnings_lint_name.to_owned()); - whitelisted_lints.extend(lint_opts.iter().map(|(lint, _)| lint).cloned()); + allowed_lints.push(warnings_lint_name.to_owned()); + allowed_lints.extend(lint_opts.iter().map(|(lint, _)| lint).cloned()); let lints = || { lint::builtin::HardwiredLints::get_lints() @@ -245,7 +245,7 @@ where let lint_opts = lints() .filter_map(|lint| { - // Whitelist feature-gated lints to avoid feature errors when trying to + // Permit feature-gated lints to avoid feature errors when trying to // allow all lints. if lint.name == warnings_lint_name || lint.feature_gate.is_some() { None @@ -258,9 +258,9 @@ where let lint_caps = lints() .filter_map(|lint| { - // We don't want to whitelist *all* lints so let's - // ignore those ones. - if whitelisted_lints.iter().any(|l| lint.name == l) { + // We don't want to allow *all* lints so let's ignore + // those ones. + if allowed_lints.iter().any(|l| lint.name == l) { None } else { Some((lint::LintId::of(lint), lint::Allow)) @@ -317,9 +317,9 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt let no_crate_level_docs = rustc_lint::builtin::MISSING_CRATE_LEVEL_DOCS.name; let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name; - // In addition to those specific lints, we also need to whitelist those given through + // In addition to those specific lints, we also need to allow those given through // command line, otherwise they'll get ignored and we don't want that. - let whitelisted_lints = vec![ + let allowed_lints = vec![ intra_link_resolution_failure_name.to_owned(), missing_docs.to_owned(), missing_doc_example.to_owned(), @@ -328,7 +328,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt invalid_codeblock_attribute_name.to_owned(), ]; - let (lint_opts, lint_caps) = init_lints(whitelisted_lints, lint_opts, |lint| { + let (lint_opts, lint_caps) = init_lints(allowed_lints, lint_opts, |lint| { if lint.name == intra_link_resolution_failure_name || lint.name == invalid_codeblock_attribute_name { @@ -376,7 +376,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt registry: rustc_driver::diagnostics_registry(), }; - interface::run_compiler_in_existing_thread_pool(config, |compiler| { + interface::create_compiler_and_run(config, |compiler| { compiler.enter(|queries| { let sess = compiler.session(); diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index f769a0920d1..8bba21a2e7a 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -3151,7 +3151,7 @@ fn item_enum(w: &mut Buffer, cx: &Context, it: &clean::Item, e: &clean::Enum) { render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All) } -const ATTRIBUTE_WHITELIST: &[Symbol] = &[ +const ALLOWED_ATTRIBUTES: &[Symbol] = &[ sym::export_name, sym::lang, sym::link_section, @@ -3173,7 +3173,7 @@ fn render_attributes(w: &mut Buffer, it: &clean::Item, top: bool) { let mut attrs = String::new(); for attr in &it.attrs.other_attrs { - if !ATTRIBUTE_WHITELIST.contains(&attr.name_or_empty()) { + if !ALLOWED_ATTRIBUTES.contains(&attr.name_or_empty()) { continue; } diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 8e2dd77cc11..57151e2b200 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -437,7 +437,10 @@ fn main_args(args: &[String]) -> i32 { Ok(opts) => opts, Err(code) => return code, }; - rustc_interface::interface::default_thread_pool(options.edition, move || main_options(options)) + rustc_interface::interface::setup_callbacks_and_run_in_default_thread_pool_with_globals( + options.edition, + move || main_options(options), + ) } fn wrap_return(diag: &rustc_errors::Handler, res: Result<(), String>) -> i32 { @@ -471,7 +474,29 @@ fn main_options(options: config::Options) -> i32 { // but we can't crates the Handler ahead of time because it's not Send let diag_opts = (options.error_format, options.edition, options.debugging_options.clone()); let show_coverage = options.show_coverage; - rust_input(options, move |out| { + + // First, parse the crate and extract all relevant information. + info!("starting to run rustc"); + + // Interpret the input file as a rust source file, passing it through the + // compiler all the way through the analysis passes. The rustdoc output is + // then generated from the cleaned AST of the crate. This runs all the + // plug/cleaning passes. + let result = rustc_driver::catch_fatal_errors(move || { + let crate_name = options.crate_name.clone(); + let crate_version = options.crate_version.clone(); + let (mut krate, renderinfo, renderopts) = core::run_core(options); + + info!("finished with rustc"); + + if let Some(name) = crate_name { + krate.name = name + } + + krate.version = crate_version; + + let out = Output { krate, renderinfo, renderopts }; + if show_coverage { // if we ran coverage, bail early, we don't need to also generate docs at this point // (also we didn't load in any of the useful passes) @@ -491,36 +516,6 @@ fn main_options(options: config::Options) -> i32 { rustc_driver::EXIT_FAILURE } } - }) -} - -/// Interprets the input file as a rust source file, passing it through the -/// compiler all the way through the analysis passes. The rustdoc output is then -/// generated from the cleaned AST of the crate. -/// -/// This form of input will run all of the plug/cleaning passes -fn rust_input<R, F>(options: config::Options, f: F) -> R -where - R: 'static + Send, - F: 'static + Send + FnOnce(Output) -> R, -{ - // First, parse the crate and extract all relevant information. - info!("starting to run rustc"); - - let result = rustc_driver::catch_fatal_errors(move || { - let crate_name = options.crate_name.clone(); - let crate_version = options.crate_version.clone(); - let (mut krate, renderinfo, renderopts) = core::run_core(options); - - info!("finished with rustc"); - - if let Some(name) = crate_name { - krate.name = name - } - - krate.version = crate_version; - - f(Output { krate, renderinfo, renderopts }) }); match result { diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index b40a5ef5950..c2d644bdd05 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -47,11 +47,11 @@ pub fn run(options: Options) -> Result<(), String> { let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name; - // In addition to those specific lints, we also need to whitelist those given through + // In addition to those specific lints, we also need to allow those given through // command line, otherwise they'll get ignored and we don't want that. - let whitelisted_lints = vec![invalid_codeblock_attribute_name.to_owned()]; + let allowed_lints = vec![invalid_codeblock_attribute_name.to_owned()]; - let (lint_opts, lint_caps) = init_lints(whitelisted_lints, options.lint_opts.clone(), |lint| { + let (lint_opts, lint_caps) = init_lints(allowed_lints, options.lint_opts.clone(), |lint| { if lint.name == invalid_codeblock_attribute_name { None } else { |
