Add treat-err-as-bug flag in rustdoc
This commit is contained in:
parent
6810f5286b
commit
fab6b06b89
4 changed files with 55 additions and 11 deletions
|
@ -260,9 +260,10 @@ impl DocAccessLevels for AccessLevels<DefId> {
|
||||||
///
|
///
|
||||||
/// If the given `error_format` is `ErrorOutputType::Json` and no `SourceMap` is given, a new one
|
/// If the given `error_format` is `ErrorOutputType::Json` and no `SourceMap` is given, a new one
|
||||||
/// will be created for the handler.
|
/// will be created for the handler.
|
||||||
pub fn new_handler(error_format: ErrorOutputType, source_map: Option<Lrc<source_map::SourceMap>>)
|
pub fn new_handler(error_format: ErrorOutputType,
|
||||||
-> errors::Handler
|
source_map: Option<Lrc<source_map::SourceMap>>,
|
||||||
{
|
treat_err_as_bug: bool,
|
||||||
|
) -> errors::Handler {
|
||||||
// rustdoc doesn't override (or allow to override) anything from this that is relevant here, so
|
// rustdoc doesn't override (or allow to override) anything from this that is relevant here, so
|
||||||
// stick to the defaults
|
// stick to the defaults
|
||||||
let sessopts = Options::default();
|
let sessopts = Options::default();
|
||||||
|
@ -299,7 +300,7 @@ pub fn new_handler(error_format: ErrorOutputType, source_map: Option<Lrc<source_
|
||||||
emitter,
|
emitter,
|
||||||
errors::HandlerFlags {
|
errors::HandlerFlags {
|
||||||
can_emit_warnings: true,
|
can_emit_warnings: true,
|
||||||
treat_err_as_bug: false,
|
treat_err_as_bug,
|
||||||
report_delayed_bugs: false,
|
report_delayed_bugs: false,
|
||||||
external_macro_backtrace: false,
|
external_macro_backtrace: false,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -323,9 +324,9 @@ pub fn run_core(search_paths: SearchPaths,
|
||||||
lint_cap: Option<lint::Level>,
|
lint_cap: Option<lint::Level>,
|
||||||
describe_lints: bool,
|
describe_lints: bool,
|
||||||
mut manual_passes: Vec<String>,
|
mut manual_passes: Vec<String>,
|
||||||
mut default_passes: passes::DefaultPassOption)
|
mut default_passes: passes::DefaultPassOption,
|
||||||
-> (clean::Crate, RenderInfo, Vec<String>)
|
treat_err_as_bug: bool,
|
||||||
{
|
) -> (clean::Crate, RenderInfo, Vec<String>) {
|
||||||
// Parse, resolve, and typecheck the given crate.
|
// Parse, resolve, and typecheck the given crate.
|
||||||
|
|
||||||
let cpath = match input {
|
let cpath = match input {
|
||||||
|
@ -388,7 +389,9 @@ pub fn run_core(search_paths: SearchPaths,
|
||||||
};
|
};
|
||||||
driver::spawn_thread_pool(sessopts, move |sessopts| {
|
driver::spawn_thread_pool(sessopts, move |sessopts| {
|
||||||
let source_map = Lrc::new(source_map::SourceMap::new(sessopts.file_path_mapping()));
|
let source_map = Lrc::new(source_map::SourceMap::new(sessopts.file_path_mapping()));
|
||||||
let diagnostic_handler = new_handler(error_format, Some(source_map.clone()));
|
let diagnostic_handler = new_handler(error_format,
|
||||||
|
Some(source_map.clone()),
|
||||||
|
treat_err_as_bug);
|
||||||
|
|
||||||
let mut sess = session::build_session_(
|
let mut sess = session::build_session_(
|
||||||
sessopts, cpath, diagnostic_handler, source_map,
|
sessopts, cpath, diagnostic_handler, source_map,
|
||||||
|
|
|
@ -404,8 +404,11 @@ fn main_args(args: &[String]) -> isize {
|
||||||
`short` (instead was `{}`)", arg));
|
`short` (instead was `{}`)", arg));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
let treat_err_as_bug = matches.opt_strs("Z").iter().any(|x| {
|
||||||
|
*x == "treat-err-as-bug"
|
||||||
|
});
|
||||||
|
|
||||||
let diag = core::new_handler(error_format, None);
|
let diag = core::new_handler(error_format, None, treat_err_as_bug);
|
||||||
|
|
||||||
// check for deprecated options
|
// check for deprecated options
|
||||||
check_deprecated_options(&matches, &diag);
|
check_deprecated_options(&matches, &diag);
|
||||||
|
@ -560,7 +563,7 @@ fn main_args(args: &[String]) -> isize {
|
||||||
let res = acquire_input(PathBuf::from(input), externs, edition, cg, &matches, error_format,
|
let res = acquire_input(PathBuf::from(input), externs, edition, cg, &matches, error_format,
|
||||||
move |out| {
|
move |out| {
|
||||||
let Output { krate, passes, renderinfo } = out;
|
let Output { krate, passes, renderinfo } = out;
|
||||||
let diag = core::new_handler(error_format, None);
|
let diag = core::new_handler(error_format, None, treat_err_as_bug);
|
||||||
info!("going to format");
|
info!("going to format");
|
||||||
match output_format.as_ref().map(|s| &**s) {
|
match output_format.as_ref().map(|s| &**s) {
|
||||||
Some("html") | None => {
|
Some("html") | None => {
|
||||||
|
@ -691,6 +694,9 @@ where R: 'static + Send,
|
||||||
let force_unstable_if_unmarked = matches.opt_strs("Z").iter().any(|x| {
|
let force_unstable_if_unmarked = matches.opt_strs("Z").iter().any(|x| {
|
||||||
*x == "force-unstable-if-unmarked"
|
*x == "force-unstable-if-unmarked"
|
||||||
});
|
});
|
||||||
|
let treat_err_as_bug = matches.opt_strs("Z").iter().any(|x| {
|
||||||
|
*x == "treat-err-as-bug"
|
||||||
|
});
|
||||||
|
|
||||||
let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
|
let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
|
||||||
|
|
||||||
|
@ -703,7 +709,8 @@ where R: 'static + Send,
|
||||||
core::run_core(paths, cfgs, externs, Input::File(cratefile), triple, maybe_sysroot,
|
core::run_core(paths, cfgs, externs, Input::File(cratefile), triple, maybe_sysroot,
|
||||||
display_warnings, crate_name.clone(),
|
display_warnings, crate_name.clone(),
|
||||||
force_unstable_if_unmarked, edition, cg, error_format,
|
force_unstable_if_unmarked, edition, cg, error_format,
|
||||||
lint_opts, lint_cap, describe_lints, manual_passes, default_passes);
|
lint_opts, lint_cap, describe_lints, manual_passes, default_passes,
|
||||||
|
treat_err_as_bug);
|
||||||
|
|
||||||
info!("finished with rustc");
|
info!("finished with rustc");
|
||||||
|
|
||||||
|
|
13
src/test/rustdoc-ui/treat-err-as-bug.rs
Normal file
13
src/test/rustdoc-ui/treat-err-as-bug.rs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright 2013-2014 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 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
// compile-flags: -Ztreat-err-as-bug --error-format=human
|
||||||
|
|
||||||
|
pub fn foo() {
|
21
src/test/rustdoc-ui/treat-err-as-bug.stderr
Normal file
21
src/test/rustdoc-ui/treat-err-as-bug.stderr
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
error: this file contains an un-closed delimiter
|
||||||
|
--> $DIR/treat-err-as-bug.rs:13:16
|
||||||
|
|
|
||||||
|
13 | pub fn foo() {
|
||||||
|
| - ^
|
||||||
|
| |
|
||||||
|
| un-closed delimiter
|
||||||
|
|
||||||
|
thread '<unnamed>' panicked at 'encountered error with `-Z treat_err_as_bug', librustc_errors/lib.rs:486:13
|
||||||
|
note: Run with `RUST_BACKTRACE=1` for a backtrace.
|
||||||
|
|
||||||
|
error: internal compiler error: unexpected panic
|
||||||
|
|
||||||
|
note: the compiler unexpectedly panicked. this is a bug.
|
||||||
|
|
||||||
|
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
|
||||||
|
|
||||||
|
note: rustc 1.30.0-dev running on x86_64-apple-darwin
|
||||||
|
|
||||||
|
note: compiler flags: -Z ui-testing -Z unstable-options -Z treat-err-as-bug
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue