2022-04-07 18:39:59 +01:00
|
|
|
|
#![feature(array_windows)]
|
2021-12-30 15:10:43 +01:00
|
|
|
|
#![feature(binary_heap_into_iter_sorted)]
|
2019-07-21 12:52:14 +02:00
|
|
|
|
#![feature(box_patterns)]
|
2020-06-23 17:05:22 +02:00
|
|
|
|
#![feature(drain_filter)]
|
2021-12-30 15:10:43 +01:00
|
|
|
|
#![feature(iter_intersperse)]
|
2022-08-20 20:40:08 +02:00
|
|
|
|
#![feature(let_chains)]
|
2022-05-21 13:24:00 +02:00
|
|
|
|
#![feature(lint_reasons)]
|
2022-06-30 10:50:09 +02:00
|
|
|
|
#![feature(never_type)]
|
2020-10-09 12:45:29 +02:00
|
|
|
|
#![feature(once_cell)]
|
2016-06-06 17:09:51 +02:00
|
|
|
|
#![feature(rustc_private)]
|
2016-05-24 18:25:25 +02:00
|
|
|
|
#![feature(stmt_expr_attributes)]
|
2019-05-14 01:34:08 +02:00
|
|
|
|
#![recursion_limit = "512"]
|
2019-07-15 07:35:02 +02:00
|
|
|
|
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
|
2020-06-23 17:05:22 +02:00
|
|
|
|
#![allow(clippy::missing_docs_in_private_items, clippy::must_use_candidate)]
|
|
|
|
|
#![warn(trivial_casts, trivial_numeric_casts)]
|
|
|
|
|
// warn on lints, that are included in `rust-lang/rust`s bootstrap
|
|
|
|
|
#![warn(rust_2018_idioms, unused_lifetimes)]
|
|
|
|
|
// warn on rustc internal lints
|
2021-04-27 13:00:36 -04:00
|
|
|
|
#![warn(rustc::internal)]
|
2022-02-10 18:40:06 +01:00
|
|
|
|
// Disable this rustc lint for now, as it was also done in rustc
|
2022-02-23 08:06:22 -05:00
|
|
|
|
#![allow(rustc::potential_query_instability)]
|
2018-03-25 21:04:05 -05:00
|
|
|
|
|
2018-09-15 10:21:58 +03:00
|
|
|
|
// FIXME: switch to something more ergonomic here, once available.
|
2019-01-31 01:15:29 +00:00
|
|
|
|
// (Currently there is no way to opt into sysroot crates without `extern crate`.)
|
2022-03-24 14:50:04 +01:00
|
|
|
|
extern crate rustc_arena;
|
2020-03-01 12:23:33 +09:00
|
|
|
|
extern crate rustc_ast;
|
2020-02-02 06:56:27 +09:00
|
|
|
|
extern crate rustc_ast_pretty;
|
2018-09-15 10:21:58 +03:00
|
|
|
|
extern crate rustc_data_structures;
|
2020-12-20 17:19:49 +01:00
|
|
|
|
extern crate rustc_driver;
|
2018-09-15 10:21:58 +03:00
|
|
|
|
extern crate rustc_errors;
|
2020-01-07 01:39:50 +09:00
|
|
|
|
extern crate rustc_hir;
|
2022-10-06 09:44:38 +02:00
|
|
|
|
extern crate rustc_hir_analysis;
|
2020-03-27 15:34:29 +01:00
|
|
|
|
extern crate rustc_hir_pretty;
|
2022-11-21 20:34:47 +01:00
|
|
|
|
extern crate rustc_hir_typeck;
|
2019-10-02 08:02:18 +09:00
|
|
|
|
extern crate rustc_index;
|
2020-02-17 11:07:26 +09:00
|
|
|
|
extern crate rustc_infer;
|
2019-11-03 00:41:22 -04:00
|
|
|
|
extern crate rustc_lexer;
|
2020-01-12 15:08:41 +09:00
|
|
|
|
extern crate rustc_lint;
|
2020-03-30 11:02:14 +02:00
|
|
|
|
extern crate rustc_middle;
|
2019-11-11 06:22:50 +02:00
|
|
|
|
extern crate rustc_parse;
|
2019-12-04 00:16:03 +01:00
|
|
|
|
extern crate rustc_session;
|
2019-12-31 09:17:56 +09:00
|
|
|
|
extern crate rustc_span;
|
2018-09-15 10:21:58 +03:00
|
|
|
|
extern crate rustc_target;
|
2020-03-15 05:26:32 +09:00
|
|
|
|
extern crate rustc_trait_selection;
|
2016-05-24 18:25:25 +02:00
|
|
|
|
|
2021-06-03 08:41:37 +02:00
|
|
|
|
#[macro_use]
|
|
|
|
|
extern crate clippy_utils;
|
2022-11-21 20:34:47 +01:00
|
|
|
|
#[macro_use]
|
|
|
|
|
extern crate declare_clippy_lint;
|
|
|
|
|
|
|
|
|
|
use std::io;
|
|
|
|
|
use std::path::PathBuf;
|
2021-06-03 08:41:37 +02:00
|
|
|
|
|
2022-12-01 18:29:38 +01:00
|
|
|
|
use clippy_utils::msrvs::Msrv;
|
2019-10-10 21:46:22 -04:00
|
|
|
|
use rustc_data_structures::fx::FxHashSet;
|
2022-11-21 20:34:47 +01:00
|
|
|
|
use rustc_lint::{Lint, LintId};
|
2020-03-18 23:45:02 +01:00
|
|
|
|
use rustc_session::Session;
|
2019-12-24 03:06:52 +07:00
|
|
|
|
|
2022-01-13 13:18:19 +01:00
|
|
|
|
#[cfg(feature = "internal")]
|
2022-06-30 10:50:09 +02:00
|
|
|
|
pub mod deprecated_lints;
|
2022-01-13 13:18:19 +01:00
|
|
|
|
#[cfg_attr(feature = "internal", allow(clippy::missing_clippy_version_attribute))]
|
2021-06-03 08:41:37 +02:00
|
|
|
|
mod utils;
|
2016-05-24 18:25:25 +02:00
|
|
|
|
|
2022-11-21 20:34:47 +01:00
|
|
|
|
mod declared_lints;
|
2022-05-05 15:12:52 +01:00
|
|
|
|
mod renamed_lints;
|
|
|
|
|
|
2016-05-24 18:25:25 +02:00
|
|
|
|
// begin lints modules, do not remove this comment, it’s used in `update_lints`
|
2022-12-17 14:12:54 +01:00
|
|
|
|
mod almost_complete_range;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod approx_const;
|
|
|
|
|
mod as_conversions;
|
2020-10-09 12:45:29 +02:00
|
|
|
|
mod asm_syntax;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod assertions_on_constants;
|
2022-07-28 19:08:22 +02:00
|
|
|
|
mod assertions_on_result_states;
|
2020-09-10 17:47:07 +02:00
|
|
|
|
mod async_yields_async;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod attrs;
|
2020-10-28 23:36:07 +01:00
|
|
|
|
mod await_holding_invalid;
|
2020-05-17 17:36:26 +02:00
|
|
|
|
mod blocks_in_if_conditions;
|
2021-04-22 11:31:13 +02:00
|
|
|
|
mod bool_assert_comparison;
|
2022-09-09 13:36:26 +02:00
|
|
|
|
mod bool_to_int_with_if;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod booleans;
|
2022-06-04 13:34:07 +02:00
|
|
|
|
mod borrow_deref_ref;
|
2022-10-06 09:44:38 +02:00
|
|
|
|
mod box_default;
|
2022-02-26 14:26:21 +01:00
|
|
|
|
mod cargo;
|
2021-03-12 15:30:50 +01:00
|
|
|
|
mod casts;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod checked_conversions;
|
|
|
|
|
mod cognitive_complexity;
|
|
|
|
|
mod collapsible_if;
|
|
|
|
|
mod comparison_chain;
|
|
|
|
|
mod copies;
|
|
|
|
|
mod copy_iterator;
|
2022-04-07 18:39:59 +01:00
|
|
|
|
mod crate_in_macro_def;
|
2020-09-10 17:47:07 +02:00
|
|
|
|
mod create_dir;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod dbg_macro;
|
2020-11-05 14:29:48 +01:00
|
|
|
|
mod default;
|
2022-06-30 10:50:09 +02:00
|
|
|
|
mod default_instead_of_iter_empty;
|
2021-02-25 11:25:22 +01:00
|
|
|
|
mod default_numeric_fallback;
|
2022-02-10 18:40:06 +01:00
|
|
|
|
mod default_union_representation;
|
2020-03-21 19:34:56 +01:00
|
|
|
|
mod dereference;
|
2021-09-08 16:31:47 +02:00
|
|
|
|
mod derivable_impls;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod derive;
|
2022-10-06 09:44:38 +02:00
|
|
|
|
mod disallowed_macros;
|
2021-12-06 12:33:31 +01:00
|
|
|
|
mod disallowed_methods;
|
2022-08-11 19:42:16 +02:00
|
|
|
|
mod disallowed_names;
|
2021-07-01 18:17:38 +02:00
|
|
|
|
mod disallowed_script_idents;
|
2021-12-06 12:33:31 +01:00
|
|
|
|
mod disallowed_types;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod doc;
|
|
|
|
|
mod double_parens;
|
|
|
|
|
mod drop_forget_ref;
|
2022-05-21 13:24:00 +02:00
|
|
|
|
mod duplicate_mod;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod else_if_without_else;
|
2022-05-05 15:12:52 +01:00
|
|
|
|
mod empty_drop;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod empty_enum;
|
2022-04-07 18:39:59 +01:00
|
|
|
|
mod empty_structs_with_brackets;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod entry;
|
|
|
|
|
mod enum_clike;
|
|
|
|
|
mod enum_variants;
|
2021-10-07 11:21:30 +02:00
|
|
|
|
mod equatable_if_let;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod escape;
|
|
|
|
|
mod eta_reduction;
|
|
|
|
|
mod excessive_bools;
|
2021-01-30 18:06:34 +01:00
|
|
|
|
mod exhaustive_items;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod exit;
|
|
|
|
|
mod explicit_write;
|
|
|
|
|
mod fallible_impl_from;
|
|
|
|
|
mod float_literal;
|
|
|
|
|
mod floating_point_arithmetic;
|
2022-12-29 14:28:34 +01:00
|
|
|
|
mod fn_null_check;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod format;
|
2021-10-21 13:11:36 +02:00
|
|
|
|
mod format_args;
|
2022-02-26 14:26:21 +01:00
|
|
|
|
mod format_impl;
|
2022-05-05 15:12:52 +01:00
|
|
|
|
mod format_push_string;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod formatting;
|
2021-01-02 16:29:43 +01:00
|
|
|
|
mod from_over_into;
|
2022-11-21 20:34:47 +01:00
|
|
|
|
mod from_raw_with_void_ptr;
|
2021-02-25 11:25:22 +01:00
|
|
|
|
mod from_str_radix_10;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod functions;
|
2020-04-07 15:39:07 +02:00
|
|
|
|
mod future_not_send;
|
2020-03-05 08:36:19 -05:00
|
|
|
|
mod if_let_mutex;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod if_not_else;
|
2021-03-25 19:29:11 +01:00
|
|
|
|
mod if_then_some_else_none;
|
2021-04-08 17:50:13 +02:00
|
|
|
|
mod implicit_hasher;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod implicit_return;
|
2022-10-06 09:44:38 +02:00
|
|
|
|
mod implicit_saturating_add;
|
2020-04-06 23:37:57 +05:30
|
|
|
|
mod implicit_saturating_sub;
|
2021-02-25 11:25:22 +01:00
|
|
|
|
mod inconsistent_struct_constructor;
|
2021-12-06 12:33:31 +01:00
|
|
|
|
mod index_refutable_slice;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod indexing_slicing;
|
|
|
|
|
mod infinite_iter;
|
|
|
|
|
mod inherent_impl;
|
|
|
|
|
mod inherent_to_string;
|
2021-12-30 15:10:43 +01:00
|
|
|
|
mod init_numbered_fields;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod inline_fn_without_body;
|
2022-11-21 20:34:47 +01:00
|
|
|
|
mod instant_subtraction;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod int_plus_one;
|
2021-04-08 17:50:13 +02:00
|
|
|
|
mod invalid_upcast_comparisons;
|
2022-07-18 09:39:37 +02:00
|
|
|
|
mod invalid_utf8_in_unchecked;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod items_after_statements;
|
2021-09-28 18:03:12 +01:00
|
|
|
|
mod iter_not_returning_iterator;
|
2020-03-23 22:07:46 +01:00
|
|
|
|
mod large_const_arrays;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod large_enum_variant;
|
2022-05-05 15:12:52 +01:00
|
|
|
|
mod large_include_file;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod large_stack_arrays;
|
|
|
|
|
mod len_zero;
|
|
|
|
|
mod let_if_seq;
|
|
|
|
|
mod let_underscore;
|
|
|
|
|
mod lifetimes;
|
|
|
|
|
mod literal_representation;
|
|
|
|
|
mod loops;
|
|
|
|
|
mod macro_use;
|
|
|
|
|
mod main_recursion;
|
2021-11-04 12:52:36 +00:00
|
|
|
|
mod manual_assert;
|
2020-05-11 20:23:47 +02:00
|
|
|
|
mod manual_async_fn;
|
2022-01-13 13:18:19 +01:00
|
|
|
|
mod manual_bits;
|
2022-10-06 09:44:38 +02:00
|
|
|
|
mod manual_clamp;
|
2022-11-21 20:34:47 +01:00
|
|
|
|
mod manual_is_ascii_check;
|
|
|
|
|
mod manual_let_else;
|
2020-05-11 20:23:47 +02:00
|
|
|
|
mod manual_non_exhaustive;
|
2022-06-30 10:50:09 +02:00
|
|
|
|
mod manual_rem_euclid;
|
|
|
|
|
mod manual_retain;
|
2022-08-31 09:24:45 -04:00
|
|
|
|
mod manual_string_new;
|
2020-09-24 14:49:22 +02:00
|
|
|
|
mod manual_strip;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod map_unit_fn;
|
2021-09-28 18:03:12 +01:00
|
|
|
|
mod match_result_ok;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod matches;
|
|
|
|
|
mod mem_forget;
|
|
|
|
|
mod mem_replace;
|
|
|
|
|
mod methods;
|
|
|
|
|
mod minmax;
|
|
|
|
|
mod misc;
|
|
|
|
|
mod misc_early;
|
2022-06-04 13:34:07 +02:00
|
|
|
|
mod mismatching_type_param_order;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod missing_const_for_fn;
|
|
|
|
|
mod missing_doc;
|
2021-07-01 18:17:38 +02:00
|
|
|
|
mod missing_enforced_import_rename;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod missing_inline;
|
2022-10-23 15:18:45 +02:00
|
|
|
|
mod missing_trait_methods;
|
2022-05-21 13:24:00 +02:00
|
|
|
|
mod mixed_read_write_in_expression;
|
2021-09-08 16:31:47 +02:00
|
|
|
|
mod module_style;
|
2022-08-31 09:24:45 -04:00
|
|
|
|
mod multi_assignments;
|
2023-01-27 21:09:08 +01:00
|
|
|
|
mod multiple_unsafe_ops_per_block;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod mut_key;
|
|
|
|
|
mod mut_mut;
|
|
|
|
|
mod mut_reference;
|
|
|
|
|
mod mutable_debug_assertion;
|
|
|
|
|
mod mutex_atomic;
|
2020-08-11 15:43:21 +02:00
|
|
|
|
mod needless_arbitrary_self_type;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod needless_bool;
|
|
|
|
|
mod needless_borrowed_ref;
|
|
|
|
|
mod needless_continue;
|
2021-04-08 17:50:13 +02:00
|
|
|
|
mod needless_for_each;
|
2021-12-06 12:33:31 +01:00
|
|
|
|
mod needless_late_init;
|
2022-06-16 17:39:06 +02:00
|
|
|
|
mod needless_parens_on_range_literals;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod needless_pass_by_value;
|
2021-01-15 10:56:44 +01:00
|
|
|
|
mod needless_question_mark;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod needless_update;
|
|
|
|
|
mod neg_cmp_op_on_partial_ord;
|
|
|
|
|
mod neg_multiply;
|
|
|
|
|
mod new_without_default;
|
|
|
|
|
mod no_effect;
|
|
|
|
|
mod non_copy_const;
|
|
|
|
|
mod non_expressive_names;
|
2021-04-08 17:50:13 +02:00
|
|
|
|
mod non_octal_unix_permissions;
|
2021-10-07 11:21:30 +02:00
|
|
|
|
mod non_send_fields_in_send_ty;
|
2021-07-01 18:17:38 +02:00
|
|
|
|
mod nonstandard_macro_braces;
|
2021-12-06 12:33:31 +01:00
|
|
|
|
mod octal_escapes;
|
2022-03-14 12:02:53 +01:00
|
|
|
|
mod only_used_in_recursion;
|
2022-06-30 10:50:09 +02:00
|
|
|
|
mod operators;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod option_env_unwrap;
|
2020-07-14 14:59:59 +02:00
|
|
|
|
mod option_if_let_else;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod overflow_check_conditional;
|
2020-09-24 14:49:22 +02:00
|
|
|
|
mod panic_in_result_fn;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod panic_unimplemented;
|
2022-10-23 15:18:45 +02:00
|
|
|
|
mod partial_pub_fields;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod partialeq_ne_impl;
|
2022-08-11 19:42:16 +02:00
|
|
|
|
mod partialeq_to_none;
|
2020-10-28 23:36:07 +01:00
|
|
|
|
mod pass_by_ref_or_value;
|
2020-07-14 14:59:59 +02:00
|
|
|
|
mod pattern_type_mismatch;
|
2022-12-29 14:28:34 +01:00
|
|
|
|
mod permissions_set_readonly_false;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod precedence;
|
|
|
|
|
mod ptr;
|
|
|
|
|
mod ptr_offset_with_cast;
|
2022-05-05 15:12:52 +01:00
|
|
|
|
mod pub_use;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod question_mark;
|
|
|
|
|
mod ranges;
|
2022-05-21 13:24:00 +02:00
|
|
|
|
mod rc_clone_in_vec_init;
|
2022-06-16 17:39:06 +02:00
|
|
|
|
mod read_zero_byte_vec;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod redundant_clone;
|
2020-07-26 21:07:07 +02:00
|
|
|
|
mod redundant_closure_call;
|
2020-12-20 17:19:49 +01:00
|
|
|
|
mod redundant_else;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod redundant_field_names;
|
|
|
|
|
mod redundant_pub_crate;
|
2021-01-30 18:06:34 +01:00
|
|
|
|
mod redundant_slicing;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod redundant_static_lifetimes;
|
2020-11-05 14:29:48 +01:00
|
|
|
|
mod ref_option_ref;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod reference;
|
|
|
|
|
mod regex;
|
2021-12-17 13:40:22 +01:00
|
|
|
|
mod return_self_not_must_use;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod returns;
|
2021-09-28 18:03:12 +01:00
|
|
|
|
mod same_name_method;
|
2021-07-29 12:16:06 +02:00
|
|
|
|
mod self_named_constructors;
|
2022-12-17 14:12:54 +01:00
|
|
|
|
mod semicolon_block;
|
2021-02-11 15:04:38 +01:00
|
|
|
|
mod semicolon_if_nothing_returned;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod serde_api;
|
|
|
|
|
mod shadow;
|
2022-01-13 13:18:19 +01:00
|
|
|
|
mod single_char_lifetime_names;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod single_component_path_imports;
|
2020-12-06 15:01:03 +01:00
|
|
|
|
mod size_of_in_element_count;
|
2022-12-29 14:28:34 +01:00
|
|
|
|
mod size_of_ref;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod slow_vector_initialization;
|
2022-07-18 09:39:37 +02:00
|
|
|
|
mod std_instead_of_core;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod strings;
|
2021-07-15 10:44:10 +02:00
|
|
|
|
mod strlen_on_c_strings;
|
2020-12-06 15:01:03 +01:00
|
|
|
|
mod suspicious_operation_groupings;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod suspicious_trait_impl;
|
2022-11-21 20:34:47 +01:00
|
|
|
|
mod suspicious_xor_used_as_pow;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod swap;
|
2022-06-04 13:34:07 +02:00
|
|
|
|
mod swap_ptr_to_ref;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod tabs_in_doc_comments;
|
|
|
|
|
mod temporary_assignment;
|
|
|
|
|
mod to_digit_is_some;
|
2021-10-21 13:11:36 +02:00
|
|
|
|
mod trailing_empty_array;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod trait_bounds;
|
|
|
|
|
mod transmute;
|
|
|
|
|
mod types;
|
2021-10-21 13:11:36 +02:00
|
|
|
|
mod undocumented_unsafe_blocks;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod unicode;
|
2021-10-21 13:11:36 +02:00
|
|
|
|
mod uninit_vec;
|
2020-07-26 21:07:07 +02:00
|
|
|
|
mod unit_return_expecting_ord;
|
2021-03-25 19:29:11 +01:00
|
|
|
|
mod unit_types;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod unnamed_address;
|
2022-05-05 15:12:52 +01:00
|
|
|
|
mod unnecessary_owned_empty_strings;
|
2021-04-22 11:31:13 +02:00
|
|
|
|
mod unnecessary_self_imports;
|
2020-11-23 13:51:04 +01:00
|
|
|
|
mod unnecessary_wraps;
|
2020-06-09 14:36:01 +00:00
|
|
|
|
mod unnested_or_patterns;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod unsafe_removed_from_name;
|
2021-05-20 12:30:31 +02:00
|
|
|
|
mod unused_async;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod unused_io_amount;
|
2022-08-31 09:24:45 -04:00
|
|
|
|
mod unused_peekable;
|
2022-06-04 13:34:07 +02:00
|
|
|
|
mod unused_rounding;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod unused_self;
|
2020-08-28 16:10:16 +02:00
|
|
|
|
mod unused_unit;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod unwrap;
|
2020-08-28 16:10:16 +02:00
|
|
|
|
mod unwrap_in_result;
|
2021-01-30 18:06:34 +01:00
|
|
|
|
mod upper_case_acronyms;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod use_self;
|
2020-05-17 17:36:26 +02:00
|
|
|
|
mod useless_conversion;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod vec;
|
2021-01-15 10:56:44 +01:00
|
|
|
|
mod vec_init_then_push;
|
2020-04-02 22:08:25 +02:00
|
|
|
|
mod wildcard_imports;
|
|
|
|
|
mod write;
|
|
|
|
|
mod zero_div_zero;
|
2020-12-20 17:19:49 +01:00
|
|
|
|
mod zero_sized_map_values;
|
2016-05-24 18:25:25 +02:00
|
|
|
|
// end lints modules, do not remove this comment, it’s used in `update_lints`
|
|
|
|
|
|
2022-05-21 13:24:00 +02:00
|
|
|
|
use crate::utils::conf::{format_error, TryConf};
|
2022-11-21 20:34:47 +01:00
|
|
|
|
pub use crate::utils::conf::{lookup_conf_file, Conf};
|
2018-08-15 08:11:07 +02:00
|
|
|
|
|
2019-02-11 07:59:57 +01:00
|
|
|
|
/// Register all pre expansion lints
|
|
|
|
|
///
|
|
|
|
|
/// Pre-expansion lints run before any macro expansion has happened.
|
|
|
|
|
///
|
2019-04-04 11:15:30 +02:00
|
|
|
|
/// Note that due to the architecture of the compiler, currently `cfg_attr` attributes on crate
|
2019-02-11 22:32:54 +01:00
|
|
|
|
/// level (i.e `#![cfg_attr(...)]`) will still be expanded even when using a pre-expansion pass.
|
2019-02-11 07:59:57 +01:00
|
|
|
|
///
|
|
|
|
|
/// Used in `./src/driver.rs`.
|
2021-12-06 12:33:31 +01:00
|
|
|
|
pub fn register_pre_expansion_lints(store: &mut rustc_lint::LintStore, sess: &Session, conf: &Conf) {
|
2021-04-22 11:31:13 +02:00
|
|
|
|
// NOTE: Do not add any more pre-expansion passes. These should be removed eventually.
|
2022-12-01 18:29:38 +01:00
|
|
|
|
let msrv = Msrv::read(&conf.msrv, sess);
|
|
|
|
|
let msrv = move || msrv.clone();
|
2021-12-06 12:33:31 +01:00
|
|
|
|
|
2022-12-01 18:29:38 +01:00
|
|
|
|
store.register_pre_expansion_pass(move || Box::new(attrs::EarlyAttributes { msrv: msrv() }));
|
2022-06-30 10:50:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-11 07:59:57 +01:00
|
|
|
|
#[doc(hidden)]
|
2022-11-21 20:34:47 +01:00
|
|
|
|
pub fn read_conf(sess: &Session, path: &io::Result<Option<PathBuf>>) -> Conf {
|
|
|
|
|
let file_name = match path {
|
2021-05-06 11:51:22 +02:00
|
|
|
|
Ok(Some(path)) => path,
|
|
|
|
|
Ok(None) => return Conf::default(),
|
|
|
|
|
Err(error) => {
|
2022-12-29 14:28:34 +01:00
|
|
|
|
sess.struct_err(format!("error finding Clippy's configuration file: {error}"))
|
2018-11-27 21:14:15 +01:00
|
|
|
|
.emit();
|
2021-05-06 11:51:22 +02:00
|
|
|
|
return Conf::default();
|
2019-10-24 11:55:22 +02:00
|
|
|
|
},
|
2021-05-06 11:51:22 +02:00
|
|
|
|
};
|
|
|
|
|
|
2022-11-21 20:34:47 +01:00
|
|
|
|
let TryConf { conf, errors, warnings } = utils::conf::read(file_name);
|
2021-05-06 11:51:22 +02:00
|
|
|
|
// all conf errors are non-fatal, we just use the default conf in case of error
|
|
|
|
|
for error in errors {
|
2022-10-23 15:18:45 +02:00
|
|
|
|
sess.err(format!(
|
2021-05-06 11:51:22 +02:00
|
|
|
|
"error reading Clippy's configuration file `{}`: {}",
|
|
|
|
|
file_name.display(),
|
2022-05-21 13:24:00 +02:00
|
|
|
|
format_error(error)
|
2022-06-30 10:50:09 +02:00
|
|
|
|
));
|
2018-08-15 08:11:07 +02:00
|
|
|
|
}
|
2021-05-06 11:51:22 +02:00
|
|
|
|
|
2022-08-11 19:42:16 +02:00
|
|
|
|
for warning in warnings {
|
2022-10-23 15:18:45 +02:00
|
|
|
|
sess.struct_warn(format!(
|
2022-08-11 19:42:16 +02:00
|
|
|
|
"error reading Clippy's configuration file `{}`: {}",
|
|
|
|
|
file_name.display(),
|
|
|
|
|
format_error(warning)
|
|
|
|
|
))
|
|
|
|
|
.emit();
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-06 11:51:22 +02:00
|
|
|
|
conf
|
2018-08-15 08:11:07 +02:00
|
|
|
|
}
|
2016-05-24 18:25:25 +02:00
|
|
|
|
|
2022-11-21 20:34:47 +01:00
|
|
|
|
#[derive(Default)]
|
|
|
|
|
struct RegistrationGroups {
|
|
|
|
|
all: Vec<LintId>,
|
|
|
|
|
cargo: Vec<LintId>,
|
|
|
|
|
complexity: Vec<LintId>,
|
|
|
|
|
correctness: Vec<LintId>,
|
|
|
|
|
nursery: Vec<LintId>,
|
|
|
|
|
pedantic: Vec<LintId>,
|
|
|
|
|
perf: Vec<LintId>,
|
|
|
|
|
restriction: Vec<LintId>,
|
|
|
|
|
style: Vec<LintId>,
|
|
|
|
|
suspicious: Vec<LintId>,
|
|
|
|
|
#[cfg(feature = "internal")]
|
|
|
|
|
internal: Vec<LintId>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl RegistrationGroups {
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
|
fn register(self, store: &mut rustc_lint::LintStore) {
|
|
|
|
|
store.register_group(true, "clippy::all", Some("clippy_all"), self.all);
|
|
|
|
|
store.register_group(true, "clippy::cargo", Some("clippy_cargo"), self.cargo);
|
|
|
|
|
store.register_group(true, "clippy::complexity", Some("clippy_complexity"), self.complexity);
|
|
|
|
|
store.register_group(true, "clippy::correctness", Some("clippy_correctness"), self.correctness);
|
|
|
|
|
store.register_group(true, "clippy::nursery", Some("clippy_nursery"), self.nursery);
|
|
|
|
|
store.register_group(true, "clippy::pedantic", Some("clippy_pedantic"), self.pedantic);
|
|
|
|
|
store.register_group(true, "clippy::perf", Some("clippy_perf"), self.perf);
|
|
|
|
|
store.register_group(true, "clippy::restriction", Some("clippy_restriction"), self.restriction);
|
|
|
|
|
store.register_group(true, "clippy::style", Some("clippy_style"), self.style);
|
|
|
|
|
store.register_group(true, "clippy::suspicious", Some("clippy_suspicious"), self.suspicious);
|
|
|
|
|
#[cfg(feature = "internal")]
|
|
|
|
|
store.register_group(true, "clippy::internal", Some("clippy_internal"), self.internal);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
|
pub(crate) enum LintCategory {
|
|
|
|
|
Cargo,
|
|
|
|
|
Complexity,
|
|
|
|
|
Correctness,
|
|
|
|
|
Nursery,
|
|
|
|
|
Pedantic,
|
|
|
|
|
Perf,
|
|
|
|
|
Restriction,
|
|
|
|
|
Style,
|
|
|
|
|
Suspicious,
|
|
|
|
|
#[cfg(feature = "internal")]
|
|
|
|
|
Internal,
|
|
|
|
|
}
|
|
|
|
|
#[allow(clippy::enum_glob_use)]
|
|
|
|
|
use LintCategory::*;
|
|
|
|
|
|
|
|
|
|
impl LintCategory {
|
|
|
|
|
fn is_all(self) -> bool {
|
|
|
|
|
matches!(self, Correctness | Suspicious | Style | Complexity | Perf)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn group(self, groups: &mut RegistrationGroups) -> &mut Vec<LintId> {
|
|
|
|
|
match self {
|
|
|
|
|
Cargo => &mut groups.cargo,
|
|
|
|
|
Complexity => &mut groups.complexity,
|
|
|
|
|
Correctness => &mut groups.correctness,
|
|
|
|
|
Nursery => &mut groups.nursery,
|
|
|
|
|
Pedantic => &mut groups.pedantic,
|
|
|
|
|
Perf => &mut groups.perf,
|
|
|
|
|
Restriction => &mut groups.restriction,
|
|
|
|
|
Style => &mut groups.style,
|
|
|
|
|
Suspicious => &mut groups.suspicious,
|
|
|
|
|
#[cfg(feature = "internal")]
|
|
|
|
|
Internal => &mut groups.internal,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) struct LintInfo {
|
|
|
|
|
/// Double reference to maintain pointer equality
|
|
|
|
|
lint: &'static &'static Lint,
|
|
|
|
|
category: LintCategory,
|
|
|
|
|
explanation: &'static str,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn explain(name: &str) {
|
|
|
|
|
let target = format!("clippy::{}", name.to_ascii_uppercase());
|
|
|
|
|
match declared_lints::LINTS.iter().find(|info| info.lint.name == target) {
|
|
|
|
|
Some(info) => print!("{}", info.explanation),
|
|
|
|
|
None => println!("unknown lint: {name}"),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn register_categories(store: &mut rustc_lint::LintStore) {
|
|
|
|
|
let mut groups = RegistrationGroups::default();
|
|
|
|
|
|
|
|
|
|
for LintInfo { lint, category, .. } in declared_lints::LINTS {
|
|
|
|
|
if category.is_all() {
|
|
|
|
|
groups.all.push(LintId::of(lint));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
category.group(&mut groups).push(LintId::of(lint));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let lints: Vec<&'static Lint> = declared_lints::LINTS.iter().map(|info| *info.lint).collect();
|
|
|
|
|
|
|
|
|
|
store.register_lints(&lints);
|
|
|
|
|
groups.register(store);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-11 07:59:57 +01:00
|
|
|
|
/// Register all lints and lint groups with the rustc plugin registry
|
|
|
|
|
///
|
|
|
|
|
/// Used in `./src/driver.rs`.
|
2022-05-21 13:24:00 +02:00
|
|
|
|
#[expect(clippy::too_many_lines)]
|
2020-01-12 15:08:41 +09:00
|
|
|
|
pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: &Conf) {
|
2019-10-10 21:46:22 -04:00
|
|
|
|
register_removed_non_tool_lints(store);
|
2022-11-21 20:34:47 +01:00
|
|
|
|
register_categories(store);
|
2019-08-12 07:28:07 +02:00
|
|
|
|
|
2021-10-07 11:21:30 +02:00
|
|
|
|
include!("lib.deprecated.rs");
|
2016-05-24 18:25:25 +02:00
|
|
|
|
|
2022-01-13 13:18:19 +01:00
|
|
|
|
#[cfg(feature = "internal")]
|
2021-06-03 08:41:37 +02:00
|
|
|
|
{
|
|
|
|
|
if std::env::var("ENABLE_METADATA_COLLECTION").eq(&Ok("1".to_string())) {
|
2022-09-21 13:02:37 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(utils::internal_lints::metadata_collector::MetadataCollector::new()));
|
2021-06-03 08:41:37 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// all the internal lints
|
2022-01-13 13:18:19 +01:00
|
|
|
|
#[cfg(feature = "internal")]
|
2021-06-03 08:41:37 +02:00
|
|
|
|
{
|
2022-10-23 15:18:45 +02:00
|
|
|
|
store.register_early_pass(|| Box::new(utils::internal_lints::clippy_lints_internal::ClippyLintsInternal));
|
|
|
|
|
store.register_early_pass(|| Box::new(utils::internal_lints::produce_ice::ProduceIce));
|
|
|
|
|
store.register_late_pass(|_| Box::new(utils::internal_lints::collapsible_calls::CollapsibleCalls));
|
|
|
|
|
store.register_late_pass(|_| {
|
|
|
|
|
Box::new(utils::internal_lints::compiler_lint_functions::CompilerLintFunctions::new())
|
|
|
|
|
});
|
|
|
|
|
store.register_late_pass(|_| Box::new(utils::internal_lints::if_chain_style::IfChainStyle));
|
|
|
|
|
store.register_late_pass(|_| Box::new(utils::internal_lints::invalid_paths::InvalidPaths));
|
|
|
|
|
store.register_late_pass(|_| {
|
|
|
|
|
Box::<utils::internal_lints::interning_defined_symbol::InterningDefinedSymbol>::default()
|
|
|
|
|
});
|
|
|
|
|
store.register_late_pass(|_| {
|
|
|
|
|
Box::<utils::internal_lints::lint_without_lint_pass::LintWithoutLintPass>::default()
|
|
|
|
|
});
|
|
|
|
|
store.register_late_pass(|_| Box::<utils::internal_lints::unnecessary_def_path::UnnecessaryDefPath>::default());
|
|
|
|
|
store.register_late_pass(|_| Box::new(utils::internal_lints::outer_expn_data_pass::OuterExpnDataPass));
|
|
|
|
|
store.register_late_pass(|_| Box::new(utils::internal_lints::msrv_attr_impl::MsrvAttrImpl));
|
2021-06-03 08:41:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-09 13:36:26 +02:00
|
|
|
|
let arithmetic_side_effects_allowed = conf.arithmetic_side_effects_allowed.clone();
|
2022-12-17 14:12:54 +01:00
|
|
|
|
let arithmetic_side_effects_allowed_binary = conf.arithmetic_side_effects_allowed_binary.clone();
|
|
|
|
|
let arithmetic_side_effects_allowed_unary = conf.arithmetic_side_effects_allowed_unary.clone();
|
2022-09-09 13:36:26 +02:00
|
|
|
|
store.register_late_pass(move |_| {
|
|
|
|
|
Box::new(operators::arithmetic_side_effects::ArithmeticSideEffects::new(
|
2022-12-17 14:12:54 +01:00
|
|
|
|
arithmetic_side_effects_allowed
|
|
|
|
|
.iter()
|
|
|
|
|
.flat_map(|el| [[el.clone(), "*".to_string()], ["*".to_string(), el.clone()]])
|
|
|
|
|
.chain(arithmetic_side_effects_allowed_binary.clone())
|
|
|
|
|
.collect(),
|
|
|
|
|
arithmetic_side_effects_allowed
|
|
|
|
|
.iter()
|
|
|
|
|
.chain(arithmetic_side_effects_allowed_unary.iter())
|
|
|
|
|
.cloned()
|
|
|
|
|
.collect(),
|
2022-09-09 13:36:26 +02:00
|
|
|
|
))
|
|
|
|
|
});
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(utils::dump_hir::DumpHir));
|
|
|
|
|
store.register_late_pass(|_| Box::new(utils::author::Author));
|
2022-05-05 15:12:52 +01:00
|
|
|
|
let await_holding_invalid_types = conf.await_holding_invalid_types.clone();
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| {
|
2022-05-05 15:12:52 +01:00
|
|
|
|
Box::new(await_holding_invalid::AwaitHolding::new(
|
|
|
|
|
await_holding_invalid_types.clone(),
|
|
|
|
|
))
|
|
|
|
|
});
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(serde_api::SerdeApi));
|
2021-06-03 08:41:37 +02:00
|
|
|
|
let vec_box_size_threshold = conf.vec_box_size_threshold;
|
|
|
|
|
let type_complexity_threshold = conf.type_complexity_threshold;
|
2021-09-08 16:31:47 +02:00
|
|
|
|
let avoid_breaking_exported_api = conf.avoid_breaking_exported_api;
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| {
|
2021-12-06 12:33:31 +01:00
|
|
|
|
Box::new(types::Types::new(
|
|
|
|
|
vec_box_size_threshold,
|
|
|
|
|
type_complexity_threshold,
|
|
|
|
|
avoid_breaking_exported_api,
|
|
|
|
|
))
|
|
|
|
|
});
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(booleans::NonminimalBool));
|
|
|
|
|
store.register_late_pass(|_| Box::new(enum_clike::UnportableVariant));
|
|
|
|
|
store.register_late_pass(|_| Box::new(float_literal::FloatLiteral));
|
|
|
|
|
store.register_late_pass(|_| Box::new(ptr::Ptr));
|
|
|
|
|
store.register_late_pass(|_| Box::new(needless_bool::NeedlessBool));
|
|
|
|
|
store.register_late_pass(|_| Box::new(needless_bool::BoolComparison));
|
|
|
|
|
store.register_late_pass(|_| Box::new(needless_for_each::NeedlessForEach));
|
2022-12-17 14:12:54 +01:00
|
|
|
|
store.register_late_pass(|_| Box::<misc::LintPass>::default());
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(eta_reduction::EtaReduction));
|
|
|
|
|
store.register_late_pass(|_| Box::new(mut_mut::MutMut));
|
|
|
|
|
store.register_late_pass(|_| Box::new(mut_reference::UnnecessaryMutPassed));
|
|
|
|
|
store.register_late_pass(|_| Box::new(len_zero::LenZero));
|
|
|
|
|
store.register_late_pass(|_| Box::new(attrs::Attributes));
|
|
|
|
|
store.register_late_pass(|_| Box::new(blocks_in_if_conditions::BlocksInIfConditions));
|
|
|
|
|
store.register_late_pass(|_| Box::new(unicode::Unicode));
|
|
|
|
|
store.register_late_pass(|_| Box::new(uninit_vec::UninitVec));
|
|
|
|
|
store.register_late_pass(|_| Box::new(unit_return_expecting_ord::UnitReturnExpectingOrd));
|
|
|
|
|
store.register_late_pass(|_| Box::new(strings::StringAdd));
|
|
|
|
|
store.register_late_pass(|_| Box::new(implicit_return::ImplicitReturn));
|
|
|
|
|
store.register_late_pass(|_| Box::new(implicit_saturating_sub::ImplicitSaturatingSub));
|
|
|
|
|
store.register_late_pass(|_| Box::new(default_numeric_fallback::DefaultNumericFallback));
|
|
|
|
|
store.register_late_pass(|_| Box::new(inconsistent_struct_constructor::InconsistentStructConstructor));
|
|
|
|
|
store.register_late_pass(|_| Box::new(non_octal_unix_permissions::NonOctalUnixPermissions));
|
2021-08-06 17:14:27 +02:00
|
|
|
|
store.register_early_pass(|| Box::new(unnecessary_self_imports::UnnecessarySelfImports));
|
2021-06-03 08:41:37 +02:00
|
|
|
|
|
2022-12-01 18:29:38 +01:00
|
|
|
|
let msrv = Msrv::read(&conf.msrv, sess);
|
|
|
|
|
let msrv = move || msrv.clone();
|
2021-06-03 08:41:37 +02:00
|
|
|
|
let avoid_breaking_exported_api = conf.avoid_breaking_exported_api;
|
2022-05-21 13:24:00 +02:00
|
|
|
|
let allow_expect_in_tests = conf.allow_expect_in_tests;
|
|
|
|
|
let allow_unwrap_in_tests = conf.allow_unwrap_in_tests;
|
2022-12-17 14:12:54 +01:00
|
|
|
|
let suppress_restriction_lint_in_const = conf.suppress_restriction_lint_in_const;
|
2022-12-01 18:29:38 +01:00
|
|
|
|
store.register_late_pass(move |_| Box::new(approx_const::ApproxConstant::new(msrv())));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| {
|
2022-05-21 13:24:00 +02:00
|
|
|
|
Box::new(methods::Methods::new(
|
|
|
|
|
avoid_breaking_exported_api,
|
2022-12-01 18:29:38 +01:00
|
|
|
|
msrv(),
|
2022-05-21 13:24:00 +02:00
|
|
|
|
allow_expect_in_tests,
|
|
|
|
|
allow_unwrap_in_tests,
|
|
|
|
|
))
|
|
|
|
|
});
|
2022-12-01 18:29:38 +01:00
|
|
|
|
store.register_late_pass(move |_| Box::new(matches::Matches::new(msrv())));
|
2022-11-21 20:34:47 +01:00
|
|
|
|
let matches_for_let_else = conf.matches_for_let_else;
|
2022-12-01 18:29:38 +01:00
|
|
|
|
store.register_late_pass(move |_| Box::new(manual_let_else::ManualLetElse::new(msrv(), matches_for_let_else)));
|
|
|
|
|
store.register_early_pass(move || Box::new(manual_non_exhaustive::ManualNonExhaustiveStruct::new(msrv())));
|
|
|
|
|
store.register_late_pass(move |_| Box::new(manual_non_exhaustive::ManualNonExhaustiveEnum::new(msrv())));
|
|
|
|
|
store.register_late_pass(move |_| Box::new(manual_strip::ManualStrip::new(msrv())));
|
|
|
|
|
store.register_early_pass(move || Box::new(redundant_static_lifetimes::RedundantStaticLifetimes::new(msrv())));
|
|
|
|
|
store.register_early_pass(move || Box::new(redundant_field_names::RedundantFieldNames::new(msrv())));
|
|
|
|
|
store.register_late_pass(move |_| Box::new(checked_conversions::CheckedConversions::new(msrv())));
|
|
|
|
|
store.register_late_pass(move |_| Box::new(mem_replace::MemReplace::new(msrv())));
|
|
|
|
|
store.register_late_pass(move |_| Box::new(ranges::Ranges::new(msrv())));
|
|
|
|
|
store.register_late_pass(move |_| Box::new(from_over_into::FromOverInto::new(msrv())));
|
|
|
|
|
store.register_late_pass(move |_| Box::new(use_self::UseSelf::new(msrv())));
|
|
|
|
|
store.register_late_pass(move |_| Box::new(missing_const_for_fn::MissingConstForFn::new(msrv())));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| Box::new(needless_question_mark::NeedlessQuestionMark));
|
2022-12-01 18:29:38 +01:00
|
|
|
|
store.register_late_pass(move |_| Box::new(casts::Casts::new(msrv())));
|
|
|
|
|
store.register_early_pass(move || Box::new(unnested_or_patterns::UnnestedOrPatterns::new(msrv())));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(size_of_in_element_count::SizeOfInElementCount));
|
|
|
|
|
store.register_late_pass(|_| Box::new(same_name_method::SameNameMethod));
|
2021-12-06 12:33:31 +01:00
|
|
|
|
let max_suggested_slice_pattern_length = conf.max_suggested_slice_pattern_length;
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| {
|
2021-12-06 12:33:31 +01:00
|
|
|
|
Box::new(index_refutable_slice::IndexRefutableSlice::new(
|
|
|
|
|
max_suggested_slice_pattern_length,
|
2022-12-01 18:29:38 +01:00
|
|
|
|
msrv(),
|
2021-12-06 12:33:31 +01:00
|
|
|
|
))
|
|
|
|
|
});
|
2022-10-06 09:44:38 +02:00
|
|
|
|
store.register_late_pass(|_| Box::<shadow::Shadow>::default());
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(unit_types::UnitTypes));
|
|
|
|
|
store.register_late_pass(|_| Box::new(loops::Loops));
|
2022-10-06 09:44:38 +02:00
|
|
|
|
store.register_late_pass(|_| Box::<main_recursion::MainRecursion>::default());
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(lifetimes::Lifetimes));
|
|
|
|
|
store.register_late_pass(|_| Box::new(entry::HashMapPass));
|
|
|
|
|
store.register_late_pass(|_| Box::new(minmax::MinMaxPass));
|
|
|
|
|
store.register_late_pass(|_| Box::new(zero_div_zero::ZeroDiv));
|
|
|
|
|
store.register_late_pass(|_| Box::new(mutex_atomic::Mutex));
|
|
|
|
|
store.register_late_pass(|_| Box::new(needless_update::NeedlessUpdate));
|
|
|
|
|
store.register_late_pass(|_| Box::new(needless_borrowed_ref::NeedlessBorrowedRef));
|
|
|
|
|
store.register_late_pass(|_| Box::new(borrow_deref_ref::BorrowDerefRef));
|
|
|
|
|
store.register_late_pass(|_| Box::new(no_effect::NoEffect));
|
|
|
|
|
store.register_late_pass(|_| Box::new(temporary_assignment::TemporaryAssignment));
|
2022-12-01 18:29:38 +01:00
|
|
|
|
store.register_late_pass(move |_| Box::new(transmute::Transmute::new(msrv())));
|
2021-06-03 08:41:37 +02:00
|
|
|
|
let cognitive_complexity_threshold = conf.cognitive_complexity_threshold;
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| {
|
2021-12-06 12:33:31 +01:00
|
|
|
|
Box::new(cognitive_complexity::CognitiveComplexity::new(
|
|
|
|
|
cognitive_complexity_threshold,
|
|
|
|
|
))
|
|
|
|
|
});
|
2021-06-03 08:41:37 +02:00
|
|
|
|
let too_large_for_stack = conf.too_large_for_stack;
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| Box::new(escape::BoxedLocal { too_large_for_stack }));
|
|
|
|
|
store.register_late_pass(move |_| Box::new(vec::UselessVec { too_large_for_stack }));
|
|
|
|
|
store.register_late_pass(|_| Box::new(panic_unimplemented::PanicUnimplemented));
|
|
|
|
|
store.register_late_pass(|_| Box::new(strings::StringLitAsBytes));
|
|
|
|
|
store.register_late_pass(|_| Box::new(derive::Derive));
|
2023-01-12 19:48:13 +01:00
|
|
|
|
store.register_late_pass(move |_| Box::new(derivable_impls::DerivableImpls::new(msrv())));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(drop_forget_ref::DropForgetRef));
|
|
|
|
|
store.register_late_pass(|_| Box::new(empty_enum::EmptyEnum));
|
|
|
|
|
store.register_late_pass(|_| Box::new(invalid_upcast_comparisons::InvalidUpcastComparisons));
|
|
|
|
|
store.register_late_pass(|_| Box::new(regex::Regex));
|
|
|
|
|
store.register_late_pass(|_| Box::new(copies::CopyAndPaste));
|
|
|
|
|
store.register_late_pass(|_| Box::new(copy_iterator::CopyIterator));
|
|
|
|
|
store.register_late_pass(|_| Box::new(format::UselessFormat));
|
|
|
|
|
store.register_late_pass(|_| Box::new(swap::Swap));
|
|
|
|
|
store.register_late_pass(|_| Box::new(overflow_check_conditional::OverflowCheckConditional));
|
2022-10-06 09:44:38 +02:00
|
|
|
|
store.register_late_pass(|_| Box::<new_without_default::NewWithoutDefault>::default());
|
2022-08-11 19:42:16 +02:00
|
|
|
|
let disallowed_names = conf.disallowed_names.iter().cloned().collect::<FxHashSet<_>>();
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| Box::new(disallowed_names::DisallowedNames::new(disallowed_names.clone())));
|
2021-06-03 08:41:37 +02:00
|
|
|
|
let too_many_arguments_threshold = conf.too_many_arguments_threshold;
|
|
|
|
|
let too_many_lines_threshold = conf.too_many_lines_threshold;
|
2022-08-31 09:24:45 -04:00
|
|
|
|
let large_error_threshold = conf.large_error_threshold;
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| {
|
2021-12-06 12:33:31 +01:00
|
|
|
|
Box::new(functions::Functions::new(
|
|
|
|
|
too_many_arguments_threshold,
|
|
|
|
|
too_many_lines_threshold,
|
2022-08-31 09:24:45 -04:00
|
|
|
|
large_error_threshold,
|
2021-12-06 12:33:31 +01:00
|
|
|
|
))
|
|
|
|
|
});
|
2021-06-03 08:41:37 +02:00
|
|
|
|
let doc_valid_idents = conf.doc_valid_idents.iter().cloned().collect::<FxHashSet<_>>();
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| Box::new(doc::DocMarkdown::new(doc_valid_idents.clone())));
|
|
|
|
|
store.register_late_pass(|_| Box::new(neg_multiply::NegMultiply));
|
|
|
|
|
store.register_late_pass(|_| Box::new(mem_forget::MemForget));
|
|
|
|
|
store.register_late_pass(|_| Box::new(let_if_seq::LetIfSeq));
|
|
|
|
|
store.register_late_pass(|_| Box::new(mixed_read_write_in_expression::EvalOrderDependence));
|
|
|
|
|
store.register_late_pass(|_| Box::new(missing_doc::MissingDoc::new()));
|
|
|
|
|
store.register_late_pass(|_| Box::new(missing_inline::MissingInline));
|
|
|
|
|
store.register_late_pass(move |_| Box::new(exhaustive_items::ExhaustiveItems));
|
|
|
|
|
store.register_late_pass(|_| Box::new(match_result_ok::MatchResultOk));
|
|
|
|
|
store.register_late_pass(|_| Box::new(partialeq_ne_impl::PartialEqNeImpl));
|
|
|
|
|
store.register_late_pass(|_| Box::new(unused_io_amount::UnusedIoAmount));
|
2021-06-03 08:41:37 +02:00
|
|
|
|
let enum_variant_size_threshold = conf.enum_variant_size_threshold;
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| Box::new(large_enum_variant::LargeEnumVariant::new(enum_variant_size_threshold)));
|
|
|
|
|
store.register_late_pass(|_| Box::new(explicit_write::ExplicitWrite));
|
|
|
|
|
store.register_late_pass(|_| Box::new(needless_pass_by_value::NeedlessPassByValue));
|
2021-06-03 08:41:37 +02:00
|
|
|
|
let pass_by_ref_or_value = pass_by_ref_or_value::PassByRefOrValue::new(
|
|
|
|
|
conf.trivial_copy_size_limit,
|
|
|
|
|
conf.pass_by_value_size_limit,
|
|
|
|
|
conf.avoid_breaking_exported_api,
|
|
|
|
|
&sess.target,
|
|
|
|
|
);
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| Box::new(pass_by_ref_or_value));
|
|
|
|
|
store.register_late_pass(|_| Box::new(ref_option_ref::RefOptionRef));
|
|
|
|
|
store.register_late_pass(|_| Box::new(infinite_iter::InfiniteIter));
|
|
|
|
|
store.register_late_pass(|_| Box::new(inline_fn_without_body::InlineFnWithoutBody));
|
2022-10-06 09:44:38 +02:00
|
|
|
|
store.register_late_pass(|_| Box::<useless_conversion::UselessConversion>::default());
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(implicit_hasher::ImplicitHasher));
|
|
|
|
|
store.register_late_pass(|_| Box::new(fallible_impl_from::FallibleImplFrom));
|
|
|
|
|
store.register_late_pass(|_| Box::new(question_mark::QuestionMark));
|
2021-08-06 17:14:27 +02:00
|
|
|
|
store.register_early_pass(|| Box::new(suspicious_operation_groupings::SuspiciousOperationGroupings));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(suspicious_trait_impl::SuspiciousImpl));
|
|
|
|
|
store.register_late_pass(|_| Box::new(map_unit_fn::MapUnit));
|
|
|
|
|
store.register_late_pass(|_| Box::new(inherent_impl::MultipleInherentImpl));
|
|
|
|
|
store.register_late_pass(|_| Box::new(neg_cmp_op_on_partial_ord::NoNegCompOpForPartialOrd));
|
|
|
|
|
store.register_late_pass(|_| Box::new(unwrap::Unwrap));
|
2022-12-17 14:12:54 +01:00
|
|
|
|
store.register_late_pass(move |_| {
|
|
|
|
|
Box::new(indexing_slicing::IndexingSlicing::new(
|
|
|
|
|
suppress_restriction_lint_in_const,
|
|
|
|
|
))
|
|
|
|
|
});
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(non_copy_const::NonCopyConst));
|
|
|
|
|
store.register_late_pass(|_| Box::new(ptr_offset_with_cast::PtrOffsetWithCast));
|
|
|
|
|
store.register_late_pass(|_| Box::new(redundant_clone::RedundantClone));
|
|
|
|
|
store.register_late_pass(|_| Box::new(slow_vector_initialization::SlowVectorInit));
|
|
|
|
|
store.register_late_pass(move |_| Box::new(unnecessary_wraps::UnnecessaryWraps::new(avoid_breaking_exported_api)));
|
|
|
|
|
store.register_late_pass(|_| Box::new(assertions_on_constants::AssertionsOnConstants));
|
|
|
|
|
store.register_late_pass(|_| Box::new(assertions_on_result_states::AssertionsOnResultStates));
|
|
|
|
|
store.register_late_pass(|_| Box::new(inherent_to_string::InherentToString));
|
2021-06-03 08:41:37 +02:00
|
|
|
|
let max_trait_bounds = conf.max_trait_bounds;
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| Box::new(trait_bounds::TraitBounds::new(max_trait_bounds)));
|
|
|
|
|
store.register_late_pass(|_| Box::new(comparison_chain::ComparisonChain));
|
2022-11-21 20:34:47 +01:00
|
|
|
|
let ignore_interior_mutability = conf.ignore_interior_mutability.clone();
|
|
|
|
|
store.register_late_pass(move |_| Box::new(mut_key::MutableKeyType::new(ignore_interior_mutability.clone())));
|
2021-08-06 17:14:27 +02:00
|
|
|
|
store.register_early_pass(|| Box::new(reference::DerefAddrOf));
|
|
|
|
|
store.register_early_pass(|| Box::new(double_parens::DoubleParens));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(format_impl::FormatImpl::new()));
|
2021-08-06 17:14:27 +02:00
|
|
|
|
store.register_early_pass(|| Box::new(unsafe_removed_from_name::UnsafeNameRemoval));
|
|
|
|
|
store.register_early_pass(|| Box::new(else_if_without_else::ElseIfWithoutElse));
|
|
|
|
|
store.register_early_pass(|| Box::new(int_plus_one::IntPlusOne));
|
|
|
|
|
store.register_early_pass(|| Box::new(formatting::Formatting));
|
|
|
|
|
store.register_early_pass(|| Box::new(misc_early::MiscEarlyLints));
|
|
|
|
|
store.register_early_pass(|| Box::new(redundant_closure_call::RedundantClosureCall));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(redundant_closure_call::RedundantClosureCall));
|
2021-08-06 17:14:27 +02:00
|
|
|
|
store.register_early_pass(|| Box::new(unused_unit::UnusedUnit));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(returns::Return));
|
2021-08-06 17:14:27 +02:00
|
|
|
|
store.register_early_pass(|| Box::new(collapsible_if::CollapsibleIf));
|
|
|
|
|
store.register_early_pass(|| Box::new(items_after_statements::ItemsAfterStatements));
|
|
|
|
|
store.register_early_pass(|| Box::new(precedence::Precedence));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(needless_parens_on_range_literals::NeedlessParensOnRangeLiterals));
|
2021-08-06 17:14:27 +02:00
|
|
|
|
store.register_early_pass(|| Box::new(needless_continue::NeedlessContinue));
|
|
|
|
|
store.register_early_pass(|| Box::new(redundant_else::RedundantElse));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(create_dir::CreateDir));
|
2021-08-06 17:14:27 +02:00
|
|
|
|
store.register_early_pass(|| Box::new(needless_arbitrary_self_type::NeedlessArbitrarySelfType));
|
2021-06-03 08:41:37 +02:00
|
|
|
|
let literal_representation_lint_fraction_readability = conf.unreadable_literal_lint_fractions;
|
2021-12-06 12:33:31 +01:00
|
|
|
|
store.register_early_pass(move || {
|
|
|
|
|
Box::new(literal_representation::LiteralDigitGrouping::new(
|
|
|
|
|
literal_representation_lint_fraction_readability,
|
|
|
|
|
))
|
|
|
|
|
});
|
2021-06-03 08:41:37 +02:00
|
|
|
|
let literal_representation_threshold = conf.literal_representation_threshold;
|
2021-12-06 12:33:31 +01:00
|
|
|
|
store.register_early_pass(move || {
|
|
|
|
|
Box::new(literal_representation::DecimalLiteralRepresentation::new(
|
|
|
|
|
literal_representation_threshold,
|
|
|
|
|
))
|
|
|
|
|
});
|
2021-06-03 08:41:37 +02:00
|
|
|
|
let enum_variant_name_threshold = conf.enum_variant_name_threshold;
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| {
|
2021-12-06 12:33:31 +01:00
|
|
|
|
Box::new(enum_variants::EnumVariantNames::new(
|
|
|
|
|
enum_variant_name_threshold,
|
|
|
|
|
avoid_breaking_exported_api,
|
|
|
|
|
))
|
|
|
|
|
});
|
2021-08-06 17:14:27 +02:00
|
|
|
|
store.register_early_pass(|| Box::new(tabs_in_doc_comments::TabsInDocComments));
|
2021-06-03 08:41:37 +02:00
|
|
|
|
let upper_case_acronyms_aggressive = conf.upper_case_acronyms_aggressive;
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| {
|
2021-12-06 12:33:31 +01:00
|
|
|
|
Box::new(upper_case_acronyms::UpperCaseAcronyms::new(
|
|
|
|
|
avoid_breaking_exported_api,
|
|
|
|
|
upper_case_acronyms_aggressive,
|
|
|
|
|
))
|
|
|
|
|
});
|
2022-10-06 09:44:38 +02:00
|
|
|
|
store.register_late_pass(|_| Box::<default::Default>::default());
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| Box::new(unused_self::UnusedSelf::new(avoid_breaking_exported_api)));
|
|
|
|
|
store.register_late_pass(|_| Box::new(mutable_debug_assertion::DebugAssertWithMutCall));
|
|
|
|
|
store.register_late_pass(|_| Box::new(exit::Exit));
|
|
|
|
|
store.register_late_pass(|_| Box::new(to_digit_is_some::ToDigitIsSome));
|
2021-06-03 08:41:37 +02:00
|
|
|
|
let array_size_threshold = conf.array_size_threshold;
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| Box::new(large_stack_arrays::LargeStackArrays::new(array_size_threshold)));
|
|
|
|
|
store.register_late_pass(move |_| Box::new(large_const_arrays::LargeConstArrays::new(array_size_threshold)));
|
|
|
|
|
store.register_late_pass(|_| Box::new(floating_point_arithmetic::FloatingPointArithmetic));
|
2021-08-06 17:14:27 +02:00
|
|
|
|
store.register_early_pass(|| Box::new(as_conversions::AsConversions));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(let_underscore::LetUnderscore));
|
2022-11-21 20:34:47 +01:00
|
|
|
|
store.register_early_pass(|| Box::<single_component_path_imports::SingleComponentPathImports>::default());
|
2021-06-03 08:41:37 +02:00
|
|
|
|
let max_fn_params_bools = conf.max_fn_params_bools;
|
|
|
|
|
let max_struct_bools = conf.max_struct_bools;
|
2022-11-21 20:34:47 +01:00
|
|
|
|
store.register_late_pass(move |_| {
|
2021-12-06 12:33:31 +01:00
|
|
|
|
Box::new(excessive_bools::ExcessiveBools::new(
|
|
|
|
|
max_struct_bools,
|
|
|
|
|
max_fn_params_bools,
|
|
|
|
|
))
|
|
|
|
|
});
|
2021-08-06 17:14:27 +02:00
|
|
|
|
store.register_early_pass(|| Box::new(option_env_unwrap::OptionEnvUnwrap));
|
2021-06-03 08:41:37 +02:00
|
|
|
|
let warn_on_all_wildcard_imports = conf.warn_on_all_wildcard_imports;
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| Box::new(wildcard_imports::WildcardImports::new(warn_on_all_wildcard_imports)));
|
2022-10-06 09:44:38 +02:00
|
|
|
|
store.register_late_pass(|_| Box::<redundant_pub_crate::RedundantPubCrate>::default());
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(unnamed_address::UnnamedAddress));
|
2022-12-01 18:29:38 +01:00
|
|
|
|
store.register_late_pass(move |_| Box::new(dereference::Dereferencing::new(msrv())));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(option_if_let_else::OptionIfLetElse));
|
|
|
|
|
store.register_late_pass(|_| Box::new(future_not_send::FutureNotSend));
|
|
|
|
|
store.register_late_pass(|_| Box::new(if_let_mutex::IfLetMutex));
|
|
|
|
|
store.register_late_pass(|_| Box::new(if_not_else::IfNotElse));
|
|
|
|
|
store.register_late_pass(|_| Box::new(equatable_if_let::PatternEquality));
|
|
|
|
|
store.register_late_pass(|_| Box::new(manual_async_fn::ManualAsyncFn));
|
|
|
|
|
store.register_late_pass(|_| Box::new(panic_in_result_fn::PanicInResultFn));
|
2021-06-03 08:41:37 +02:00
|
|
|
|
let single_char_binding_names_threshold = conf.single_char_binding_names_threshold;
|
2021-12-06 12:33:31 +01:00
|
|
|
|
store.register_early_pass(move || {
|
|
|
|
|
Box::new(non_expressive_names::NonExpressiveNames {
|
|
|
|
|
single_char_binding_names_threshold,
|
|
|
|
|
})
|
|
|
|
|
});
|
2021-07-01 18:17:38 +02:00
|
|
|
|
let macro_matcher = conf.standard_macro_braces.iter().cloned().collect::<FxHashSet<_>>();
|
2021-08-06 17:14:27 +02:00
|
|
|
|
store.register_early_pass(move || Box::new(nonstandard_macro_braces::MacroBraces::new(¯o_matcher)));
|
2022-10-06 09:44:38 +02:00
|
|
|
|
store.register_late_pass(|_| Box::<macro_use::MacroUseImports>::default());
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(pattern_type_mismatch::PatternTypeMismatch));
|
|
|
|
|
store.register_late_pass(|_| Box::new(unwrap_in_result::UnwrapInResult));
|
|
|
|
|
store.register_late_pass(|_| Box::new(semicolon_if_nothing_returned::SemicolonIfNothingReturned));
|
|
|
|
|
store.register_late_pass(|_| Box::new(async_yields_async::AsyncYieldsAsync));
|
2022-10-06 09:44:38 +02:00
|
|
|
|
let disallowed_macros = conf.disallowed_macros.clone();
|
|
|
|
|
store.register_late_pass(move |_| Box::new(disallowed_macros::DisallowedMacros::new(disallowed_macros.clone())));
|
2021-09-28 18:03:12 +01:00
|
|
|
|
let disallowed_methods = conf.disallowed_methods.clone();
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| Box::new(disallowed_methods::DisallowedMethods::new(disallowed_methods.clone())));
|
2021-08-06 17:14:27 +02:00
|
|
|
|
store.register_early_pass(|| Box::new(asm_syntax::InlineAsmX86AttSyntax));
|
|
|
|
|
store.register_early_pass(|| Box::new(asm_syntax::InlineAsmX86IntelSyntax));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(empty_drop::EmptyDrop));
|
|
|
|
|
store.register_late_pass(|_| Box::new(strings::StrToString));
|
|
|
|
|
store.register_late_pass(|_| Box::new(strings::StringToString));
|
|
|
|
|
store.register_late_pass(|_| Box::new(zero_sized_map_values::ZeroSizedMapValues));
|
2022-10-06 09:44:38 +02:00
|
|
|
|
store.register_late_pass(|_| Box::<vec_init_then_push::VecInitThenPush>::default());
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(redundant_slicing::RedundantSlicing));
|
|
|
|
|
store.register_late_pass(|_| Box::new(from_str_radix_10::FromStrRadix10));
|
2022-12-01 18:29:38 +01:00
|
|
|
|
store.register_late_pass(move |_| Box::new(if_then_some_else_none::IfThenSomeElseNone::new(msrv())));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(bool_assert_comparison::BoolAssertComparison));
|
2021-09-08 16:31:47 +02:00
|
|
|
|
store.register_early_pass(move || Box::new(module_style::ModStyle));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(unused_async::UnusedAsync));
|
2021-10-21 13:11:36 +02:00
|
|
|
|
let disallowed_types = conf.disallowed_types.clone();
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| Box::new(disallowed_types::DisallowedTypes::new(disallowed_types.clone())));
|
2021-07-01 18:17:38 +02:00
|
|
|
|
let import_renames = conf.enforced_import_renames.clone();
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| {
|
2021-12-06 12:33:31 +01:00
|
|
|
|
Box::new(missing_enforced_import_rename::ImportRename::new(
|
|
|
|
|
import_renames.clone(),
|
|
|
|
|
))
|
|
|
|
|
});
|
2021-07-01 18:17:38 +02:00
|
|
|
|
let scripts = conf.allowed_scripts.clone();
|
2021-08-06 17:14:27 +02:00
|
|
|
|
store.register_early_pass(move || Box::new(disallowed_script_idents::DisallowedScriptIdents::new(&scripts)));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(strlen_on_c_strings::StrlenOnCStrings));
|
|
|
|
|
store.register_late_pass(move |_| Box::new(self_named_constructors::SelfNamedConstructors));
|
|
|
|
|
store.register_late_pass(move |_| Box::new(iter_not_returning_iterator::IterNotReturningIterator));
|
|
|
|
|
store.register_late_pass(move |_| Box::new(manual_assert::ManualAssert));
|
2021-10-07 11:21:30 +02:00
|
|
|
|
let enable_raw_pointer_heuristic_for_send = conf.enable_raw_pointer_heuristic_for_send;
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| {
|
2021-12-06 12:33:31 +01:00
|
|
|
|
Box::new(non_send_fields_in_send_ty::NonSendFieldInSendTy::new(
|
|
|
|
|
enable_raw_pointer_heuristic_for_send,
|
|
|
|
|
))
|
|
|
|
|
});
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| Box::new(undocumented_unsafe_blocks::UndocumentedUnsafeBlocks));
|
2022-12-01 18:29:38 +01:00
|
|
|
|
let allow_mixed_uninlined = conf.allow_mixed_uninlined_format_args;
|
|
|
|
|
store.register_late_pass(move |_| Box::new(format_args::FormatArgs::new(msrv(), allow_mixed_uninlined)));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(trailing_empty_array::TrailingEmptyArray));
|
2021-12-06 12:33:31 +01:00
|
|
|
|
store.register_early_pass(|| Box::new(octal_escapes::OctalEscapes));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(needless_late_init::NeedlessLateInit));
|
|
|
|
|
store.register_late_pass(|_| Box::new(return_self_not_must_use::ReturnSelfNotMustUse));
|
|
|
|
|
store.register_late_pass(|_| Box::new(init_numbered_fields::NumberedFields));
|
2022-01-13 13:18:19 +01:00
|
|
|
|
store.register_early_pass(|| Box::new(single_char_lifetime_names::SingleCharLifetimeNames));
|
2022-12-01 18:29:38 +01:00
|
|
|
|
store.register_late_pass(move |_| Box::new(manual_bits::ManualBits::new(msrv())));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(default_union_representation::DefaultUnionRepresentation));
|
2022-10-06 09:44:38 +02:00
|
|
|
|
store.register_late_pass(|_| Box::<only_used_in_recursion::OnlyUsedInRecursion>::default());
|
2022-06-04 13:34:07 +02:00
|
|
|
|
let allow_dbg_in_tests = conf.allow_dbg_in_tests;
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| Box::new(dbg_macro::DbgMacro::new(allow_dbg_in_tests)));
|
2022-11-21 20:34:47 +01:00
|
|
|
|
let allow_print_in_tests = conf.allow_print_in_tests;
|
|
|
|
|
store.register_late_pass(move |_| Box::new(write::Write::new(allow_print_in_tests)));
|
2022-02-26 14:26:21 +01:00
|
|
|
|
let cargo_ignore_publish = conf.cargo_ignore_publish;
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| {
|
2022-02-26 14:26:21 +01:00
|
|
|
|
Box::new(cargo::Cargo {
|
|
|
|
|
ignore_publish: cargo_ignore_publish,
|
|
|
|
|
})
|
|
|
|
|
});
|
2022-04-07 18:39:59 +01:00
|
|
|
|
store.register_early_pass(|| Box::new(crate_in_macro_def::CrateInMacroDef));
|
|
|
|
|
store.register_early_pass(|| Box::new(empty_structs_with_brackets::EmptyStructsWithBrackets));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(unnecessary_owned_empty_strings::UnnecessaryOwnedEmptyStrings));
|
2022-05-05 15:12:52 +01:00
|
|
|
|
store.register_early_pass(|| Box::new(pub_use::PubUse));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(format_push_string::FormatPushString));
|
2022-05-05 15:12:52 +01:00
|
|
|
|
let max_include_file_size = conf.max_include_file_size;
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| Box::new(large_include_file::LargeIncludeFile::new(max_include_file_size)));
|
|
|
|
|
store.register_late_pass(|_| Box::new(strings::TrimSplitWhitespace));
|
|
|
|
|
store.register_late_pass(|_| Box::new(rc_clone_in_vec_init::RcCloneInVecInit));
|
2022-10-06 09:44:38 +02:00
|
|
|
|
store.register_early_pass(|| Box::<duplicate_mod::DuplicateMod>::default());
|
2022-06-04 13:34:07 +02:00
|
|
|
|
store.register_early_pass(|| Box::new(unused_rounding::UnusedRounding));
|
2022-12-17 14:12:54 +01:00
|
|
|
|
store.register_early_pass(move || Box::new(almost_complete_range::AlmostCompleteRange::new(msrv())));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(swap_ptr_to_ref::SwapPtrToRef));
|
|
|
|
|
store.register_late_pass(|_| Box::new(mismatching_type_param_order::TypeParamMismatch));
|
|
|
|
|
store.register_late_pass(|_| Box::new(read_zero_byte_vec::ReadZeroByteVec));
|
|
|
|
|
store.register_late_pass(|_| Box::new(default_instead_of_iter_empty::DefaultIterEmpty));
|
2022-12-01 18:29:38 +01:00
|
|
|
|
store.register_late_pass(move |_| Box::new(manual_rem_euclid::ManualRemEuclid::new(msrv())));
|
|
|
|
|
store.register_late_pass(move |_| Box::new(manual_retain::ManualRetain::new(msrv())));
|
2022-06-30 10:50:09 +02:00
|
|
|
|
let verbose_bit_mask_threshold = conf.verbose_bit_mask_threshold;
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(move |_| Box::new(operators::Operators::new(verbose_bit_mask_threshold)));
|
|
|
|
|
store.register_late_pass(|_| Box::new(invalid_utf8_in_unchecked::InvalidUtf8InUnchecked));
|
2022-10-06 09:44:38 +02:00
|
|
|
|
store.register_late_pass(|_| Box::<std_instead_of_core::StdReexports>::default());
|
2022-12-01 18:29:38 +01:00
|
|
|
|
store.register_late_pass(move |_| Box::new(instant_subtraction::InstantSubtraction::new(msrv())));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(partialeq_to_none::PartialeqToNone));
|
2022-12-01 18:29:38 +01:00
|
|
|
|
store.register_late_pass(move |_| Box::new(manual_clamp::ManualClamp::new(msrv())));
|
2022-09-06 14:23:03 -04:00
|
|
|
|
store.register_late_pass(|_| Box::new(manual_string_new::ManualStringNew));
|
|
|
|
|
store.register_late_pass(|_| Box::new(unused_peekable::UnusedPeekable));
|
2022-08-31 09:24:45 -04:00
|
|
|
|
store.register_early_pass(|| Box::new(multi_assignments::MultiAssignments));
|
2022-09-09 13:36:26 +02:00
|
|
|
|
store.register_late_pass(|_| Box::new(bool_to_int_with_if::BoolToIntWithIf));
|
2022-10-06 09:44:38 +02:00
|
|
|
|
store.register_late_pass(|_| Box::new(box_default::BoxDefault));
|
|
|
|
|
store.register_late_pass(|_| Box::new(implicit_saturating_add::ImplicitSaturatingAdd));
|
2022-10-23 15:18:45 +02:00
|
|
|
|
store.register_early_pass(|| Box::new(partial_pub_fields::PartialPubFields));
|
|
|
|
|
store.register_late_pass(|_| Box::new(missing_trait_methods::MissingTraitMethods));
|
2022-11-21 20:34:47 +01:00
|
|
|
|
store.register_late_pass(|_| Box::new(from_raw_with_void_ptr::FromRawWithVoidPtr));
|
|
|
|
|
store.register_late_pass(|_| Box::new(suspicious_xor_used_as_pow::ConfusingXorAndPow));
|
2022-12-01 18:29:38 +01:00
|
|
|
|
store.register_late_pass(move |_| Box::new(manual_is_ascii_check::ManualIsAsciiCheck::new(msrv())));
|
2022-12-17 14:12:54 +01:00
|
|
|
|
store.register_late_pass(|_| Box::new(semicolon_block::SemicolonBlock));
|
2022-12-29 14:28:34 +01:00
|
|
|
|
store.register_late_pass(|_| Box::new(fn_null_check::FnNullCheck));
|
|
|
|
|
store.register_late_pass(|_| Box::new(permissions_set_readonly_false::PermissionsSetReadonlyFalse));
|
|
|
|
|
store.register_late_pass(|_| Box::new(size_of_ref::SizeOfRef));
|
2023-01-27 21:09:08 +01:00
|
|
|
|
store.register_late_pass(|_| Box::new(multiple_unsafe_ops_per_block::MultipleUnsafeOpsPerBlock));
|
2021-11-04 12:52:36 +00:00
|
|
|
|
// add lints here, do not remove this comment, it's used in `new_lint`
|
2018-12-17 13:58:41 +01:00
|
|
|
|
}
|
2018-12-16 22:49:46 +01:00
|
|
|
|
|
2019-08-12 07:28:07 +02:00
|
|
|
|
#[rustfmt::skip]
|
2020-01-12 15:08:41 +09:00
|
|
|
|
fn register_removed_non_tool_lints(store: &mut rustc_lint::LintStore) {
|
2019-08-12 07:28:07 +02:00
|
|
|
|
store.register_removed(
|
|
|
|
|
"should_assert_eq",
|
|
|
|
|
"`assert!()` will be more flexible with RFC 2011",
|
|
|
|
|
);
|
|
|
|
|
store.register_removed(
|
|
|
|
|
"extend_from_slice",
|
|
|
|
|
"`.extend_from_slice(_)` is a faster way to extend a Vec by a slice",
|
|
|
|
|
);
|
|
|
|
|
store.register_removed(
|
|
|
|
|
"range_step_by_zero",
|
|
|
|
|
"`iterator.step_by(0)` panics nowadays",
|
|
|
|
|
);
|
|
|
|
|
store.register_removed(
|
|
|
|
|
"unstable_as_slice",
|
|
|
|
|
"`Vec::as_slice` has been stabilized in 1.7",
|
|
|
|
|
);
|
|
|
|
|
store.register_removed(
|
|
|
|
|
"unstable_as_mut_slice",
|
|
|
|
|
"`Vec::as_mut_slice` has been stabilized in 1.7",
|
|
|
|
|
);
|
|
|
|
|
store.register_removed(
|
|
|
|
|
"misaligned_transmute",
|
|
|
|
|
"this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr",
|
|
|
|
|
);
|
|
|
|
|
store.register_removed(
|
|
|
|
|
"assign_ops",
|
|
|
|
|
"using compound assignment operators (e.g., `+=`) is harmless",
|
|
|
|
|
);
|
|
|
|
|
store.register_removed(
|
|
|
|
|
"if_let_redundant_pattern_matching",
|
|
|
|
|
"this lint has been changed to redundant_pattern_matching",
|
|
|
|
|
);
|
|
|
|
|
store.register_removed(
|
|
|
|
|
"unsafe_vector_initialization",
|
|
|
|
|
"the replacement suggested by this lint had substantially different behavior",
|
|
|
|
|
);
|
2020-05-17 17:36:26 +02:00
|
|
|
|
store.register_removed(
|
|
|
|
|
"reverse_range_loop",
|
|
|
|
|
"this lint is now included in reversed_empty_ranges",
|
|
|
|
|
);
|
2019-08-12 07:28:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-11 07:59:57 +01:00
|
|
|
|
/// Register renamed lints.
|
|
|
|
|
///
|
|
|
|
|
/// Used in `./src/driver.rs`.
|
2020-01-12 15:08:41 +09:00
|
|
|
|
pub fn register_renamed(ls: &mut rustc_lint::LintStore) {
|
2022-05-05 15:12:52 +01:00
|
|
|
|
for (old_name, new_name) in renamed_lints::RENAMED_LINTS {
|
|
|
|
|
ls.register_renamed(old_name, new_name);
|
|
|
|
|
}
|
2016-05-24 18:25:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// only exists to let the dogfood integration test works.
|
|
|
|
|
// Don't run clippy as an executable directly
|
2018-11-17 13:47:27 +01:00
|
|
|
|
#[allow(dead_code)]
|
2016-05-24 18:25:25 +02:00
|
|
|
|
fn main() {
|
|
|
|
|
panic!("Please use the cargo-clippy executable");
|
|
|
|
|
}
|