Skip to content

Commit 33df191

Browse files
committed
Enable nightly lints via cli args
1 parent 9e61b0d commit 33df191

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

clippy_dev/src/update_lints.rs

+18
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ fn generate_lint_files(
114114
update_mode,
115115
&gen_deprecated(deprecated_lints),
116116
);
117+
process_file(
118+
"src/main.warn_nightly_args.rs",
119+
update_mode,
120+
&gen_warn_nightly_lints(lints),
121+
);
117122

118123
let all_group_lints = usable_lints.iter().filter(|l| {
119124
matches!(
@@ -780,6 +785,19 @@ fn gen_renamed_lints_list(lints: &[RenamedLint]) -> String {
780785
res
781786
}
782787

788+
fn gen_warn_nightly_lints(lints: &[Lint]) -> String {
789+
let mut res: String = GENERATED_FILE_COMMENT.into();
790+
res.push_str("[\n");
791+
for lint in lints
792+
.iter()
793+
.filter(|l| !l.has_version && !l.group.starts_with("internal"))
794+
{
795+
let _ = write!(res, " \"-W\",\n \"clippy::{}\",\n", lint.name);
796+
}
797+
res.push_str("]\n");
798+
res
799+
}
800+
783801
/// Gathers all lints defined in `clippy_lints/src`
784802
fn gather_all() -> (Vec<Lint>, Vec<DeprecatedLint>, Vec<RenamedLint>) {
785803
let mut lints = Vec::with_capacity(1000);

src/main.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
#![feature(rustc_private)]
12
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
23
// warn on lints, that are included in `rust-lang/rust`s bootstrap
34
#![warn(rust_2018_idioms, unused_lifetimes)]
45

6+
extern crate rustc_session;
7+
8+
use rustc_session::config::nightly_options::is_nightly_build;
59
use rustc_tools_util::VersionInfo;
610
use std::env;
711
use std::path::PathBuf;
@@ -132,6 +136,11 @@ impl ClippyCmd {
132136
.arg(self.cargo_subcommand)
133137
.args(&self.args);
134138

139+
if is_nightly_build(None) {
140+
static ARGS: &[&str] = &include!("main.warn_nightly_args.rs");
141+
cmd.args(ARGS);
142+
}
143+
135144
cmd
136145
}
137146
}

src/main.warn_nightly_args.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// This file was generated by `cargo dev update_lints`.
2+
// Use that command to update this file and do not edit by hand.
3+
// Manual edits will be overwritten.
4+
5+
[
6+
]

0 commit comments

Comments
 (0)