Add command line lint manipulation in rustdoc

This commit is contained in:
Guillaume Gomez 2018-06-23 15:09:21 +02:00
parent 2ea922a96d
commit e221be89e0
3 changed files with 58 additions and 20 deletions

View file

@ -178,7 +178,10 @@ pub fn run_core(search_paths: SearchPaths,
force_unstable_if_unmarked: bool,
edition: Edition,
cg: CodegenOptions,
error_format: ErrorOutputType) -> (clean::Crate, RenderInfo)
error_format: ErrorOutputType,
cmd_lints: Vec<(String, lint::Level)>,
lint_cap: Option<lint::Level>,
describe_lints: bool) -> (clean::Crate, RenderInfo)
{
// Parse, resolve, and typecheck the given crate.
@ -200,6 +203,7 @@ pub fn run_core(search_paths: SearchPaths,
Some((lint.name_lower(), lint::Allow))
}
})
.chain(cmd_lints.into_iter())
.collect::<Vec<_>>();
let host_triple = TargetTriple::from_triple(config::host_triple());
@ -213,7 +217,7 @@ pub fn run_core(search_paths: SearchPaths,
} else {
vec![]
},
lint_cap: Some(lint::Forbid),
lint_cap: Some(lint_cap.unwrap_or_else(|| lint::Forbid)),
cg,
externs,
target_triple: triple.unwrap_or(host_triple),
@ -226,6 +230,7 @@ pub fn run_core(search_paths: SearchPaths,
},
error_format,
edition,
describe_lints,
..config::basic_options()
};
driver::spawn_thread_pool(sessopts, move |sessopts| {

View file

@ -68,6 +68,7 @@ use rustc::session::search_paths::SearchPaths;
use rustc::session::config::{ErrorOutputType, RustcOptGroup, Externs, CodegenOptions};
use rustc::session::config::{nightly_options, build_codegen_options};
use rustc_target::spec::TargetTriple;
use rustc::session::config::get_cmd_lint_options;
#[macro_use]
pub mod externalfiles;
@ -304,6 +305,28 @@ pub fn opts() -> Vec<RustcOptGroup> {
"disable-minification",
"Disable minification applied on JS files")
}),
unstable("warn", |o| {
o.optmulti("W", "warn", "Set lint warnings", "OPT")
}),
unstable("allow", |o| {
o.optmulti("A", "allow", "Set lint allowed", "OPT")
}),
unstable("deny", |o| {
o.optmulti("D", "deny", "Set lint denied", "OPT")
}),
unstable("forbid", |o| {
o.optmulti("F", "forbid", "Set lint forbidden", "OPT")
}),
unstable("cap-lints", |o| {
o.optmulti(
"",
"cap-lints",
"Set the most restrictive lint level. \
More restrictive lints are capped at this \
level. By default, it is at `forbid` level.",
"LEVEL",
)
}),
]
}
@ -636,6 +659,8 @@ where R: 'static + Send,
*x == "force-unstable-if-unmarked"
});
let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
let (tx, rx) = channel();
rustc_driver::monitor(move || syntax::with_globals(move || {
@ -644,7 +669,8 @@ where R: 'static + Send,
let (mut krate, renderinfo) =
core::run_core(paths, cfgs, externs, Input::File(cratefile), triple, maybe_sysroot,
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);
info!("finished with rustc");