Skip to content

Commit 108be3c

Browse files
Rollup merge of rust-lang#54205 - GuillaumeGomez:treat-err-as-bug, r=QuietMisdreavus
Add treat-err-as-bug flag in rustdoc cc @nikomatsakis r? @QuietMisdreavus
2 parents 6aed133 + 818938f commit 108be3c

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

src/librustdoc/core.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,10 @@ impl DocAccessLevels for AccessLevels<DefId> {
260260
///
261261
/// If the given `error_format` is `ErrorOutputType::Json` and no `SourceMap` is given, a new one
262262
/// will be created for the handler.
263-
pub fn new_handler(error_format: ErrorOutputType, source_map: Option<Lrc<source_map::SourceMap>>)
264-
-> errors::Handler
265-
{
263+
pub fn new_handler(error_format: ErrorOutputType,
264+
source_map: Option<Lrc<source_map::SourceMap>>,
265+
treat_err_as_bug: bool,
266+
) -> errors::Handler {
266267
// rustdoc doesn't override (or allow to override) anything from this that is relevant here, so
267268
// stick to the defaults
268269
let sessopts = Options::default();
@@ -299,7 +300,7 @@ pub fn new_handler(error_format: ErrorOutputType, source_map: Option<Lrc<source_
299300
emitter,
300301
errors::HandlerFlags {
301302
can_emit_warnings: true,
302-
treat_err_as_bug: false,
303+
treat_err_as_bug,
303304
report_delayed_bugs: false,
304305
external_macro_backtrace: false,
305306
..Default::default()
@@ -323,9 +324,9 @@ pub fn run_core(search_paths: SearchPaths,
323324
lint_cap: Option<lint::Level>,
324325
describe_lints: bool,
325326
mut manual_passes: Vec<String>,
326-
mut default_passes: passes::DefaultPassOption)
327-
-> (clean::Crate, RenderInfo, Vec<String>)
328-
{
327+
mut default_passes: passes::DefaultPassOption,
328+
treat_err_as_bug: bool,
329+
) -> (clean::Crate, RenderInfo, Vec<String>) {
329330
// Parse, resolve, and typecheck the given crate.
330331

331332
let cpath = match input {
@@ -388,7 +389,9 @@ pub fn run_core(search_paths: SearchPaths,
388389
};
389390
driver::spawn_thread_pool(sessopts, move |sessopts| {
390391
let source_map = Lrc::new(source_map::SourceMap::new(sessopts.file_path_mapping()));
391-
let diagnostic_handler = new_handler(error_format, Some(source_map.clone()));
392+
let diagnostic_handler = new_handler(error_format,
393+
Some(source_map.clone()),
394+
treat_err_as_bug);
392395

393396
let mut sess = session::build_session_(
394397
sessopts, cpath, diagnostic_handler, source_map,

src/librustdoc/lib.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,11 @@ fn main_args(args: &[String]) -> isize {
404404
`short` (instead was `{}`)", arg));
405405
}
406406
};
407+
let treat_err_as_bug = matches.opt_strs("Z").iter().any(|x| {
408+
*x == "treat-err-as-bug"
409+
});
407410

408-
let diag = core::new_handler(error_format, None);
411+
let diag = core::new_handler(error_format, None, treat_err_as_bug);
409412

410413
// check for deprecated options
411414
check_deprecated_options(&matches, &diag);
@@ -560,7 +563,7 @@ fn main_args(args: &[String]) -> isize {
560563
let res = acquire_input(PathBuf::from(input), externs, edition, cg, &matches, error_format,
561564
move |out| {
562565
let Output { krate, passes, renderinfo } = out;
563-
let diag = core::new_handler(error_format, None);
566+
let diag = core::new_handler(error_format, None, treat_err_as_bug);
564567
info!("going to format");
565568
match output_format.as_ref().map(|s| &**s) {
566569
Some("html") | None => {
@@ -694,6 +697,9 @@ where R: 'static + Send,
694697
let force_unstable_if_unmarked = matches.opt_strs("Z").iter().any(|x| {
695698
*x == "force-unstable-if-unmarked"
696699
});
700+
let treat_err_as_bug = matches.opt_strs("Z").iter().any(|x| {
701+
*x == "treat-err-as-bug"
702+
});
697703

698704
let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
699705

@@ -706,7 +712,8 @@ where R: 'static + Send,
706712
core::run_core(paths, cfgs, externs, Input::File(cratefile), triple, maybe_sysroot,
707713
display_warnings, crate_name.clone(),
708714
force_unstable_if_unmarked, edition, cg, error_format,
709-
lint_opts, lint_cap, describe_lints, manual_passes, default_passes);
715+
lint_opts, lint_cap, describe_lints, manual_passes, default_passes,
716+
treat_err_as_bug);
710717

711718
info!("finished with rustc");
712719

0 commit comments

Comments
 (0)