Add `rename_lint` command

This commit is contained in:
Jason Newcomb 2022-04-03 20:28:47 -04:00
parent d5ef542d37
commit b3de32ba3c
8 changed files with 561 additions and 256 deletions

View File

@ -4,6 +4,7 @@ version = "0.0.1"
edition = "2021"
[dependencies]
aho-corasick = "0.7"
clap = "2.33"
indoc = "1.0"
itertools = "0.10.1"

View File

@ -1,3 +1,4 @@
#![feature(let_chains)]
#![feature(let_else)]
#![feature(once_cell)]
#![feature(rustc_private)]

View File

@ -18,9 +18,9 @@ fn main() {
if matches.is_present("print-only") {
update_lints::print_lints();
} else if matches.is_present("check") {
update_lints::run(update_lints::UpdateMode::Check);
update_lints::update(update_lints::UpdateMode::Check);
} else {
update_lints::run(update_lints::UpdateMode::Change);
update_lints::update(update_lints::UpdateMode::Change);
}
},
("new_lint", Some(matches)) => {
@ -30,7 +30,7 @@ fn main() {
matches.value_of("category"),
matches.is_present("msrv"),
) {
Ok(_) => update_lints::run(update_lints::UpdateMode::Change),
Ok(_) => update_lints::update(update_lints::UpdateMode::Change),
Err(e) => eprintln!("Unable to create lint: {}", e),
}
},
@ -59,6 +59,12 @@ fn main() {
let filename = matches.value_of("filename").unwrap();
lint::run(filename);
},
("rename_lint", Some(matches)) => {
let old_name = matches.value_of("old_name").unwrap();
let new_name = matches.value_of("new_name").unwrap_or(old_name);
let uplift = matches.is_present("uplift");
update_lints::rename(old_name, new_name, uplift);
},
_ => {},
}
}
@ -232,5 +238,26 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
.help("The path to a file to lint"),
),
)
.subcommand(
SubCommand::with_name("rename_lint")
.about("Renames the given lint")
.arg(
Arg::with_name("old_name")
.index(1)
.required(true)
.help("The name of the lint to rename"),
)
.arg(
Arg::with_name("new_name")
.index(2)
.required_unless("uplift")
.help("The new name of the lint"),
)
.arg(
Arg::with_name("uplift")
.long("uplift")
.help("This lint will be uplifted into rustc"),
),
)
.get_matches()
}

View File

@ -1,11 +1,13 @@
use core::fmt::Write;
use aho_corasick::AhoCorasickBuilder;
use core::fmt::Write as _;
use itertools::Itertools;
use rustc_lexer::{tokenize, unescape, LiteralKind, TokenKind};
use std::collections::{HashMap, HashSet};
use std::ffi::OsStr;
use std::fs;
use std::path::Path;
use walkdir::WalkDir;
use std::io::{self, Read as _, Seek as _, Write as _};
use std::path::{Path, PathBuf};
use walkdir::{DirEntry, WalkDir};
use crate::clippy_project_root;
@ -30,12 +32,19 @@ pub enum UpdateMode {
/// # Panics
///
/// Panics if a file path could not read from or then written to
#[allow(clippy::too_many_lines)]
pub fn run(update_mode: UpdateMode) {
pub fn update(update_mode: UpdateMode) {
let (lints, deprecated_lints, renamed_lints) = gather_all();
generate_lint_files(update_mode, &lints, &deprecated_lints, &renamed_lints);
}
let internal_lints = Lint::internal_lints(&lints);
let usable_lints = Lint::usable_lints(&lints);
fn generate_lint_files(
update_mode: UpdateMode,
lints: &[Lint],
deprecated_lints: &[DeprecatedLint],
renamed_lints: &[RenamedLint],
) {
let internal_lints = Lint::internal_lints(lints);
let usable_lints = Lint::usable_lints(lints);
let mut sorted_usable_lints = usable_lints.clone();
sorted_usable_lints.sort_by_key(|lint| lint.name.clone());
@ -87,7 +96,7 @@ pub fn run(update_mode: UpdateMode) {
process_file(
"clippy_lints/src/lib.deprecated.rs",
update_mode,
&gen_deprecated(&deprecated_lints),
&gen_deprecated(deprecated_lints),
);
let all_group_lints = usable_lints.iter().filter(|l| {
@ -108,10 +117,10 @@ pub fn run(update_mode: UpdateMode) {
);
}
let content = gen_deprecated_lints_test(&deprecated_lints);
let content = gen_deprecated_lints_test(deprecated_lints);
process_file("tests/ui/deprecated.rs", update_mode, &content);
let content = gen_renamed_lints_test(&renamed_lints);
let content = gen_renamed_lints_test(renamed_lints);
process_file("tests/ui/rename.rs", update_mode, &content);
}
@ -134,6 +143,209 @@ pub fn print_lints() {
println!("there are {} lints", usable_lint_count);
}
/// Runs the `rename_lint` command.
///
/// This does the following:
/// * Adds an entry to `renamed_lints.rs`.
/// * Renames all lint attributes to the new name (e.g. `#[allow(clippy::lint_name)]`).
/// * Renames the lint struct to the new name.
/// * Renames the module containing the lint struct to the new name if it shares a name with the
/// lint.
///
/// # Panics
/// Panics for the following conditions:
/// * If a file path could not read from or then written to
/// * If either lint name has a prefix
/// * If `old_name` doesn't name an existing lint.
/// * If `old_name` names a deprecated or renamed lint.
#[allow(clippy::too_many_lines)]
pub fn rename(old_name: &str, new_name: &str, uplift: bool) {
if let Some((prefix, _)) = old_name.split_once("::") {
panic!("`{}` should not contain the `{}` prefix", old_name, prefix);
}
if let Some((prefix, _)) = new_name.split_once("::") {
panic!("`{}` should not contain the `{}` prefix", new_name, prefix);
}
let (mut lints, deprecated_lints, mut renamed_lints) = gather_all();
let mut old_lint_index = None;
let mut found_new_name = false;
for (i, lint) in lints.iter().enumerate() {
if lint.name == old_name {
old_lint_index = Some(i);
} else if lint.name == new_name {
found_new_name = true;
}
}
let old_lint_index = old_lint_index.unwrap_or_else(|| panic!("could not find lint `{}`", old_name));
let lint = RenamedLint {
old_name: format!("clippy::{}", old_name),
new_name: if uplift {
new_name.into()
} else {
format!("clippy::{}", new_name)
},
};
// Renamed lints and deprecated lints shouldn't have been found in the lint list, but check just in
// case.
assert!(
!renamed_lints.iter().any(|l| lint.old_name == l.old_name),
"`{}` has already been renamed",
old_name
);
assert!(
!deprecated_lints.iter().any(|l| lint.old_name == l.name),
"`{}` has already been deprecated",
old_name
);
// Update all lint level attributes. (`clippy::lint_name`)
for file in WalkDir::new(clippy_project_root())
.into_iter()
.map(Result::unwrap)
.filter(|f| {
let name = f.path().file_name();
let ext = f.path().extension();
(ext == Some(OsStr::new("rs")) || ext == Some(OsStr::new("fixed")))
&& name != Some(OsStr::new("rename.rs"))
&& name != Some(OsStr::new("renamed_lints.rs"))
})
{
rewrite_file(file.path(), |s| {
replace_ident_like(s, &[(&lint.old_name, &lint.new_name)])
});
}
renamed_lints.push(lint);
renamed_lints.sort_by(|lhs, rhs| {
lhs.new_name
.starts_with("clippy::")
.cmp(&rhs.new_name.starts_with("clippy::"))
.reverse()
.then_with(|| lhs.old_name.cmp(&rhs.old_name))
});
write_file(
Path::new("clippy_lints/src/renamed_lints.rs"),
&gen_renamed_lints_list(&renamed_lints),
);
if uplift {
write_file(Path::new("tests/ui/rename.rs"), &gen_renamed_lints_test(&renamed_lints));
println!(
"`{}` has be uplifted. All the code inside `clippy_lints` related to it needs to be removed manually.",
old_name
);
} else if found_new_name {
write_file(Path::new("tests/ui/rename.rs"), &gen_renamed_lints_test(&renamed_lints));
println!(
"`{}` is already defined. The old linting code inside `clippy_lints` needs to be updated/removed manually.",
new_name
);
} else {
// Rename the lint struct and source files sharing a name with the lint.
let lint = &mut lints[old_lint_index];
let old_name_upper = old_name.to_uppercase();
let new_name_upper = new_name.to_uppercase();
lint.name = new_name.into();
// Rename test files. only rename `.stderr` and `.fixed` files if the new test name doesn't exist.
if try_rename_file(
Path::new(&format!("tests/ui/{}.rs", old_name)),
Path::new(&format!("tests/ui/{}.rs", new_name)),
) {
try_rename_file(
Path::new(&format!("tests/ui/{}.stderr", old_name)),
Path::new(&format!("tests/ui/{}.stderr", new_name)),
);
try_rename_file(
Path::new(&format!("tests/ui/{}.fixed", old_name)),
Path::new(&format!("tests/ui/{}.fixed", new_name)),
);
}
// Try to rename the file containing the lint if the file name matches the lint's name.
let replacements;
let replacements = if lint.module == old_name
&& try_rename_file(
Path::new(&format!("clippy_lints/src/{}.rs", old_name)),
Path::new(&format!("clippy_lints/src/{}.rs", new_name)),
) {
// Edit the module name in the lint list. Note there could be multiple lints.
for lint in lints.iter_mut().filter(|l| l.module == old_name) {
lint.module = new_name.into();
}
replacements = [(&*old_name_upper, &*new_name_upper), (old_name, new_name)];
replacements.as_slice()
} else if !lint.module.contains("::")
// Catch cases like `methods/lint_name.rs` where the lint is stored in `methods/mod.rs`
&& try_rename_file(
Path::new(&format!("clippy_lints/src/{}/{}.rs", lint.module, old_name)),
Path::new(&format!("clippy_lints/src/{}/{}.rs", lint.module, new_name)),
)
{
// Edit the module name in the lint list. Note there could be multiple lints, or none.
let renamed_mod = format!("{}::{}", lint.module, old_name);
for lint in lints.iter_mut().filter(|l| l.module == renamed_mod) {
lint.module = format!("{}::{}", lint.module, new_name);
}
replacements = [(&*old_name_upper, &*new_name_upper), (old_name, new_name)];
replacements.as_slice()
} else {
replacements = [(&*old_name_upper, &*new_name_upper), ("", "")];
&replacements[0..1]
};
// Don't change `clippy_utils/src/renamed_lints.rs` here as it would try to edit the lint being
// renamed.
for (_, file) in clippy_lints_src_files().filter(|(rel_path, _)| rel_path != OsStr::new("renamed_lints.rs")) {
rewrite_file(file.path(), |s| replace_ident_like(s, replacements));
}
generate_lint_files(UpdateMode::Change, &lints, &deprecated_lints, &renamed_lints);
println!("{} has been successfully renamed", old_name);
}
println!("note: `cargo uitest` still needs to be run to update the test results");
}
/// Replace substrings if they aren't bordered by identifier characters. Returns `None` if there
/// were no replacements.
fn replace_ident_like(contents: &str, replacements: &[(&str, &str)]) -> Option<String> {
fn is_ident_char(c: u8) -> bool {
matches!(c, b'a'..=b'z' | b'A'..=b'Z' | b'0'..=b'9' | b'_')
}
let searcher = AhoCorasickBuilder::new()
.dfa(true)
.match_kind(aho_corasick::MatchKind::LeftmostLongest)
.build_with_size::<u16, _, _>(replacements.iter().map(|&(x, _)| x.as_bytes()))
.unwrap();
let mut result = String::with_capacity(contents.len() + 1024);
let mut pos = 0;
let mut edited = false;
for m in searcher.find_iter(contents) {
let (old, new) = replacements[m.pattern()];
result.push_str(&contents[pos..m.start()]);
result.push_str(
if !is_ident_char(contents.as_bytes().get(m.start().wrapping_sub(1)).copied().unwrap_or(0))
&& !is_ident_char(contents.as_bytes().get(m.end()).copied().unwrap_or(0))
{
edited = true;
new
} else {
old
},
);
pos = m.end();
}
result.push_str(&contents[pos..]);
edited.then(|| result)
}
fn round_to_fifty(count: usize) -> usize {
count / 50 * 50
}
@ -323,19 +535,27 @@ fn gen_renamed_lints_test(lints: &[RenamedLint]) -> String {
res
}
fn gen_renamed_lints_list(lints: &[RenamedLint]) -> String {
const HEADER: &str = "\
// This file is managed by `cargo dev rename_lint`. Prefer using that when possible.\n\n\
#[rustfmt::skip]\n\
pub static RENAMED_LINTS: &[(&str, &str)] = &[\n";
let mut res = String::from(HEADER);
for lint in lints {
writeln!(res, " (\"{}\", \"{}\"),", lint.old_name, lint.new_name).unwrap();
}
res.push_str("];\n");
res
}
/// Gathers all lints defined in `clippy_lints/src`
fn gather_all() -> (Vec<Lint>, Vec<DeprecatedLint>, Vec<RenamedLint>) {
let mut lints = Vec::with_capacity(1000);
let mut deprecated_lints = Vec::with_capacity(50);
let mut renamed_lints = Vec::with_capacity(50);
let root_path = clippy_project_root().join("clippy_lints/src");
for (rel_path, file) in WalkDir::new(&root_path)
.into_iter()
.map(Result::unwrap)
.filter(|f| f.path().extension() == Some(OsStr::new("rs")))
.map(|f| (f.path().strip_prefix(&root_path).unwrap().to_path_buf(), f))
{
for (rel_path, file) in clippy_lints_src_files() {
let path = file.path();
let contents =
fs::read_to_string(path).unwrap_or_else(|e| panic!("Cannot read from `{}`: {}", path.display(), e));
@ -362,6 +582,14 @@ fn gather_all() -> (Vec<Lint>, Vec<DeprecatedLint>, Vec<RenamedLint>) {
(lints, deprecated_lints, renamed_lints)
}
fn clippy_lints_src_files() -> impl Iterator<Item = (PathBuf, DirEntry)> {
let root_path = clippy_project_root().join("clippy_lints/src");
let iter = WalkDir::new(&root_path).into_iter();
iter.map(Result::unwrap)
.filter(|f| f.path().extension() == Some(OsStr::new("rs")))
.map(move |f| (f.path().strip_prefix(&root_path).unwrap().to_path_buf(), f))
}
macro_rules! match_tokens {
($iter:ident, $($token:ident $({$($fields:tt)*})? $(($capture:ident))?)*) => {
{
@ -526,6 +754,52 @@ fn replace_region_in_text<'a>(
Ok(res)
}
fn try_rename_file(old_name: &Path, new_name: &Path) -> bool {
match fs::OpenOptions::new().create_new(true).write(true).open(new_name) {
Ok(file) => drop(file),
Err(e) if matches!(e.kind(), io::ErrorKind::AlreadyExists | io::ErrorKind::NotFound) => return false,
Err(e) => panic_file(e, new_name, "create"),
};
match fs::rename(old_name, new_name) {
Ok(()) => true,
Err(e) => {
drop(fs::remove_file(new_name));
if e.kind() == io::ErrorKind::NotFound {
false
} else {
panic_file(e, old_name, "rename");
}
},
}
}
#[allow(clippy::needless_pass_by_value)]
fn panic_file(error: io::Error, name: &Path, action: &str) -> ! {
panic!("failed to {} file `{}`: {}", action, name.display(), error)
}
fn rewrite_file(path: &Path, f: impl FnOnce(&str) -> Option<String>) {
let mut file = fs::OpenOptions::new()
.write(true)
.read(true)
.open(path)
.unwrap_or_else(|e| panic_file(e, path, "open"));
let mut buf = String::new();
file.read_to_string(&mut buf)
.unwrap_or_else(|e| panic_file(e, path, "read"));
if let Some(new_contents) = f(&buf) {
file.rewind().unwrap_or_else(|e| panic_file(e, path, "write"));
file.write_all(new_contents.as_bytes())
.unwrap_or_else(|e| panic_file(e, path, "write"));
file.set_len(new_contents.len() as u64)
.unwrap_or_else(|e| panic_file(e, path, "write"));
}
}
fn write_file(path: &Path, contents: &str) {
fs::write(path, contents).unwrap_or_else(|e| panic_file(e, path, "write"));
}
#[cfg(test)]
mod tests {
use super::*;

View File

@ -1,37 +1,39 @@
// This file is managed by `cargo dev rename_lint`. Prefer using that when possible.
#[rustfmt::skip]
pub static RENAMED_LINTS: &[(&str, &str)] = &[
("clippy::stutter", "clippy::module_name_repetitions"),
("clippy::new_without_default_derive", "clippy::new_without_default"),
("clippy::cyclomatic_complexity", "clippy::cognitive_complexity"),
("clippy::const_static_lifetime", "clippy::redundant_static_lifetimes"),
("clippy::option_and_then_some", "clippy::bind_instead_of_map"),
("clippy::box_vec", "clippy::box_collection"),
("clippy::block_in_if_condition_expr", "clippy::blocks_in_if_conditions"),
("clippy::block_in_if_condition_stmt", "clippy::blocks_in_if_conditions"),
("clippy::option_map_unwrap_or", "clippy::map_unwrap_or"),
("clippy::option_map_unwrap_or_else", "clippy::map_unwrap_or"),
("clippy::result_map_unwrap_or_else", "clippy::map_unwrap_or"),
("clippy::option_unwrap_used", "clippy::unwrap_used"),
("clippy::result_unwrap_used", "clippy::unwrap_used"),
("clippy::option_expect_used", "clippy::expect_used"),
("clippy::result_expect_used", "clippy::expect_used"),
("clippy::box_vec", "clippy::box_collection"),
("clippy::const_static_lifetime", "clippy::redundant_static_lifetimes"),
("clippy::cyclomatic_complexity", "clippy::cognitive_complexity"),
("clippy::disallowed_method", "clippy::disallowed_methods"),
("clippy::disallowed_type", "clippy::disallowed_types"),
("clippy::for_loop_over_option", "clippy::for_loops_over_fallibles"),
("clippy::for_loop_over_result", "clippy::for_loops_over_fallibles"),
("clippy::identity_conversion", "clippy::useless_conversion"),
("clippy::zero_width_space", "clippy::invisible_characters"),
("clippy::single_char_push_str", "clippy::single_char_add_str"),
("clippy::if_let_some_result", "clippy::match_result_ok"),
("clippy::disallowed_type", "clippy::disallowed_types"),
("clippy::disallowed_method", "clippy::disallowed_methods"),
("clippy::new_without_default_derive", "clippy::new_without_default"),
("clippy::option_and_then_some", "clippy::bind_instead_of_map"),
("clippy::option_expect_used", "clippy::expect_used"),
("clippy::option_map_unwrap_or", "clippy::map_unwrap_or"),
("clippy::option_map_unwrap_or_else", "clippy::map_unwrap_or"),
("clippy::option_unwrap_used", "clippy::unwrap_used"),
("clippy::ref_in_deref", "clippy::needless_borrow"),
("clippy::result_expect_used", "clippy::expect_used"),
("clippy::result_map_unwrap_or_else", "clippy::map_unwrap_or"),
("clippy::result_unwrap_used", "clippy::unwrap_used"),
("clippy::single_char_push_str", "clippy::single_char_add_str"),
("clippy::stutter", "clippy::module_name_repetitions"),
("clippy::to_string_in_display", "clippy::recursive_format_impl"),
// uplifted lints
("clippy::invalid_ref", "invalid_value"),
("clippy::into_iter_on_array", "array_into_iter"),
("clippy::unused_label", "unused_labels"),
("clippy::zero_width_space", "clippy::invisible_characters"),
("clippy::drop_bounds", "drop_bounds"),
("clippy::temporary_cstring_as_ptr", "temporary_cstring_as_ptr"),
("clippy::panic_params", "non_fmt_panics"),
("clippy::unknown_clippy_lints", "unknown_lints"),
("clippy::into_iter_on_array", "array_into_iter"),
("clippy::invalid_atomic_ordering", "invalid_atomic_ordering"),
("clippy::invalid_ref", "invalid_value"),
("clippy::mem_discriminant_non_enum", "enum_intrinsics_non_enums"),
("clippy::panic_params", "non_fmt_panics"),
("clippy::temporary_cstring_as_ptr", "temporary_cstring_as_ptr"),
("clippy::unknown_clippy_lints", "unknown_lints"),
("clippy::unused_label", "unused_labels"),
];

View File

@ -4,67 +4,67 @@
// run-rustfix
#![allow(clippy::module_name_repetitions)]
#![allow(clippy::new_without_default)]
#![allow(clippy::cognitive_complexity)]
#![allow(clippy::redundant_static_lifetimes)]
#![allow(clippy::bind_instead_of_map)]
#![allow(clippy::box_collection)]
#![allow(clippy::blocks_in_if_conditions)]
#![allow(clippy::map_unwrap_or)]
#![allow(clippy::unwrap_used)]
#![allow(clippy::expect_used)]
#![allow(clippy::box_collection)]
#![allow(clippy::redundant_static_lifetimes)]
#![allow(clippy::cognitive_complexity)]
#![allow(clippy::disallowed_methods)]
#![allow(clippy::disallowed_types)]
#![allow(clippy::for_loops_over_fallibles)]
#![allow(clippy::useless_conversion)]
#![allow(clippy::invisible_characters)]
#![allow(clippy::single_char_add_str)]
#![allow(clippy::match_result_ok)]
#![allow(clippy::disallowed_types)]
#![allow(clippy::disallowed_methods)]
#![allow(clippy::new_without_default)]
#![allow(clippy::bind_instead_of_map)]
#![allow(clippy::expect_used)]
#![allow(clippy::map_unwrap_or)]
#![allow(clippy::unwrap_used)]
#![allow(clippy::needless_borrow)]
#![allow(clippy::single_char_add_str)]
#![allow(clippy::module_name_repetitions)]
#![allow(clippy::recursive_format_impl)]
#![allow(invalid_value)]
#![allow(array_into_iter)]
#![allow(unused_labels)]
#![allow(clippy::invisible_characters)]
#![allow(drop_bounds)]
#![allow(temporary_cstring_as_ptr)]
#![allow(non_fmt_panics)]
#![allow(unknown_lints)]
#![allow(array_into_iter)]
#![allow(invalid_atomic_ordering)]
#![allow(invalid_value)]
#![allow(enum_intrinsics_non_enums)]
#![warn(clippy::module_name_repetitions)]
#![warn(clippy::new_without_default)]
#![warn(clippy::cognitive_complexity)]
#![warn(clippy::redundant_static_lifetimes)]
#![warn(clippy::bind_instead_of_map)]
#![allow(non_fmt_panics)]
#![allow(temporary_cstring_as_ptr)]
#![allow(unknown_lints)]
#![allow(unused_labels)]
#![warn(clippy::blocks_in_if_conditions)]
#![warn(clippy::blocks_in_if_conditions)]
#![warn(clippy::box_collection)]
#![warn(clippy::blocks_in_if_conditions)]
#![warn(clippy::blocks_in_if_conditions)]
#![warn(clippy::map_unwrap_or)]
#![warn(clippy::map_unwrap_or)]
#![warn(clippy::map_unwrap_or)]
#![warn(clippy::unwrap_used)]
#![warn(clippy::unwrap_used)]
#![warn(clippy::expect_used)]
#![warn(clippy::expect_used)]
#![warn(clippy::redundant_static_lifetimes)]
#![warn(clippy::cognitive_complexity)]
#![warn(clippy::disallowed_methods)]
#![warn(clippy::disallowed_types)]
#![warn(clippy::for_loops_over_fallibles)]
#![warn(clippy::for_loops_over_fallibles)]
#![warn(clippy::useless_conversion)]
#![warn(clippy::invisible_characters)]
#![warn(clippy::single_char_add_str)]
#![warn(clippy::match_result_ok)]
#![warn(clippy::disallowed_types)]
#![warn(clippy::disallowed_methods)]
#![warn(clippy::new_without_default)]
#![warn(clippy::bind_instead_of_map)]
#![warn(clippy::expect_used)]
#![warn(clippy::map_unwrap_or)]
#![warn(clippy::map_unwrap_or)]
#![warn(clippy::unwrap_used)]
#![warn(clippy::needless_borrow)]
#![warn(clippy::expect_used)]
#![warn(clippy::map_unwrap_or)]
#![warn(clippy::unwrap_used)]
#![warn(clippy::single_char_add_str)]
#![warn(clippy::module_name_repetitions)]
#![warn(clippy::recursive_format_impl)]
#![warn(invalid_value)]
#![warn(array_into_iter)]
#![warn(unused_labels)]
#![warn(clippy::invisible_characters)]
#![warn(drop_bounds)]
#![warn(temporary_cstring_as_ptr)]
#![warn(non_fmt_panics)]
#![warn(unknown_lints)]
#![warn(array_into_iter)]
#![warn(invalid_atomic_ordering)]
#![warn(invalid_value)]
#![warn(enum_intrinsics_non_enums)]
#![warn(non_fmt_panics)]
#![warn(temporary_cstring_as_ptr)]
#![warn(unknown_lints)]
#![warn(unused_labels)]
fn main() {}

View File

@ -4,67 +4,67 @@
// run-rustfix
#![allow(clippy::module_name_repetitions)]
#![allow(clippy::new_without_default)]
#![allow(clippy::cognitive_complexity)]
#![allow(clippy::redundant_static_lifetimes)]
#![allow(clippy::bind_instead_of_map)]
#![allow(clippy::box_collection)]
#![allow(clippy::blocks_in_if_conditions)]
#![allow(clippy::map_unwrap_or)]
#![allow(clippy::unwrap_used)]
#![allow(clippy::expect_used)]
#![allow(clippy::box_collection)]
#![allow(clippy::redundant_static_lifetimes)]
#![allow(clippy::cognitive_complexity)]
#![allow(clippy::disallowed_methods)]
#![allow(clippy::disallowed_types)]
#![allow(clippy::for_loops_over_fallibles)]
#![allow(clippy::useless_conversion)]
#![allow(clippy::invisible_characters)]
#![allow(clippy::single_char_add_str)]
#![allow(clippy::match_result_ok)]
#![allow(clippy::disallowed_types)]
#![allow(clippy::disallowed_methods)]
#![allow(clippy::new_without_default)]
#![allow(clippy::bind_instead_of_map)]
#![allow(clippy::expect_used)]
#![allow(clippy::map_unwrap_or)]
#![allow(clippy::unwrap_used)]
#![allow(clippy::needless_borrow)]
#![allow(clippy::single_char_add_str)]
#![allow(clippy::module_name_repetitions)]
#![allow(clippy::recursive_format_impl)]
#![allow(invalid_value)]
#![allow(array_into_iter)]
#![allow(unused_labels)]
#![allow(clippy::invisible_characters)]
#![allow(drop_bounds)]
#![allow(temporary_cstring_as_ptr)]
#![allow(non_fmt_panics)]
#![allow(unknown_lints)]
#![allow(array_into_iter)]
#![allow(invalid_atomic_ordering)]
#![allow(invalid_value)]
#![allow(enum_intrinsics_non_enums)]
#![warn(clippy::stutter)]
#![warn(clippy::new_without_default_derive)]
#![warn(clippy::cyclomatic_complexity)]
#![warn(clippy::const_static_lifetime)]
#![warn(clippy::option_and_then_some)]
#![warn(clippy::box_vec)]
#![allow(non_fmt_panics)]
#![allow(temporary_cstring_as_ptr)]
#![allow(unknown_lints)]
#![allow(unused_labels)]
#![warn(clippy::block_in_if_condition_expr)]
#![warn(clippy::block_in_if_condition_stmt)]
#![warn(clippy::option_map_unwrap_or)]
#![warn(clippy::option_map_unwrap_or_else)]
#![warn(clippy::result_map_unwrap_or_else)]
#![warn(clippy::option_unwrap_used)]
#![warn(clippy::result_unwrap_used)]
#![warn(clippy::option_expect_used)]
#![warn(clippy::result_expect_used)]
#![warn(clippy::box_vec)]
#![warn(clippy::const_static_lifetime)]
#![warn(clippy::cyclomatic_complexity)]
#![warn(clippy::disallowed_method)]
#![warn(clippy::disallowed_type)]
#![warn(clippy::for_loop_over_option)]
#![warn(clippy::for_loop_over_result)]
#![warn(clippy::identity_conversion)]
#![warn(clippy::zero_width_space)]
#![warn(clippy::single_char_push_str)]
#![warn(clippy::if_let_some_result)]
#![warn(clippy::disallowed_type)]
#![warn(clippy::disallowed_method)]
#![warn(clippy::new_without_default_derive)]
#![warn(clippy::option_and_then_some)]
#![warn(clippy::option_expect_used)]
#![warn(clippy::option_map_unwrap_or)]
#![warn(clippy::option_map_unwrap_or_else)]
#![warn(clippy::option_unwrap_used)]
#![warn(clippy::ref_in_deref)]
#![warn(clippy::result_expect_used)]
#![warn(clippy::result_map_unwrap_or_else)]
#![warn(clippy::result_unwrap_used)]
#![warn(clippy::single_char_push_str)]
#![warn(clippy::stutter)]
#![warn(clippy::to_string_in_display)]
#![warn(clippy::invalid_ref)]
#![warn(clippy::into_iter_on_array)]
#![warn(clippy::unused_label)]
#![warn(clippy::zero_width_space)]
#![warn(clippy::drop_bounds)]
#![warn(clippy::temporary_cstring_as_ptr)]
#![warn(clippy::panic_params)]
#![warn(clippy::unknown_clippy_lints)]
#![warn(clippy::into_iter_on_array)]
#![warn(clippy::invalid_atomic_ordering)]
#![warn(clippy::invalid_ref)]
#![warn(clippy::mem_discriminant_non_enum)]
#![warn(clippy::panic_params)]
#![warn(clippy::temporary_cstring_as_ptr)]
#![warn(clippy::unknown_clippy_lints)]
#![warn(clippy::unused_label)]
fn main() {}

View File

@ -1,22 +1,22 @@
error: lint `clippy::stutter` has been renamed to `clippy::module_name_repetitions`
error: lint `clippy::block_in_if_condition_expr` has been renamed to `clippy::blocks_in_if_conditions`
--> $DIR/rename.rs:35:9
|
LL | #![warn(clippy::stutter)]
| ^^^^^^^^^^^^^^^ help: use the new name: `clippy::module_name_repetitions`
LL | #![warn(clippy::block_in_if_condition_expr)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_if_conditions`
|
= note: `-D renamed-and-removed-lints` implied by `-D warnings`
error: lint `clippy::new_without_default_derive` has been renamed to `clippy::new_without_default`
error: lint `clippy::block_in_if_condition_stmt` has been renamed to `clippy::blocks_in_if_conditions`
--> $DIR/rename.rs:36:9
|
LL | #![warn(clippy::new_without_default_derive)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::new_without_default`
LL | #![warn(clippy::block_in_if_condition_stmt)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_if_conditions`
error: lint `clippy::cyclomatic_complexity` has been renamed to `clippy::cognitive_complexity`
error: lint `clippy::box_vec` has been renamed to `clippy::box_collection`
--> $DIR/rename.rs:37:9
|
LL | #![warn(clippy::cyclomatic_complexity)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::cognitive_complexity`
LL | #![warn(clippy::box_vec)]
| ^^^^^^^^^^^^^^^ help: use the new name: `clippy::box_collection`
error: lint `clippy::const_static_lifetime` has been renamed to `clippy::redundant_static_lifetimes`
--> $DIR/rename.rs:38:9
@ -24,137 +24,137 @@ error: lint `clippy::const_static_lifetime` has been renamed to `clippy::redunda
LL | #![warn(clippy::const_static_lifetime)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::redundant_static_lifetimes`
error: lint `clippy::option_and_then_some` has been renamed to `clippy::bind_instead_of_map`
error: lint `clippy::cyclomatic_complexity` has been renamed to `clippy::cognitive_complexity`
--> $DIR/rename.rs:39:9
|
LL | #![warn(clippy::cyclomatic_complexity)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::cognitive_complexity`
error: lint `clippy::disallowed_method` has been renamed to `clippy::disallowed_methods`
--> $DIR/rename.rs:40:9
|
LL | #![warn(clippy::disallowed_method)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_methods`
error: lint `clippy::disallowed_type` has been renamed to `clippy::disallowed_types`
--> $DIR/rename.rs:41:9
|
LL | #![warn(clippy::disallowed_type)]
| ^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_types`
error: lint `clippy::for_loop_over_option` has been renamed to `clippy::for_loops_over_fallibles`
--> $DIR/rename.rs:42:9
|
LL | #![warn(clippy::for_loop_over_option)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::for_loops_over_fallibles`
error: lint `clippy::for_loop_over_result` has been renamed to `clippy::for_loops_over_fallibles`
--> $DIR/rename.rs:43:9
|
LL | #![warn(clippy::for_loop_over_result)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::for_loops_over_fallibles`
error: lint `clippy::identity_conversion` has been renamed to `clippy::useless_conversion`
--> $DIR/rename.rs:44:9
|
LL | #![warn(clippy::identity_conversion)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::useless_conversion`
error: lint `clippy::if_let_some_result` has been renamed to `clippy::match_result_ok`
--> $DIR/rename.rs:45:9
|
LL | #![warn(clippy::if_let_some_result)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::match_result_ok`
error: lint `clippy::new_without_default_derive` has been renamed to `clippy::new_without_default`
--> $DIR/rename.rs:46:9
|
LL | #![warn(clippy::new_without_default_derive)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::new_without_default`
error: lint `clippy::option_and_then_some` has been renamed to `clippy::bind_instead_of_map`
--> $DIR/rename.rs:47:9
|
LL | #![warn(clippy::option_and_then_some)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::bind_instead_of_map`
error: lint `clippy::box_vec` has been renamed to `clippy::box_collection`
--> $DIR/rename.rs:40:9
|
LL | #![warn(clippy::box_vec)]
| ^^^^^^^^^^^^^^^ help: use the new name: `clippy::box_collection`
error: lint `clippy::block_in_if_condition_expr` has been renamed to `clippy::blocks_in_if_conditions`
--> $DIR/rename.rs:41:9
|
LL | #![warn(clippy::block_in_if_condition_expr)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_if_conditions`
error: lint `clippy::block_in_if_condition_stmt` has been renamed to `clippy::blocks_in_if_conditions`
--> $DIR/rename.rs:42:9
|
LL | #![warn(clippy::block_in_if_condition_stmt)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_if_conditions`
error: lint `clippy::option_map_unwrap_or` has been renamed to `clippy::map_unwrap_or`
--> $DIR/rename.rs:43:9
|
LL | #![warn(clippy::option_map_unwrap_or)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or`
error: lint `clippy::option_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or`
--> $DIR/rename.rs:44:9
|
LL | #![warn(clippy::option_map_unwrap_or_else)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or`
error: lint `clippy::result_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or`
--> $DIR/rename.rs:45:9
|
LL | #![warn(clippy::result_map_unwrap_or_else)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or`
error: lint `clippy::option_unwrap_used` has been renamed to `clippy::unwrap_used`
--> $DIR/rename.rs:46:9
|
LL | #![warn(clippy::option_unwrap_used)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used`
error: lint `clippy::result_unwrap_used` has been renamed to `clippy::unwrap_used`
--> $DIR/rename.rs:47:9
|
LL | #![warn(clippy::result_unwrap_used)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used`
error: lint `clippy::option_expect_used` has been renamed to `clippy::expect_used`
--> $DIR/rename.rs:48:9
|
LL | #![warn(clippy::option_expect_used)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used`
error: lint `clippy::result_expect_used` has been renamed to `clippy::expect_used`
error: lint `clippy::option_map_unwrap_or` has been renamed to `clippy::map_unwrap_or`
--> $DIR/rename.rs:49:9
|
LL | #![warn(clippy::result_expect_used)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used`
LL | #![warn(clippy::option_map_unwrap_or)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or`
error: lint `clippy::for_loop_over_option` has been renamed to `clippy::for_loops_over_fallibles`
error: lint `clippy::option_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or`
--> $DIR/rename.rs:50:9
|
LL | #![warn(clippy::for_loop_over_option)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::for_loops_over_fallibles`
LL | #![warn(clippy::option_map_unwrap_or_else)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or`
error: lint `clippy::for_loop_over_result` has been renamed to `clippy::for_loops_over_fallibles`
error: lint `clippy::option_unwrap_used` has been renamed to `clippy::unwrap_used`
--> $DIR/rename.rs:51:9
|
LL | #![warn(clippy::for_loop_over_result)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::for_loops_over_fallibles`
error: lint `clippy::identity_conversion` has been renamed to `clippy::useless_conversion`
--> $DIR/rename.rs:52:9
|
LL | #![warn(clippy::identity_conversion)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::useless_conversion`
error: lint `clippy::zero_width_space` has been renamed to `clippy::invisible_characters`
--> $DIR/rename.rs:53:9
|
LL | #![warn(clippy::zero_width_space)]
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::invisible_characters`
error: lint `clippy::single_char_push_str` has been renamed to `clippy::single_char_add_str`
--> $DIR/rename.rs:54:9
|
LL | #![warn(clippy::single_char_push_str)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::single_char_add_str`
error: lint `clippy::if_let_some_result` has been renamed to `clippy::match_result_ok`
--> $DIR/rename.rs:55:9
|
LL | #![warn(clippy::if_let_some_result)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::match_result_ok`
error: lint `clippy::disallowed_type` has been renamed to `clippy::disallowed_types`
--> $DIR/rename.rs:56:9
|
LL | #![warn(clippy::disallowed_type)]
| ^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_types`
error: lint `clippy::disallowed_method` has been renamed to `clippy::disallowed_methods`
--> $DIR/rename.rs:57:9
|
LL | #![warn(clippy::disallowed_method)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_methods`
LL | #![warn(clippy::option_unwrap_used)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used`
error: lint `clippy::ref_in_deref` has been renamed to `clippy::needless_borrow`
--> $DIR/rename.rs:58:9
--> $DIR/rename.rs:52:9
|
LL | #![warn(clippy::ref_in_deref)]
| ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::needless_borrow`
error: lint `clippy::result_expect_used` has been renamed to `clippy::expect_used`
--> $DIR/rename.rs:53:9
|
LL | #![warn(clippy::result_expect_used)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used`
error: lint `clippy::result_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or`
--> $DIR/rename.rs:54:9
|
LL | #![warn(clippy::result_map_unwrap_or_else)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or`
error: lint `clippy::result_unwrap_used` has been renamed to `clippy::unwrap_used`
--> $DIR/rename.rs:55:9
|
LL | #![warn(clippy::result_unwrap_used)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used`
error: lint `clippy::single_char_push_str` has been renamed to `clippy::single_char_add_str`
--> $DIR/rename.rs:56:9
|
LL | #![warn(clippy::single_char_push_str)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::single_char_add_str`
error: lint `clippy::stutter` has been renamed to `clippy::module_name_repetitions`
--> $DIR/rename.rs:57:9
|
LL | #![warn(clippy::stutter)]
| ^^^^^^^^^^^^^^^ help: use the new name: `clippy::module_name_repetitions`
error: lint `clippy::to_string_in_display` has been renamed to `clippy::recursive_format_impl`
--> $DIR/rename.rs:59:9
--> $DIR/rename.rs:58:9
|
LL | #![warn(clippy::to_string_in_display)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::recursive_format_impl`
error: lint `clippy::invalid_ref` has been renamed to `invalid_value`
error: lint `clippy::zero_width_space` has been renamed to `clippy::invisible_characters`
--> $DIR/rename.rs:59:9
|
LL | #![warn(clippy::zero_width_space)]
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::invisible_characters`
error: lint `clippy::drop_bounds` has been renamed to `drop_bounds`
--> $DIR/rename.rs:60:9
|
LL | #![warn(clippy::invalid_ref)]
| ^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_value`
LL | #![warn(clippy::drop_bounds)]
| ^^^^^^^^^^^^^^^^^^^ help: use the new name: `drop_bounds`
error: lint `clippy::into_iter_on_array` has been renamed to `array_into_iter`
--> $DIR/rename.rs:61:9
@ -162,23 +162,23 @@ error: lint `clippy::into_iter_on_array` has been renamed to `array_into_iter`
LL | #![warn(clippy::into_iter_on_array)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `array_into_iter`
error: lint `clippy::unused_label` has been renamed to `unused_labels`
error: lint `clippy::invalid_atomic_ordering` has been renamed to `invalid_atomic_ordering`
--> $DIR/rename.rs:62:9
|
LL | #![warn(clippy::unused_label)]
| ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unused_labels`
LL | #![warn(clippy::invalid_atomic_ordering)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_atomic_ordering`
error: lint `clippy::drop_bounds` has been renamed to `drop_bounds`
error: lint `clippy::invalid_ref` has been renamed to `invalid_value`
--> $DIR/rename.rs:63:9
|
LL | #![warn(clippy::drop_bounds)]
| ^^^^^^^^^^^^^^^^^^^ help: use the new name: `drop_bounds`
LL | #![warn(clippy::invalid_ref)]
| ^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_value`
error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cstring_as_ptr`
error: lint `clippy::mem_discriminant_non_enum` has been renamed to `enum_intrinsics_non_enums`
--> $DIR/rename.rs:64:9
|
LL | #![warn(clippy::temporary_cstring_as_ptr)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `temporary_cstring_as_ptr`
LL | #![warn(clippy::mem_discriminant_non_enum)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `enum_intrinsics_non_enums`
error: lint `clippy::panic_params` has been renamed to `non_fmt_panics`
--> $DIR/rename.rs:65:9
@ -186,23 +186,23 @@ error: lint `clippy::panic_params` has been renamed to `non_fmt_panics`
LL | #![warn(clippy::panic_params)]
| ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panics`
error: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints`
error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cstring_as_ptr`
--> $DIR/rename.rs:66:9
|
LL | #![warn(clippy::temporary_cstring_as_ptr)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `temporary_cstring_as_ptr`
error: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints`
--> $DIR/rename.rs:67:9
|
LL | #![warn(clippy::unknown_clippy_lints)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unknown_lints`
error: lint `clippy::invalid_atomic_ordering` has been renamed to `invalid_atomic_ordering`
--> $DIR/rename.rs:67:9
|
LL | #![warn(clippy::invalid_atomic_ordering)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_atomic_ordering`
error: lint `clippy::mem_discriminant_non_enum` has been renamed to `enum_intrinsics_non_enums`
error: lint `clippy::unused_label` has been renamed to `unused_labels`
--> $DIR/rename.rs:68:9
|
LL | #![warn(clippy::mem_discriminant_non_enum)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `enum_intrinsics_non_enums`
LL | #![warn(clippy::unused_label)]
| ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unused_labels`
error: aborting due to 34 previous errors