summaryrefslogtreecommitdiffstats
path: root/src/librustdoc/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/librustdoc/lib.rs87
1 files changed, 42 insertions, 45 deletions
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index 14d695582..4cf9435d9 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -9,14 +9,12 @@
#![feature(control_flow_enum)]
#![feature(drain_filter)]
#![feature(let_chains)]
-#![cfg_attr(bootstrap, feature(let_else))]
#![feature(test)]
#![feature(never_type)]
#![feature(once_cell)]
#![feature(type_ascription)]
#![feature(iter_intersperse)]
#![feature(type_alias_impl_trait)]
-#![cfg_attr(bootstrap, feature(generic_associated_types))]
#![recursion_limit = "256"]
#![warn(rustc::internal)]
#![allow(clippy::collapsible_if, clippy::collapsible_else_if)]
@@ -43,6 +41,7 @@ extern crate rustc_errors;
extern crate rustc_expand;
extern crate rustc_feature;
extern crate rustc_hir;
+extern crate rustc_hir_analysis;
extern crate rustc_hir_pretty;
extern crate rustc_index;
extern crate rustc_infer;
@@ -61,7 +60,6 @@ extern crate rustc_session;
extern crate rustc_span;
extern crate rustc_target;
extern crate rustc_trait_selection;
-extern crate rustc_typeck;
extern crate test;
// See docs in https://github.com/rust-lang/rust/blob/master/compiler/rustc/src/main.rs
@@ -156,7 +154,6 @@ pub fn main() {
}
}
- rustc_driver::set_sigpipe_handler();
rustc_driver::install_ice_hook();
// When using CI artifacts (with `download_stage1 = true`), tracing is unconditionally built
@@ -461,7 +458,7 @@ fn opts() -> Vec<RustcOptGroup> {
"human|json|short",
)
}),
- unstable("diagnostic-width", |o| {
+ stable("diagnostic-width", |o| {
o.optopt(
"",
"diagnostic-width",
@@ -676,39 +673,6 @@ fn usage(argv0: &str) {
/// A result type used by several functions under `main()`.
type MainResult = Result<(), ErrorGuaranteed>;
-fn main_args(at_args: &[String]) -> MainResult {
- let args = rustc_driver::args::arg_expand_all(at_args);
-
- let mut options = getopts::Options::new();
- for option in opts() {
- (option.apply)(&mut options);
- }
- let matches = match options.parse(&args[1..]) {
- Ok(m) => m,
- Err(err) => {
- early_error(ErrorOutputType::default(), &err.to_string());
- }
- };
-
- // Note that we discard any distinction between different non-zero exit
- // codes from `from_matches` here.
- let options = match config::Options::from_matches(&matches, args) {
- Ok(opts) => opts,
- Err(code) => {
- return if code == 0 {
- Ok(())
- } else {
- Err(ErrorGuaranteed::unchecked_claim_error_was_emitted())
- };
- }
- };
- rustc_interface::util::run_in_thread_pool_with_globals(
- options.edition,
- 1, // this runs single-threaded, even in a parallel compiler
- move || main_options(options),
- )
-}
-
fn wrap_return(diag: &rustc_errors::Handler, res: Result<(), String>) -> MainResult {
match res {
Ok(()) => Ok(()),
@@ -739,7 +703,33 @@ fn run_renderer<'tcx, T: formats::FormatRenderer<'tcx>>(
}
}
-fn main_options(options: config::Options) -> MainResult {
+fn main_args(at_args: &[String]) -> MainResult {
+ let args = rustc_driver::args::arg_expand_all(at_args);
+
+ let mut options = getopts::Options::new();
+ for option in opts() {
+ (option.apply)(&mut options);
+ }
+ let matches = match options.parse(&args[1..]) {
+ Ok(m) => m,
+ Err(err) => {
+ early_error(ErrorOutputType::default(), &err.to_string());
+ }
+ };
+
+ // Note that we discard any distinction between different non-zero exit
+ // codes from `from_matches` here.
+ let (options, render_options) = match config::Options::from_matches(&matches, args) {
+ Ok(opts) => opts,
+ Err(code) => {
+ return if code == 0 {
+ Ok(())
+ } else {
+ Err(ErrorGuaranteed::unchecked_claim_error_was_emitted())
+ };
+ }
+ };
+
let diag = core::new_handler(
options.error_format,
None,
@@ -751,9 +741,18 @@ fn main_options(options: config::Options) -> MainResult {
(true, true) => return wrap_return(&diag, markdown::test(options)),
(true, false) => return doctest::run(options),
(false, true) => {
+ let input = options.input.clone();
+ let edition = options.edition;
+ let config = core::create_config(options);
+
+ // `markdown::render` can invoke `doctest::make_test`, which
+ // requires session globals and a thread pool, so we use
+ // `run_compiler`.
return wrap_return(
&diag,
- markdown::render(&options.input, options.render_options, options.edition),
+ interface::run_compiler(config, |_compiler| {
+ markdown::render(&input, render_options, edition)
+ }),
);
}
(false, false) => {}
@@ -774,14 +773,12 @@ fn main_options(options: config::Options) -> MainResult {
let crate_version = options.crate_version.clone();
let output_format = options.output_format;
- // FIXME: fix this clone (especially render_options)
let externs = options.externs.clone();
- let render_options = options.render_options.clone();
let scrape_examples_options = options.scrape_examples_options.clone();
- let document_private = options.render_options.document_private;
+
let config = core::create_config(options);
- interface::create_compiler_and_run(config, |compiler| {
+ interface::run_compiler(config, |compiler| {
let sess = compiler.session();
if sess.opts.describe_lints {
@@ -813,7 +810,7 @@ fn main_options(options: config::Options) -> MainResult {
sess,
krate,
externs,
- document_private,
+ render_options.document_private,
)
});
(resolver.clone(), resolver_caches)