2016-05-24 16:25:25 +00:00
|
|
|
|
// error-pattern:cargo-clippy
|
|
|
|
|
|
2022-02-19 22:56:42 +00:00
|
|
|
|
#![feature(array_windows)]
|
2021-12-30 14:10:43 +00:00
|
|
|
|
#![feature(binary_heap_into_iter_sorted)]
|
2019-07-21 10:52:14 +00:00
|
|
|
|
#![feature(box_patterns)]
|
2021-12-30 14:10:43 +00:00
|
|
|
|
#![feature(control_flow_enum)]
|
2020-06-23 15:05:22 +00:00
|
|
|
|
#![feature(drain_filter)]
|
2021-12-30 14:10:43 +00:00
|
|
|
|
#![feature(iter_intersperse)]
|
2022-02-01 19:53:12 +00:00
|
|
|
|
#![feature(let_chains)]
|
2021-12-30 14:10:43 +00:00
|
|
|
|
#![feature(let_else)]
|
2020-10-09 10:45:29 +00:00
|
|
|
|
#![feature(once_cell)]
|
2016-06-06 15:09:51 +00:00
|
|
|
|
#![feature(rustc_private)]
|
2016-05-24 16:25:25 +00:00
|
|
|
|
#![feature(stmt_expr_attributes)]
|
2019-05-13 23:34:08 +00:00
|
|
|
|
#![recursion_limit = "512"]
|
2019-07-15 05:35:02 +00:00
|
|
|
|
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
|
2020-06-23 15:05:22 +00: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 17:00:36 +00:00
|
|
|
|
#![warn(rustc::internal)]
|
2022-02-10 17:11:27 +00:00
|
|
|
|
// Disable this rustc lint for now, as it was also done in rustc
|
|
|
|
|
#![allow(rustc::potential_query_instability)]
|
2018-03-26 02:04:05 +00:00
|
|
|
|
|
2018-09-15 07:21:58 +00: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-01-06 18:37:37 +00:00
|
|
|
|
extern crate rustc_arena;
|
2020-03-01 03:23:33 +00:00
|
|
|
|
extern crate rustc_ast;
|
2020-02-01 21:56:27 +00:00
|
|
|
|
extern crate rustc_ast_pretty;
|
2022-02-01 02:22:47 +00:00
|
|
|
|
extern crate rustc_attr;
|
2018-09-15 07:21:58 +00:00
|
|
|
|
extern crate rustc_data_structures;
|
2020-12-20 16:19:49 +00:00
|
|
|
|
extern crate rustc_driver;
|
2018-09-15 07:21:58 +00:00
|
|
|
|
extern crate rustc_errors;
|
2020-01-06 16:39:50 +00:00
|
|
|
|
extern crate rustc_hir;
|
2020-03-27 14:34:29 +00:00
|
|
|
|
extern crate rustc_hir_pretty;
|
2019-10-01 23:02:18 +00:00
|
|
|
|
extern crate rustc_index;
|
2020-02-17 02:07:26 +00:00
|
|
|
|
extern crate rustc_infer;
|
2019-11-03 04:41:22 +00:00
|
|
|
|
extern crate rustc_lexer;
|
2020-01-12 06:08:41 +00:00
|
|
|
|
extern crate rustc_lint;
|
2020-03-30 09:02:14 +00:00
|
|
|
|
extern crate rustc_middle;
|
2021-01-05 18:53:07 +00:00
|
|
|
|
extern crate rustc_mir_dataflow;
|
2019-11-11 04:22:50 +00:00
|
|
|
|
extern crate rustc_parse;
|
2020-06-02 19:46:42 +00:00
|
|
|
|
extern crate rustc_parse_format;
|
2019-12-03 23:16:03 +00:00
|
|
|
|
extern crate rustc_session;
|
2019-12-31 00:17:56 +00:00
|
|
|
|
extern crate rustc_span;
|
2018-09-15 07:21:58 +00:00
|
|
|
|
extern crate rustc_target;
|
2020-03-14 20:26:32 +00:00
|
|
|
|
extern crate rustc_trait_selection;
|
2018-09-15 07:21:58 +00:00
|
|
|
|
extern crate rustc_typeck;
|
2016-05-24 16:25:25 +00:00
|
|
|
|
|
2021-06-03 06:41:37 +00:00
|
|
|
|
#[macro_use]
|
|
|
|
|
extern crate clippy_utils;
|
|
|
|
|
|
2021-03-25 18:29:11 +00:00
|
|
|
|
use clippy_utils::parse_msrv;
|
2019-10-11 01:46:22 +00:00
|
|
|
|
use rustc_data_structures::fx::FxHashSet;
|
2020-01-12 06:08:41 +00:00
|
|
|
|
use rustc_lint::LintId;
|
2020-03-18 22:45:02 +00:00
|
|
|
|
use rustc_session::Session;
|
2019-12-23 20:06:52 +00:00
|
|
|
|
|
2019-02-11 06:35:28 +00:00
|
|
|
|
/// Macro used to declare a Clippy lint.
|
|
|
|
|
///
|
|
|
|
|
/// Every lint declaration consists of 4 parts:
|
|
|
|
|
///
|
2019-03-05 16:50:33 +00:00
|
|
|
|
/// 1. The documentation, which is used for the website
|
2019-02-11 06:35:28 +00:00
|
|
|
|
/// 2. The `LINT_NAME`. See [lint naming][lint_naming] on lint naming conventions.
|
|
|
|
|
/// 3. The `lint_level`, which is a mapping from *one* of our lint groups to `Allow`, `Warn` or
|
|
|
|
|
/// `Deny`. The lint level here has nothing to do with what lint groups the lint is a part of.
|
|
|
|
|
/// 4. The `description` that contains a short explanation on what's wrong with code where the
|
|
|
|
|
/// lint is triggered.
|
|
|
|
|
///
|
2021-07-01 16:17:38 +00:00
|
|
|
|
/// Currently the categories `style`, `correctness`, `suspicious`, `complexity` and `perf` are
|
|
|
|
|
/// enabled by default. As said in the README.md of this repository, if the lint level mapping
|
|
|
|
|
/// changes, please update README.md.
|
2019-02-11 06:35:28 +00:00
|
|
|
|
///
|
|
|
|
|
/// # Example
|
|
|
|
|
///
|
|
|
|
|
/// ```
|
2020-06-23 15:05:22 +00:00
|
|
|
|
/// #![feature(rustc_private)]
|
|
|
|
|
/// extern crate rustc_session;
|
2019-12-03 23:16:03 +00:00
|
|
|
|
/// use rustc_session::declare_tool_lint;
|
2020-06-23 15:05:22 +00:00
|
|
|
|
/// use clippy_lints::declare_clippy_lint;
|
2019-02-11 06:35:28 +00:00
|
|
|
|
///
|
|
|
|
|
/// declare_clippy_lint! {
|
2021-07-29 10:16:06 +00:00
|
|
|
|
/// /// ### What it does
|
|
|
|
|
/// /// Checks for ... (describe what the lint matches).
|
2019-03-05 16:50:33 +00:00
|
|
|
|
/// ///
|
2021-07-29 10:16:06 +00:00
|
|
|
|
/// /// ### Why is this bad?
|
|
|
|
|
/// /// Supply the reason for linting the code.
|
2019-03-05 16:50:33 +00:00
|
|
|
|
/// ///
|
2021-07-29 10:16:06 +00:00
|
|
|
|
/// /// ### Example
|
2019-03-05 16:50:33 +00:00
|
|
|
|
/// /// ```rust
|
|
|
|
|
/// /// // Bad
|
|
|
|
|
/// /// Insert a short example of code that triggers the lint
|
|
|
|
|
/// ///
|
|
|
|
|
/// /// // Good
|
|
|
|
|
/// /// Insert a short example of improved code that doesn't trigger the lint
|
|
|
|
|
/// /// ```
|
2019-02-11 06:35:28 +00:00
|
|
|
|
/// pub LINT_NAME,
|
|
|
|
|
/// pedantic,
|
|
|
|
|
/// "description"
|
|
|
|
|
/// }
|
|
|
|
|
/// ```
|
|
|
|
|
/// [lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints
|
2018-10-12 06:09:04 +00:00
|
|
|
|
#[macro_export]
|
2018-03-27 15:13:55 +00:00
|
|
|
|
macro_rules! declare_clippy_lint {
|
2019-03-05 16:50:33 +00:00
|
|
|
|
{ $(#[$attr:meta])* pub $name:tt, style, $description:tt } => {
|
|
|
|
|
declare_tool_lint! {
|
|
|
|
|
$(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true
|
|
|
|
|
}
|
2018-03-27 15:13:55 +00:00
|
|
|
|
};
|
2019-03-05 16:50:33 +00:00
|
|
|
|
{ $(#[$attr:meta])* pub $name:tt, correctness, $description:tt } => {
|
|
|
|
|
declare_tool_lint! {
|
|
|
|
|
$(#[$attr])* pub clippy::$name, Deny, $description, report_in_external_macro: true
|
|
|
|
|
}
|
2018-03-27 15:13:55 +00:00
|
|
|
|
};
|
2021-07-01 16:17:38 +00:00
|
|
|
|
{ $(#[$attr:meta])* pub $name:tt, suspicious, $description:tt } => {
|
|
|
|
|
declare_tool_lint! {
|
|
|
|
|
$(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true
|
|
|
|
|
}
|
|
|
|
|
};
|
2019-03-05 16:50:33 +00:00
|
|
|
|
{ $(#[$attr:meta])* pub $name:tt, complexity, $description:tt } => {
|
|
|
|
|
declare_tool_lint! {
|
2019-08-02 06:13:54 +00:00
|
|
|
|
$(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true
|
2019-03-05 16:50:33 +00:00
|
|
|
|
}
|
2018-03-27 15:13:55 +00:00
|
|
|
|
};
|
2019-03-05 16:50:33 +00:00
|
|
|
|
{ $(#[$attr:meta])* pub $name:tt, perf, $description:tt } => {
|
|
|
|
|
declare_tool_lint! {
|
2019-08-03 06:01:27 +00:00
|
|
|
|
$(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true
|
2019-03-05 16:50:33 +00:00
|
|
|
|
}
|
2018-03-27 15:13:55 +00:00
|
|
|
|
};
|
2019-03-05 16:50:33 +00:00
|
|
|
|
{ $(#[$attr:meta])* pub $name:tt, pedantic, $description:tt } => {
|
|
|
|
|
declare_tool_lint! {
|
2019-08-03 16:42:05 +00:00
|
|
|
|
$(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true
|
2019-03-05 16:50:33 +00:00
|
|
|
|
}
|
2018-03-28 13:24:26 +00:00
|
|
|
|
};
|
2019-03-05 16:50:33 +00:00
|
|
|
|
{ $(#[$attr:meta])* pub $name:tt, restriction, $description:tt } => {
|
|
|
|
|
declare_tool_lint! {
|
2019-08-03 19:24:50 +00:00
|
|
|
|
$(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true
|
2019-03-05 16:50:33 +00:00
|
|
|
|
}
|
2018-03-28 13:24:26 +00:00
|
|
|
|
};
|
2019-03-05 16:50:33 +00:00
|
|
|
|
{ $(#[$attr:meta])* pub $name:tt, cargo, $description:tt } => {
|
|
|
|
|
declare_tool_lint! {
|
2019-08-03 06:01:27 +00:00
|
|
|
|
$(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true
|
2019-03-05 16:50:33 +00:00
|
|
|
|
}
|
2018-04-29 23:20:39 +00:00
|
|
|
|
};
|
2019-03-05 16:50:33 +00:00
|
|
|
|
{ $(#[$attr:meta])* pub $name:tt, nursery, $description:tt } => {
|
|
|
|
|
declare_tool_lint! {
|
2019-08-03 19:01:23 +00:00
|
|
|
|
$(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true
|
2019-03-05 16:50:33 +00:00
|
|
|
|
}
|
2018-03-28 13:24:26 +00:00
|
|
|
|
};
|
2019-03-05 16:50:33 +00:00
|
|
|
|
{ $(#[$attr:meta])* pub $name:tt, internal, $description:tt } => {
|
|
|
|
|
declare_tool_lint! {
|
2019-08-03 06:12:53 +00:00
|
|
|
|
$(#[$attr])* pub clippy::$name, Allow, $description, report_in_external_macro: true
|
2019-03-05 16:50:33 +00:00
|
|
|
|
}
|
2018-03-28 13:24:26 +00:00
|
|
|
|
};
|
2019-03-05 16:50:33 +00:00
|
|
|
|
{ $(#[$attr:meta])* pub $name:tt, internal_warn, $description:tt } => {
|
|
|
|
|
declare_tool_lint! {
|
2019-08-03 06:12:53 +00:00
|
|
|
|
$(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true
|
2019-03-05 16:50:33 +00:00
|
|
|
|
}
|
2018-03-29 11:41:53 +00:00
|
|
|
|
};
|
2018-03-27 15:13:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-13 12:18:19 +00:00
|
|
|
|
#[cfg(feature = "internal")]
|
2021-05-20 10:30:31 +00:00
|
|
|
|
mod deprecated_lints;
|
2022-01-13 12:18:19 +00:00
|
|
|
|
#[cfg_attr(feature = "internal", allow(clippy::missing_clippy_version_attribute))]
|
2021-06-03 06:41:37 +00:00
|
|
|
|
mod utils;
|
2016-05-24 16:25:25 +00:00
|
|
|
|
|
|
|
|
|
// begin lints modules, do not remove this comment, it’s used in `update_lints`
|
2021-04-08 15:50:13 +00:00
|
|
|
|
mod absurd_extreme_comparisons;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod approx_const;
|
|
|
|
|
mod arithmetic;
|
|
|
|
|
mod as_conversions;
|
2020-10-09 10:45:29 +00:00
|
|
|
|
mod asm_syntax;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod assertions_on_constants;
|
|
|
|
|
mod assign_ops;
|
2020-09-10 15:47:07 +00:00
|
|
|
|
mod async_yields_async;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod attrs;
|
2020-10-28 22:36:07 +00:00
|
|
|
|
mod await_holding_invalid;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod bit_mask;
|
|
|
|
|
mod blacklisted_name;
|
2020-05-17 15:36:26 +00:00
|
|
|
|
mod blocks_in_if_conditions;
|
2021-04-22 09:31:13 +00:00
|
|
|
|
mod bool_assert_comparison;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod booleans;
|
2022-01-13 12:18:19 +00:00
|
|
|
|
mod borrow_as_ptr;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod bytecount;
|
2022-01-31 00:16:10 +00:00
|
|
|
|
mod bytes_count_to_len;
|
2022-02-13 21:54:33 +00:00
|
|
|
|
mod cargo;
|
2021-01-30 17:06:34 +00:00
|
|
|
|
mod case_sensitive_file_extension_comparisons;
|
2021-03-12 14:30:50 +00:00
|
|
|
|
mod casts;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod checked_conversions;
|
|
|
|
|
mod cognitive_complexity;
|
|
|
|
|
mod collapsible_if;
|
2020-12-06 14:01:03 +00:00
|
|
|
|
mod collapsible_match;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod comparison_chain;
|
|
|
|
|
mod copies;
|
|
|
|
|
mod copy_iterator;
|
2022-03-24 01:08:52 +00:00
|
|
|
|
mod crate_in_macro_def;
|
2020-09-10 15:47:07 +00:00
|
|
|
|
mod create_dir;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod dbg_macro;
|
2020-11-05 13:29:48 +00:00
|
|
|
|
mod default;
|
2021-02-25 10:25:22 +00:00
|
|
|
|
mod default_numeric_fallback;
|
2022-01-15 09:27:24 +00:00
|
|
|
|
mod default_union_representation;
|
2020-03-21 18:34:56 +00:00
|
|
|
|
mod dereference;
|
2021-09-08 14:31:47 +00:00
|
|
|
|
mod derivable_impls;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod derive;
|
2021-12-06 11:33:31 +00:00
|
|
|
|
mod disallowed_methods;
|
2021-07-01 16:17:38 +00:00
|
|
|
|
mod disallowed_script_idents;
|
2021-12-06 11:33:31 +00:00
|
|
|
|
mod disallowed_types;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod doc;
|
|
|
|
|
mod double_comparison;
|
|
|
|
|
mod double_parens;
|
|
|
|
|
mod drop_forget_ref;
|
|
|
|
|
mod duration_subsec;
|
|
|
|
|
mod else_if_without_else;
|
2022-03-25 19:31:52 +00:00
|
|
|
|
mod empty_drop;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod empty_enum;
|
2022-03-28 09:35:43 +00:00
|
|
|
|
mod empty_structs_with_brackets;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod entry;
|
|
|
|
|
mod enum_clike;
|
|
|
|
|
mod enum_variants;
|
|
|
|
|
mod eq_op;
|
2021-10-07 09:21:30 +00:00
|
|
|
|
mod equatable_if_let;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod erasing_op;
|
|
|
|
|
mod escape;
|
|
|
|
|
mod eta_reduction;
|
|
|
|
|
mod eval_order_dependence;
|
|
|
|
|
mod excessive_bools;
|
2021-01-30 17:06:34 +00:00
|
|
|
|
mod exhaustive_items;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod exit;
|
|
|
|
|
mod explicit_write;
|
|
|
|
|
mod fallible_impl_from;
|
2020-08-28 14:10:16 +00:00
|
|
|
|
mod float_equality_without_abs;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod float_literal;
|
|
|
|
|
mod floating_point_arithmetic;
|
|
|
|
|
mod format;
|
2021-10-21 11:11:36 +00:00
|
|
|
|
mod format_args;
|
2022-02-17 11:20:47 +00:00
|
|
|
|
mod format_impl;
|
2022-04-04 03:40:58 +00:00
|
|
|
|
mod format_push_string;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod formatting;
|
2021-01-02 15:29:43 +00:00
|
|
|
|
mod from_over_into;
|
2021-02-25 10:25:22 +00:00
|
|
|
|
mod from_str_radix_10;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod functions;
|
2020-04-07 13:39:07 +00:00
|
|
|
|
mod future_not_send;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod get_last_with_len;
|
|
|
|
|
mod identity_op;
|
2020-03-05 13:36:19 +00:00
|
|
|
|
mod if_let_mutex;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod if_not_else;
|
2021-03-25 18:29:11 +00:00
|
|
|
|
mod if_then_some_else_none;
|
2021-04-08 15:50:13 +00:00
|
|
|
|
mod implicit_hasher;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod implicit_return;
|
2020-04-06 18:07:57 +00:00
|
|
|
|
mod implicit_saturating_sub;
|
2021-02-25 10:25:22 +00:00
|
|
|
|
mod inconsistent_struct_constructor;
|
2021-12-06 11:33:31 +00:00
|
|
|
|
mod index_refutable_slice;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod indexing_slicing;
|
|
|
|
|
mod infinite_iter;
|
|
|
|
|
mod inherent_impl;
|
|
|
|
|
mod inherent_to_string;
|
2021-12-30 14:10:43 +00:00
|
|
|
|
mod init_numbered_fields;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod inline_fn_without_body;
|
|
|
|
|
mod int_plus_one;
|
|
|
|
|
mod integer_division;
|
2021-04-08 15:50:13 +00:00
|
|
|
|
mod invalid_upcast_comparisons;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod items_after_statements;
|
2021-09-28 17:03:12 +00:00
|
|
|
|
mod iter_not_returning_iterator;
|
2020-03-23 21:07:46 +00:00
|
|
|
|
mod large_const_arrays;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod large_enum_variant;
|
2022-04-21 15:01:18 +00:00
|
|
|
|
mod large_include_file;
|
2020-04-02 20:08:25 +00: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 18:23:47 +00:00
|
|
|
|
mod manual_async_fn;
|
2022-01-13 12:18:19 +00:00
|
|
|
|
mod manual_bits;
|
2021-02-25 10:25:22 +00:00
|
|
|
|
mod manual_map;
|
2020-05-11 18:23:47 +00:00
|
|
|
|
mod manual_non_exhaustive;
|
2020-11-05 13:29:48 +00:00
|
|
|
|
mod manual_ok_or;
|
2020-09-24 12:49:22 +00:00
|
|
|
|
mod manual_strip;
|
2020-10-23 20:16:59 +00:00
|
|
|
|
mod manual_unwrap_or;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod map_clone;
|
2020-09-24 12:49:22 +00:00
|
|
|
|
mod map_err_ignore;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod map_unit_fn;
|
2020-04-25 08:33:40 +00:00
|
|
|
|
mod match_on_vec_items;
|
2021-09-28 17:03:12 +00:00
|
|
|
|
mod match_result_ok;
|
2021-10-21 11:11:36 +00:00
|
|
|
|
mod match_str_case_mismatch;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod matches;
|
|
|
|
|
mod mem_forget;
|
|
|
|
|
mod mem_replace;
|
|
|
|
|
mod methods;
|
|
|
|
|
mod minmax;
|
|
|
|
|
mod misc;
|
|
|
|
|
mod misc_early;
|
|
|
|
|
mod missing_const_for_fn;
|
|
|
|
|
mod missing_doc;
|
2021-07-01 16:17:38 +00:00
|
|
|
|
mod missing_enforced_import_rename;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod missing_inline;
|
2021-09-08 14:31:47 +00:00
|
|
|
|
mod module_style;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod modulo_arithmetic;
|
|
|
|
|
mod mut_key;
|
|
|
|
|
mod mut_mut;
|
2020-10-28 22:36:07 +00:00
|
|
|
|
mod mut_mutex_lock;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod mut_reference;
|
|
|
|
|
mod mutable_debug_assertion;
|
|
|
|
|
mod mutex_atomic;
|
2020-08-11 13:43:21 +00:00
|
|
|
|
mod needless_arbitrary_self_type;
|
2021-05-20 10:30:31 +00:00
|
|
|
|
mod needless_bitwise_bool;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod needless_bool;
|
|
|
|
|
mod needless_borrowed_ref;
|
|
|
|
|
mod needless_continue;
|
2021-04-08 15:50:13 +00:00
|
|
|
|
mod needless_for_each;
|
2021-12-06 11:33:31 +00:00
|
|
|
|
mod needless_late_init;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod needless_pass_by_value;
|
2021-01-15 09:56:44 +00:00
|
|
|
|
mod needless_question_mark;
|
2020-04-02 20:08:25 +00: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 15:50:13 +00:00
|
|
|
|
mod non_octal_unix_permissions;
|
2021-10-07 09:21:30 +00:00
|
|
|
|
mod non_send_fields_in_send_ty;
|
2021-07-01 16:17:38 +00:00
|
|
|
|
mod nonstandard_macro_braces;
|
2021-12-06 11:33:31 +00:00
|
|
|
|
mod octal_escapes;
|
2022-02-12 17:32:09 +00:00
|
|
|
|
mod only_used_in_recursion;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod open_options;
|
|
|
|
|
mod option_env_unwrap;
|
2020-07-14 12:59:59 +00:00
|
|
|
|
mod option_if_let_else;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod overflow_check_conditional;
|
2020-09-24 12:49:22 +00:00
|
|
|
|
mod panic_in_result_fn;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod panic_unimplemented;
|
|
|
|
|
mod partialeq_ne_impl;
|
2020-10-28 22:36:07 +00:00
|
|
|
|
mod pass_by_ref_or_value;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod path_buf_push_overwrite;
|
2020-07-14 12:59:59 +00:00
|
|
|
|
mod pattern_type_mismatch;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod precedence;
|
|
|
|
|
mod ptr;
|
2020-10-23 20:16:59 +00:00
|
|
|
|
mod ptr_eq;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod ptr_offset_with_cast;
|
2022-04-12 09:09:34 +00:00
|
|
|
|
mod pub_use;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod question_mark;
|
|
|
|
|
mod ranges;
|
|
|
|
|
mod redundant_clone;
|
2020-07-26 19:07:07 +00:00
|
|
|
|
mod redundant_closure_call;
|
2020-12-20 16:19:49 +00:00
|
|
|
|
mod redundant_else;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod redundant_field_names;
|
|
|
|
|
mod redundant_pub_crate;
|
2021-01-30 17:06:34 +00:00
|
|
|
|
mod redundant_slicing;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod redundant_static_lifetimes;
|
2020-11-05 13:29:48 +00:00
|
|
|
|
mod ref_option_ref;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod reference;
|
|
|
|
|
mod regex;
|
2020-07-14 12:59:59 +00:00
|
|
|
|
mod repeat_once;
|
2021-12-17 12:40:22 +00:00
|
|
|
|
mod return_self_not_must_use;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod returns;
|
2021-09-28 17:03:12 +00:00
|
|
|
|
mod same_name_method;
|
2020-08-28 14:10:16 +00:00
|
|
|
|
mod self_assignment;
|
2021-07-29 10:16:06 +00:00
|
|
|
|
mod self_named_constructors;
|
2021-02-11 14:04:38 +00:00
|
|
|
|
mod semicolon_if_nothing_returned;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod serde_api;
|
|
|
|
|
mod shadow;
|
2022-01-13 12:18:19 +00:00
|
|
|
|
mod single_char_lifetime_names;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod single_component_path_imports;
|
2020-12-06 14:01:03 +00:00
|
|
|
|
mod size_of_in_element_count;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod slow_vector_initialization;
|
2020-08-11 13:43:21 +00:00
|
|
|
|
mod stable_sort_primitive;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod strings;
|
2021-07-15 08:44:10 +00:00
|
|
|
|
mod strlen_on_c_strings;
|
2020-12-06 14:01:03 +00:00
|
|
|
|
mod suspicious_operation_groupings;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod suspicious_trait_impl;
|
|
|
|
|
mod swap;
|
|
|
|
|
mod tabs_in_doc_comments;
|
|
|
|
|
mod temporary_assignment;
|
|
|
|
|
mod to_digit_is_some;
|
2021-10-21 11:11:36 +00:00
|
|
|
|
mod trailing_empty_array;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod trait_bounds;
|
|
|
|
|
mod transmute;
|
|
|
|
|
mod transmuting_null;
|
|
|
|
|
mod try_err;
|
|
|
|
|
mod types;
|
2021-10-21 11:11:36 +00:00
|
|
|
|
mod undocumented_unsafe_blocks;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod unicode;
|
2021-10-21 11:11:36 +00:00
|
|
|
|
mod uninit_vec;
|
2021-11-04 12:52:36 +00:00
|
|
|
|
mod unit_hash;
|
2020-07-26 19:07:07 +00:00
|
|
|
|
mod unit_return_expecting_ord;
|
2021-03-25 18:29:11 +00:00
|
|
|
|
mod unit_types;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod unnamed_address;
|
2022-04-11 11:05:42 +00:00
|
|
|
|
mod unnecessary_owned_empty_strings;
|
2021-04-22 09:31:13 +00:00
|
|
|
|
mod unnecessary_self_imports;
|
2020-06-09 14:36:01 +00:00
|
|
|
|
mod unnecessary_sort_by;
|
2020-11-23 12:51:04 +00:00
|
|
|
|
mod unnecessary_wraps;
|
2020-06-09 14:36:01 +00:00
|
|
|
|
mod unnested_or_patterns;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod unsafe_removed_from_name;
|
2021-05-20 10:30:31 +00:00
|
|
|
|
mod unused_async;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod unused_io_amount;
|
|
|
|
|
mod unused_self;
|
2020-08-28 14:10:16 +00:00
|
|
|
|
mod unused_unit;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod unwrap;
|
2020-08-28 14:10:16 +00:00
|
|
|
|
mod unwrap_in_result;
|
2021-01-30 17:06:34 +00:00
|
|
|
|
mod upper_case_acronyms;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod use_self;
|
2020-05-17 15:36:26 +00:00
|
|
|
|
mod useless_conversion;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod vec;
|
2021-01-15 09:56:44 +00:00
|
|
|
|
mod vec_init_then_push;
|
2020-06-09 14:36:01 +00:00
|
|
|
|
mod vec_resize_to_zero;
|
2020-04-02 20:08:25 +00:00
|
|
|
|
mod verbose_file_reads;
|
|
|
|
|
mod wildcard_imports;
|
|
|
|
|
mod write;
|
|
|
|
|
mod zero_div_zero;
|
2020-12-20 16:19:49 +00:00
|
|
|
|
mod zero_sized_map_values;
|
2016-05-24 16:25:25 +00:00
|
|
|
|
// end lints modules, do not remove this comment, it’s used in `update_lints`
|
|
|
|
|
|
2018-09-03 01:57:50 +00:00
|
|
|
|
pub use crate::utils::conf::Conf;
|
2021-05-06 09:51:22 +00:00
|
|
|
|
use crate::utils::conf::TryConf;
|
2018-08-15 06:11:07 +00:00
|
|
|
|
|
2019-02-11 06:59:57 +00:00
|
|
|
|
/// Register all pre expansion lints
|
|
|
|
|
///
|
|
|
|
|
/// Pre-expansion lints run before any macro expansion has happened.
|
|
|
|
|
///
|
2019-04-04 09:15:30 +00:00
|
|
|
|
/// Note that due to the architecture of the compiler, currently `cfg_attr` attributes on crate
|
2019-02-11 21:32:54 +00:00
|
|
|
|
/// level (i.e `#![cfg_attr(...)]`) will still be expanded even when using a pre-expansion pass.
|
2019-02-11 06:59:57 +00:00
|
|
|
|
///
|
|
|
|
|
/// Used in `./src/driver.rs`.
|
2021-12-06 11:33:31 +00:00
|
|
|
|
pub fn register_pre_expansion_lints(store: &mut rustc_lint::LintStore, sess: &Session, conf: &Conf) {
|
2021-04-22 09:31:13 +00:00
|
|
|
|
// NOTE: Do not add any more pre-expansion passes. These should be removed eventually.
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
|
|
|
|
let msrv = conf.msrv.as_ref().and_then(|s| {
|
|
|
|
|
parse_msrv(s, None, None).or_else(|| {
|
|
|
|
|
sess.err(&format!(
|
|
|
|
|
"error reading Clippy's configuration file. `{}` is not a valid Rust version",
|
|
|
|
|
s
|
|
|
|
|
));
|
|
|
|
|
None
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_pre_expansion_pass(|| Box::new(write::Write::default()));
|
2021-12-06 11:33:31 +00:00
|
|
|
|
store.register_pre_expansion_pass(move || Box::new(attrs::EarlyAttributes { msrv }));
|
2018-08-16 05:13:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-11 06:59:57 +00:00
|
|
|
|
#[doc(hidden)]
|
2021-05-06 09:51:22 +00:00
|
|
|
|
pub fn read_conf(sess: &Session) -> Conf {
|
|
|
|
|
let file_name = match utils::conf::lookup_conf_file() {
|
|
|
|
|
Ok(Some(path)) => path,
|
|
|
|
|
Ok(None) => return Conf::default(),
|
|
|
|
|
Err(error) => {
|
|
|
|
|
sess.struct_err(&format!("error finding Clippy's configuration file: {}", error))
|
2018-11-27 20:14:15 +00:00
|
|
|
|
.emit();
|
2021-05-06 09:51:22 +00:00
|
|
|
|
return Conf::default();
|
2019-10-24 09:55:22 +00:00
|
|
|
|
},
|
2021-05-06 09:51:22 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let TryConf { conf, errors } = utils::conf::read(&file_name);
|
|
|
|
|
// all conf errors are non-fatal, we just use the default conf in case of error
|
|
|
|
|
for error in errors {
|
|
|
|
|
sess.struct_err(&format!(
|
|
|
|
|
"error reading Clippy's configuration file `{}`: {}",
|
|
|
|
|
file_name.display(),
|
|
|
|
|
error
|
|
|
|
|
))
|
|
|
|
|
.emit();
|
2018-08-15 06:11:07 +00:00
|
|
|
|
}
|
2021-05-06 09:51:22 +00:00
|
|
|
|
|
|
|
|
|
conf
|
2018-08-15 06:11:07 +00:00
|
|
|
|
}
|
2016-05-24 16:25:25 +00:00
|
|
|
|
|
2019-02-11 06:59:57 +00:00
|
|
|
|
/// Register all lints and lint groups with the rustc plugin registry
|
|
|
|
|
///
|
|
|
|
|
/// Used in `./src/driver.rs`.
|
2019-01-13 15:19:02 +00:00
|
|
|
|
#[allow(clippy::too_many_lines)]
|
2020-01-12 06:08:41 +00:00
|
|
|
|
pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: &Conf) {
|
2019-10-11 01:46:22 +00:00
|
|
|
|
register_removed_non_tool_lints(store);
|
2019-08-12 05:28:07 +00:00
|
|
|
|
|
2021-10-07 09:21:30 +00:00
|
|
|
|
include!("lib.deprecated.rs");
|
2016-05-24 16:25:25 +00:00
|
|
|
|
|
2021-10-07 09:21:30 +00:00
|
|
|
|
include!("lib.register_lints.rs");
|
|
|
|
|
include!("lib.register_restriction.rs");
|
|
|
|
|
include!("lib.register_pedantic.rs");
|
2020-12-06 14:01:03 +00:00
|
|
|
|
|
2022-01-13 12:18:19 +00:00
|
|
|
|
#[cfg(feature = "internal")]
|
2021-10-07 09:21:30 +00:00
|
|
|
|
include!("lib.register_internal.rs");
|
2021-06-03 06:41:37 +00:00
|
|
|
|
|
2021-10-07 09:21:30 +00:00
|
|
|
|
include!("lib.register_all.rs");
|
|
|
|
|
include!("lib.register_style.rs");
|
|
|
|
|
include!("lib.register_complexity.rs");
|
|
|
|
|
include!("lib.register_correctness.rs");
|
|
|
|
|
include!("lib.register_suspicious.rs");
|
|
|
|
|
include!("lib.register_perf.rs");
|
|
|
|
|
include!("lib.register_cargo.rs");
|
|
|
|
|
include!("lib.register_nursery.rs");
|
2021-06-03 06:41:37 +00:00
|
|
|
|
|
2022-01-13 12:18:19 +00:00
|
|
|
|
#[cfg(feature = "internal")]
|
2021-06-03 06:41:37 +00:00
|
|
|
|
{
|
|
|
|
|
if std::env::var("ENABLE_METADATA_COLLECTION").eq(&Ok("1".to_string())) {
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(utils::internal_lints::metadata_collector::MetadataCollector::new()));
|
2021-06-03 06:41:37 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// all the internal lints
|
2022-01-13 12:18:19 +00:00
|
|
|
|
#[cfg(feature = "internal")]
|
2021-06-03 06:41:37 +00:00
|
|
|
|
{
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_early_pass(|| Box::new(utils::internal_lints::ClippyLintsInternal));
|
|
|
|
|
store.register_early_pass(|| Box::new(utils::internal_lints::ProduceIce));
|
|
|
|
|
store.register_late_pass(|| Box::new(utils::internal_lints::CollapsibleCalls));
|
|
|
|
|
store.register_late_pass(|| Box::new(utils::internal_lints::CompilerLintFunctions::new()));
|
|
|
|
|
store.register_late_pass(|| Box::new(utils::internal_lints::IfChainStyle));
|
|
|
|
|
store.register_late_pass(|| Box::new(utils::internal_lints::InvalidPaths));
|
|
|
|
|
store.register_late_pass(|| Box::new(utils::internal_lints::InterningDefinedSymbol::default()));
|
|
|
|
|
store.register_late_pass(|| Box::new(utils::internal_lints::LintWithoutLintPass::default()));
|
|
|
|
|
store.register_late_pass(|| Box::new(utils::internal_lints::MatchTypeOnDiagItem));
|
|
|
|
|
store.register_late_pass(|| Box::new(utils::internal_lints::OuterExpnDataPass));
|
2022-01-19 16:35:52 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(utils::internal_lints::MsrvAttrImpl));
|
2021-06-03 06:41:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-15 09:37:58 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(utils::dump_hir::DumpHir));
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(utils::author::Author));
|
2022-04-14 23:52:10 +00:00
|
|
|
|
let await_holding_invalid_types = conf.await_holding_invalid_types.clone();
|
|
|
|
|
store.register_late_pass(move || {
|
|
|
|
|
Box::new(await_holding_invalid::AwaitHolding::new(
|
|
|
|
|
await_holding_invalid_types.clone(),
|
|
|
|
|
))
|
|
|
|
|
});
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(serde_api::SerdeApi));
|
2021-06-03 06:41:37 +00:00
|
|
|
|
let vec_box_size_threshold = conf.vec_box_size_threshold;
|
|
|
|
|
let type_complexity_threshold = conf.type_complexity_threshold;
|
2021-09-08 14:31:47 +00:00
|
|
|
|
let avoid_breaking_exported_api = conf.avoid_breaking_exported_api;
|
2021-12-06 11:33:31 +00:00
|
|
|
|
store.register_late_pass(move || {
|
|
|
|
|
Box::new(types::Types::new(
|
|
|
|
|
vec_box_size_threshold,
|
|
|
|
|
type_complexity_threshold,
|
|
|
|
|
avoid_breaking_exported_api,
|
|
|
|
|
))
|
|
|
|
|
});
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(booleans::NonminimalBool));
|
|
|
|
|
store.register_late_pass(|| Box::new(needless_bitwise_bool::NeedlessBitwiseBool));
|
|
|
|
|
store.register_late_pass(|| Box::new(eq_op::EqOp));
|
|
|
|
|
store.register_late_pass(|| Box::new(enum_clike::UnportableVariant));
|
|
|
|
|
store.register_late_pass(|| Box::new(float_literal::FloatLiteral));
|
2021-06-03 06:41:37 +00:00
|
|
|
|
let verbose_bit_mask_threshold = conf.verbose_bit_mask_threshold;
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_late_pass(move || Box::new(bit_mask::BitMask::new(verbose_bit_mask_threshold)));
|
|
|
|
|
store.register_late_pass(|| Box::new(ptr::Ptr));
|
|
|
|
|
store.register_late_pass(|| Box::new(ptr_eq::PtrEq));
|
|
|
|
|
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));
|
|
|
|
|
store.register_late_pass(|| Box::new(misc::MiscLints));
|
|
|
|
|
store.register_late_pass(|| Box::new(eta_reduction::EtaReduction));
|
|
|
|
|
store.register_late_pass(|| Box::new(identity_op::IdentityOp));
|
|
|
|
|
store.register_late_pass(|| Box::new(erasing_op::ErasingOp));
|
|
|
|
|
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(collapsible_match::CollapsibleMatch));
|
|
|
|
|
store.register_late_pass(|| Box::new(unicode::Unicode));
|
2021-10-21 11:11:36 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(uninit_vec::UninitVec));
|
2021-11-04 12:52:36 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(unit_hash::UnitHash));
|
2021-08-06 15:14:27 +00:00
|
|
|
|
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));
|
|
|
|
|
store.register_early_pass(|| Box::new(unnecessary_self_imports::UnnecessarySelfImports));
|
2021-06-03 06:41:37 +00:00
|
|
|
|
|
|
|
|
|
let msrv = conf.msrv.as_ref().and_then(|s| {
|
|
|
|
|
parse_msrv(s, None, None).or_else(|| {
|
2021-12-06 11:33:31 +00:00
|
|
|
|
sess.err(&format!(
|
|
|
|
|
"error reading Clippy's configuration file. `{}` is not a valid Rust version",
|
|
|
|
|
s
|
|
|
|
|
));
|
2021-06-03 06:41:37 +00:00
|
|
|
|
None
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let avoid_breaking_exported_api = conf.avoid_breaking_exported_api;
|
2021-09-08 14:31:47 +00:00
|
|
|
|
store.register_late_pass(move || Box::new(approx_const::ApproxConstant::new(msrv)));
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_late_pass(move || Box::new(methods::Methods::new(avoid_breaking_exported_api, msrv)));
|
|
|
|
|
store.register_late_pass(move || Box::new(matches::Matches::new(msrv)));
|
2022-04-06 13:26:59 +00:00
|
|
|
|
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)));
|
2021-08-06 15:14:27 +00:00
|
|
|
|
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)));
|
|
|
|
|
store.register_late_pass(move || Box::new(needless_question_mark::NeedlessQuestionMark));
|
|
|
|
|
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-01-27 14:12:45 +00:00
|
|
|
|
store.register_late_pass(move || Box::new(map_clone::MapClone::new(msrv)));
|
2021-06-03 06:41:37 +00:00
|
|
|
|
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(size_of_in_element_count::SizeOfInElementCount));
|
2021-09-28 17:03:12 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(same_name_method::SameNameMethod));
|
2021-12-06 11:33:31 +00:00
|
|
|
|
let max_suggested_slice_pattern_length = conf.max_suggested_slice_pattern_length;
|
|
|
|
|
store.register_late_pass(move || {
|
|
|
|
|
Box::new(index_refutable_slice::IndexRefutableSlice::new(
|
|
|
|
|
max_suggested_slice_pattern_length,
|
|
|
|
|
msrv,
|
|
|
|
|
))
|
|
|
|
|
});
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(map_err_ignore::MapErrIgnore));
|
2021-10-07 09:21:30 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(shadow::Shadow::default()));
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(unit_types::UnitTypes));
|
|
|
|
|
store.register_late_pass(|| Box::new(loops::Loops));
|
|
|
|
|
store.register_late_pass(|| Box::new(main_recursion::MainRecursion::default()));
|
|
|
|
|
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(open_options::OpenOptions));
|
|
|
|
|
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(no_effect::NoEffect));
|
|
|
|
|
store.register_late_pass(|| Box::new(temporary_assignment::TemporaryAssignment));
|
|
|
|
|
store.register_late_pass(|| Box::new(transmute::Transmute));
|
2021-06-03 06:41:37 +00:00
|
|
|
|
let cognitive_complexity_threshold = conf.cognitive_complexity_threshold;
|
2021-12-06 11:33:31 +00:00
|
|
|
|
store.register_late_pass(move || {
|
|
|
|
|
Box::new(cognitive_complexity::CognitiveComplexity::new(
|
|
|
|
|
cognitive_complexity_threshold,
|
|
|
|
|
))
|
|
|
|
|
});
|
2021-06-03 06:41:37 +00:00
|
|
|
|
let too_large_for_stack = conf.too_large_for_stack;
|
2021-12-06 11:33:31 +00: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 }));
|
2021-08-06 15:14:27 +00:00
|
|
|
|
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));
|
2021-09-08 14:31:47 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(derivable_impls::DerivableImpls));
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(get_last_with_len::GetLastWithLen));
|
|
|
|
|
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(absurd_extreme_comparisons::AbsurdExtremeComparisons));
|
|
|
|
|
store.register_late_pass(|| Box::new(invalid_upcast_comparisons::InvalidUpcastComparisons));
|
2021-09-28 17:03:12 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(regex::Regex));
|
2021-08-06 15:14:27 +00:00
|
|
|
|
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));
|
|
|
|
|
store.register_late_pass(|| Box::new(new_without_default::NewWithoutDefault::default()));
|
2021-06-03 06:41:37 +00:00
|
|
|
|
let blacklisted_names = conf.blacklisted_names.iter().cloned().collect::<FxHashSet<_>>();
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_late_pass(move || Box::new(blacklisted_name::BlacklistedName::new(blacklisted_names.clone())));
|
2021-06-03 06:41:37 +00:00
|
|
|
|
let too_many_arguments_threshold = conf.too_many_arguments_threshold;
|
|
|
|
|
let too_many_lines_threshold = conf.too_many_lines_threshold;
|
2021-12-06 11:33:31 +00:00
|
|
|
|
store.register_late_pass(move || {
|
|
|
|
|
Box::new(functions::Functions::new(
|
|
|
|
|
too_many_arguments_threshold,
|
|
|
|
|
too_many_lines_threshold,
|
|
|
|
|
))
|
|
|
|
|
});
|
2021-06-03 06:41:37 +00:00
|
|
|
|
let doc_valid_idents = conf.doc_valid_idents.iter().cloned().collect::<FxHashSet<_>>();
|
2021-08-06 15:14:27 +00: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(arithmetic::Arithmetic::default()));
|
|
|
|
|
store.register_late_pass(|| Box::new(assign_ops::AssignOps));
|
|
|
|
|
store.register_late_pass(|| Box::new(let_if_seq::LetIfSeq));
|
|
|
|
|
store.register_late_pass(|| Box::new(eval_order_dependence::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));
|
2021-09-28 17:03:12 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(match_result_ok::MatchResultOk));
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(partialeq_ne_impl::PartialEqNeImpl));
|
|
|
|
|
store.register_late_pass(|| Box::new(unused_io_amount::UnusedIoAmount));
|
2021-06-03 06:41:37 +00:00
|
|
|
|
let enum_variant_size_threshold = conf.enum_variant_size_threshold;
|
2021-08-06 15:14:27 +00: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 06:41:37 +00: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,
|
|
|
|
|
);
|
2021-08-06 15:14:27 +00: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(try_err::TryErr));
|
|
|
|
|
store.register_late_pass(|| Box::new(bytecount::ByteCount));
|
|
|
|
|
store.register_late_pass(|| Box::new(infinite_iter::InfiniteIter));
|
|
|
|
|
store.register_late_pass(|| Box::new(inline_fn_without_body::InlineFnWithoutBody));
|
|
|
|
|
store.register_late_pass(|| Box::new(useless_conversion::UselessConversion::default()));
|
|
|
|
|
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(double_comparison::DoubleComparisons));
|
|
|
|
|
store.register_late_pass(|| Box::new(question_mark::QuestionMark));
|
|
|
|
|
store.register_early_pass(|| Box::new(suspicious_operation_groupings::SuspiciousOperationGroupings));
|
|
|
|
|
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));
|
|
|
|
|
store.register_late_pass(|| Box::new(duration_subsec::DurationSubsec));
|
|
|
|
|
store.register_late_pass(|| Box::new(indexing_slicing::IndexingSlicing));
|
|
|
|
|
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(|| Box::new(unnecessary_sort_by::UnnecessarySortBy));
|
|
|
|
|
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(transmuting_null::TransmutingNull));
|
|
|
|
|
store.register_late_pass(|| Box::new(path_buf_push_overwrite::PathBufPushOverwrite));
|
|
|
|
|
store.register_late_pass(|| Box::new(integer_division::IntegerDivision));
|
|
|
|
|
store.register_late_pass(|| Box::new(inherent_to_string::InherentToString));
|
2021-06-03 06:41:37 +00:00
|
|
|
|
let max_trait_bounds = conf.max_trait_bounds;
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_late_pass(move || Box::new(trait_bounds::TraitBounds::new(max_trait_bounds)));
|
|
|
|
|
store.register_late_pass(|| Box::new(comparison_chain::ComparisonChain));
|
|
|
|
|
store.register_late_pass(|| Box::new(mut_key::MutableKeyType));
|
|
|
|
|
store.register_late_pass(|| Box::new(modulo_arithmetic::ModuloArithmetic));
|
|
|
|
|
store.register_early_pass(|| Box::new(reference::DerefAddrOf));
|
|
|
|
|
store.register_early_pass(|| Box::new(double_parens::DoubleParens));
|
2022-02-17 11:20:47 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(format_impl::FormatImpl::new()));
|
2021-08-06 15:14:27 +00: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));
|
|
|
|
|
store.register_late_pass(|| Box::new(redundant_closure_call::RedundantClosureCall));
|
|
|
|
|
store.register_early_pass(|| Box::new(unused_unit::UnusedUnit));
|
|
|
|
|
store.register_late_pass(|| Box::new(returns::Return));
|
|
|
|
|
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));
|
|
|
|
|
store.register_early_pass(|| Box::new(needless_continue::NeedlessContinue));
|
|
|
|
|
store.register_early_pass(|| Box::new(redundant_else::RedundantElse));
|
|
|
|
|
store.register_late_pass(|| Box::new(create_dir::CreateDir));
|
|
|
|
|
store.register_early_pass(|| Box::new(needless_arbitrary_self_type::NeedlessArbitrarySelfType));
|
2021-06-03 06:41:37 +00:00
|
|
|
|
let literal_representation_lint_fraction_readability = conf.unreadable_literal_lint_fractions;
|
2021-12-06 11:33:31 +00:00
|
|
|
|
store.register_early_pass(move || {
|
|
|
|
|
Box::new(literal_representation::LiteralDigitGrouping::new(
|
|
|
|
|
literal_representation_lint_fraction_readability,
|
|
|
|
|
))
|
|
|
|
|
});
|
2021-06-03 06:41:37 +00:00
|
|
|
|
let literal_representation_threshold = conf.literal_representation_threshold;
|
2021-12-06 11:33:31 +00:00
|
|
|
|
store.register_early_pass(move || {
|
|
|
|
|
Box::new(literal_representation::DecimalLiteralRepresentation::new(
|
|
|
|
|
literal_representation_threshold,
|
|
|
|
|
))
|
|
|
|
|
});
|
2021-06-03 06:41:37 +00:00
|
|
|
|
let enum_variant_name_threshold = conf.enum_variant_name_threshold;
|
2021-12-06 11:33:31 +00:00
|
|
|
|
store.register_late_pass(move || {
|
|
|
|
|
Box::new(enum_variants::EnumVariantNames::new(
|
|
|
|
|
enum_variant_name_threshold,
|
|
|
|
|
avoid_breaking_exported_api,
|
|
|
|
|
))
|
|
|
|
|
});
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_early_pass(|| Box::new(tabs_in_doc_comments::TabsInDocComments));
|
2021-06-03 06:41:37 +00:00
|
|
|
|
let upper_case_acronyms_aggressive = conf.upper_case_acronyms_aggressive;
|
2021-12-06 11:33:31 +00:00
|
|
|
|
store.register_late_pass(move || {
|
|
|
|
|
Box::new(upper_case_acronyms::UpperCaseAcronyms::new(
|
|
|
|
|
avoid_breaking_exported_api,
|
|
|
|
|
upper_case_acronyms_aggressive,
|
|
|
|
|
))
|
|
|
|
|
});
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(default::Default::default()));
|
|
|
|
|
store.register_late_pass(|| Box::new(unused_self::UnusedSelf));
|
|
|
|
|
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 06:41:37 +00:00
|
|
|
|
let array_size_threshold = conf.array_size_threshold;
|
2021-08-06 15:14:27 +00: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));
|
|
|
|
|
store.register_early_pass(|| Box::new(as_conversions::AsConversions));
|
|
|
|
|
store.register_late_pass(|| Box::new(let_underscore::LetUnderscore));
|
|
|
|
|
store.register_early_pass(|| Box::new(single_component_path_imports::SingleComponentPathImports));
|
2021-06-03 06:41:37 +00:00
|
|
|
|
let max_fn_params_bools = conf.max_fn_params_bools;
|
|
|
|
|
let max_struct_bools = conf.max_struct_bools;
|
2021-12-06 11:33:31 +00:00
|
|
|
|
store.register_early_pass(move || {
|
|
|
|
|
Box::new(excessive_bools::ExcessiveBools::new(
|
|
|
|
|
max_struct_bools,
|
|
|
|
|
max_fn_params_bools,
|
|
|
|
|
))
|
|
|
|
|
});
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_early_pass(|| Box::new(option_env_unwrap::OptionEnvUnwrap));
|
2021-06-03 06:41:37 +00:00
|
|
|
|
let warn_on_all_wildcard_imports = conf.warn_on_all_wildcard_imports;
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_late_pass(move || Box::new(wildcard_imports::WildcardImports::new(warn_on_all_wildcard_imports)));
|
|
|
|
|
store.register_late_pass(|| Box::new(verbose_file_reads::VerboseFileReads));
|
|
|
|
|
store.register_late_pass(|| Box::new(redundant_pub_crate::RedundantPubCrate::default()));
|
|
|
|
|
store.register_late_pass(|| Box::new(unnamed_address::UnnamedAddress));
|
|
|
|
|
store.register_late_pass(|| Box::new(dereference::Dereferencing::default()));
|
|
|
|
|
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));
|
2021-11-04 12:52:36 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(if_not_else::IfNotElse));
|
2021-10-07 09:21:30 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(equatable_if_let::PatternEquality));
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(mut_mutex_lock::MutMutexLock));
|
|
|
|
|
store.register_late_pass(|| Box::new(match_on_vec_items::MatchOnVecItems));
|
|
|
|
|
store.register_late_pass(|| Box::new(manual_async_fn::ManualAsyncFn));
|
|
|
|
|
store.register_late_pass(|| Box::new(vec_resize_to_zero::VecResizeToZero));
|
|
|
|
|
store.register_late_pass(|| Box::new(panic_in_result_fn::PanicInResultFn));
|
2021-06-03 06:41:37 +00:00
|
|
|
|
let single_char_binding_names_threshold = conf.single_char_binding_names_threshold;
|
2021-12-06 11:33:31 +00:00
|
|
|
|
store.register_early_pass(move || {
|
|
|
|
|
Box::new(non_expressive_names::NonExpressiveNames {
|
|
|
|
|
single_char_binding_names_threshold,
|
|
|
|
|
})
|
|
|
|
|
});
|
2021-07-01 16:17:38 +00:00
|
|
|
|
let macro_matcher = conf.standard_macro_braces.iter().cloned().collect::<FxHashSet<_>>();
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_early_pass(move || Box::new(nonstandard_macro_braces::MacroBraces::new(¯o_matcher)));
|
|
|
|
|
store.register_late_pass(|| Box::new(macro_use::MacroUseImports::default()));
|
|
|
|
|
store.register_late_pass(|| Box::new(pattern_type_mismatch::PatternTypeMismatch));
|
|
|
|
|
store.register_late_pass(|| Box::new(stable_sort_primitive::StableSortPrimitive));
|
|
|
|
|
store.register_late_pass(|| Box::new(repeat_once::RepeatOnce));
|
|
|
|
|
store.register_late_pass(|| Box::new(unwrap_in_result::UnwrapInResult));
|
|
|
|
|
store.register_late_pass(|| Box::new(self_assignment::SelfAssignment));
|
|
|
|
|
store.register_late_pass(|| Box::new(manual_unwrap_or::ManualUnwrapOr));
|
|
|
|
|
store.register_late_pass(|| Box::new(manual_ok_or::ManualOkOr));
|
|
|
|
|
store.register_late_pass(|| Box::new(float_equality_without_abs::FloatEqualityWithoutAbs));
|
|
|
|
|
store.register_late_pass(|| Box::new(semicolon_if_nothing_returned::SemicolonIfNothingReturned));
|
|
|
|
|
store.register_late_pass(|| Box::new(async_yields_async::AsyncYieldsAsync));
|
2021-09-28 17:03:12 +00:00
|
|
|
|
let disallowed_methods = conf.disallowed_methods.clone();
|
2021-12-06 11:33:31 +00:00
|
|
|
|
store.register_late_pass(move || Box::new(disallowed_methods::DisallowedMethods::new(disallowed_methods.clone())));
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_early_pass(|| Box::new(asm_syntax::InlineAsmX86AttSyntax));
|
|
|
|
|
store.register_early_pass(|| Box::new(asm_syntax::InlineAsmX86IntelSyntax));
|
2022-03-25 19:31:52 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(empty_drop::EmptyDrop));
|
2021-08-06 15:14:27 +00:00
|
|
|
|
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));
|
|
|
|
|
store.register_late_pass(|| Box::new(vec_init_then_push::VecInitThenPush::default()));
|
2021-12-06 11:33:31 +00:00
|
|
|
|
store.register_late_pass(|| {
|
|
|
|
|
Box::new(case_sensitive_file_extension_comparisons::CaseSensitiveFileExtensionComparisons)
|
|
|
|
|
});
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(redundant_slicing::RedundantSlicing));
|
|
|
|
|
store.register_late_pass(|| Box::new(from_str_radix_10::FromStrRadix10));
|
|
|
|
|
store.register_late_pass(|| Box::new(manual_map::ManualMap));
|
|
|
|
|
store.register_late_pass(move || Box::new(if_then_some_else_none::IfThenSomeElseNone::new(msrv)));
|
2021-09-08 14:31:47 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(bool_assert_comparison::BoolAssertComparison));
|
|
|
|
|
store.register_early_pass(move || Box::new(module_style::ModStyle));
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(unused_async::UnusedAsync));
|
2021-10-21 11:11:36 +00:00
|
|
|
|
let disallowed_types = conf.disallowed_types.clone();
|
2021-12-06 11:33:31 +00:00
|
|
|
|
store.register_late_pass(move || Box::new(disallowed_types::DisallowedTypes::new(disallowed_types.clone())));
|
2021-07-01 16:17:38 +00:00
|
|
|
|
let import_renames = conf.enforced_import_renames.clone();
|
2021-12-06 11:33:31 +00:00
|
|
|
|
store.register_late_pass(move || {
|
|
|
|
|
Box::new(missing_enforced_import_rename::ImportRename::new(
|
|
|
|
|
import_renames.clone(),
|
|
|
|
|
))
|
|
|
|
|
});
|
2021-07-01 16:17:38 +00:00
|
|
|
|
let scripts = conf.allowed_scripts.clone();
|
2021-08-06 15:14:27 +00:00
|
|
|
|
store.register_early_pass(move || Box::new(disallowed_script_idents::DisallowedScriptIdents::new(&scripts)));
|
|
|
|
|
store.register_late_pass(|| Box::new(strlen_on_c_strings::StrlenOnCStrings));
|
|
|
|
|
store.register_late_pass(move || Box::new(self_named_constructors::SelfNamedConstructors));
|
2021-09-28 17:03:12 +00:00
|
|
|
|
store.register_late_pass(move || Box::new(iter_not_returning_iterator::IterNotReturningIterator));
|
2021-11-04 12:52:36 +00:00
|
|
|
|
store.register_late_pass(move || Box::new(manual_assert::ManualAssert));
|
2021-10-07 09:21:30 +00:00
|
|
|
|
let enable_raw_pointer_heuristic_for_send = conf.enable_raw_pointer_heuristic_for_send;
|
2021-12-06 11:33:31 +00:00
|
|
|
|
store.register_late_pass(move || {
|
|
|
|
|
Box::new(non_send_fields_in_send_ty::NonSendFieldInSendTy::new(
|
|
|
|
|
enable_raw_pointer_heuristic_for_send,
|
|
|
|
|
))
|
|
|
|
|
});
|
2022-02-19 22:56:42 +00:00
|
|
|
|
store.register_late_pass(move || Box::new(undocumented_unsafe_blocks::UndocumentedUnsafeBlocks));
|
2021-10-21 11:11:36 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(match_str_case_mismatch::MatchStrCaseMismatch));
|
|
|
|
|
store.register_late_pass(move || Box::new(format_args::FormatArgs));
|
|
|
|
|
store.register_late_pass(|| Box::new(trailing_empty_array::TrailingEmptyArray));
|
2021-12-06 11:33:31 +00:00
|
|
|
|
store.register_early_pass(|| Box::new(octal_escapes::OctalEscapes));
|
|
|
|
|
store.register_late_pass(|| Box::new(needless_late_init::NeedlessLateInit));
|
2021-12-17 12:40:22 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(return_self_not_must_use::ReturnSelfNotMustUse));
|
2021-12-30 14:10:43 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(init_numbered_fields::NumberedFields));
|
2022-01-13 12:18:19 +00:00
|
|
|
|
store.register_early_pass(|| Box::new(single_char_lifetime_names::SingleCharLifetimeNames));
|
|
|
|
|
store.register_late_pass(move || Box::new(borrow_as_ptr::BorrowAsPtr::new(msrv)));
|
|
|
|
|
store.register_late_pass(move || Box::new(manual_bits::ManualBits::new(msrv)));
|
2022-01-15 09:27:24 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(default_union_representation::DefaultUnionRepresentation));
|
2022-02-12 17:32:09 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(only_used_in_recursion::OnlyUsedInRecursion));
|
2022-02-11 14:45:56 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(dbg_macro::DbgMacro));
|
2022-02-13 21:54:33 +00:00
|
|
|
|
let cargo_ignore_publish = conf.cargo_ignore_publish;
|
|
|
|
|
store.register_late_pass(move || {
|
|
|
|
|
Box::new(cargo::Cargo {
|
|
|
|
|
ignore_publish: cargo_ignore_publish,
|
|
|
|
|
})
|
|
|
|
|
});
|
2022-03-24 01:08:52 +00:00
|
|
|
|
store.register_early_pass(|| Box::new(crate_in_macro_def::CrateInMacroDef));
|
2022-03-28 09:35:43 +00:00
|
|
|
|
store.register_early_pass(|| Box::new(empty_structs_with_brackets::EmptyStructsWithBrackets));
|
2022-04-11 11:05:42 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(unnecessary_owned_empty_strings::UnnecessaryOwnedEmptyStrings));
|
2022-04-12 09:09:34 +00:00
|
|
|
|
store.register_early_pass(|| Box::new(pub_use::PubUse));
|
2022-04-04 03:40:58 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(format_push_string::FormatPushString));
|
2022-01-31 00:16:10 +00:00
|
|
|
|
store.register_late_pass(|| Box::new(bytes_count_to_len::BytesCountToLen));
|
2022-04-21 15:01:18 +00:00
|
|
|
|
let max_include_file_size = conf.max_include_file_size;
|
|
|
|
|
store.register_late_pass(move || Box::new(large_include_file::LargeIncludeFile::new(max_include_file_size)));
|
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 12:58:41 +00:00
|
|
|
|
}
|
2018-12-16 21:49:46 +00:00
|
|
|
|
|
2019-08-12 05:28:07 +00:00
|
|
|
|
#[rustfmt::skip]
|
2020-01-12 06:08:41 +00:00
|
|
|
|
fn register_removed_non_tool_lints(store: &mut rustc_lint::LintStore) {
|
2019-08-12 05:28:07 +00: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 15:36:26 +00:00
|
|
|
|
store.register_removed(
|
|
|
|
|
"reverse_range_loop",
|
|
|
|
|
"this lint is now included in reversed_empty_ranges",
|
|
|
|
|
);
|
2019-08-12 05:28:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-11 06:59:57 +00:00
|
|
|
|
/// Register renamed lints.
|
|
|
|
|
///
|
|
|
|
|
/// Used in `./src/driver.rs`.
|
2020-01-12 06:08:41 +00:00
|
|
|
|
pub fn register_renamed(ls: &mut rustc_lint::LintStore) {
|
2021-11-04 12:52:36 +00:00
|
|
|
|
// NOTE: when renaming a lint, add a corresponding test to tests/ui/rename.rs
|
2018-12-17 13:29:19 +00:00
|
|
|
|
ls.register_renamed("clippy::stutter", "clippy::module_name_repetitions");
|
2018-12-17 23:25:49 +00:00
|
|
|
|
ls.register_renamed("clippy::new_without_default_derive", "clippy::new_without_default");
|
2019-02-23 01:19:50 +00:00
|
|
|
|
ls.register_renamed("clippy::cyclomatic_complexity", "clippy::cognitive_complexity");
|
2019-06-13 21:54:05 +00:00
|
|
|
|
ls.register_renamed("clippy::const_static_lifetime", "clippy::redundant_static_lifetimes");
|
2020-05-17 15:36:26 +00:00
|
|
|
|
ls.register_renamed("clippy::option_and_then_some", "clippy::bind_instead_of_map");
|
2021-09-28 17:03:12 +00:00
|
|
|
|
ls.register_renamed("clippy::box_vec", "clippy::box_collection");
|
2020-05-17 15:36:26 +00:00
|
|
|
|
ls.register_renamed("clippy::block_in_if_condition_expr", "clippy::blocks_in_if_conditions");
|
|
|
|
|
ls.register_renamed("clippy::block_in_if_condition_stmt", "clippy::blocks_in_if_conditions");
|
|
|
|
|
ls.register_renamed("clippy::option_map_unwrap_or", "clippy::map_unwrap_or");
|
|
|
|
|
ls.register_renamed("clippy::option_map_unwrap_or_else", "clippy::map_unwrap_or");
|
|
|
|
|
ls.register_renamed("clippy::result_map_unwrap_or_else", "clippy::map_unwrap_or");
|
|
|
|
|
ls.register_renamed("clippy::option_unwrap_used", "clippy::unwrap_used");
|
|
|
|
|
ls.register_renamed("clippy::result_unwrap_used", "clippy::unwrap_used");
|
|
|
|
|
ls.register_renamed("clippy::option_expect_used", "clippy::expect_used");
|
|
|
|
|
ls.register_renamed("clippy::result_expect_used", "clippy::expect_used");
|
|
|
|
|
ls.register_renamed("clippy::for_loop_over_option", "clippy::for_loops_over_fallibles");
|
|
|
|
|
ls.register_renamed("clippy::for_loop_over_result", "clippy::for_loops_over_fallibles");
|
|
|
|
|
ls.register_renamed("clippy::identity_conversion", "clippy::useless_conversion");
|
2020-10-09 10:45:29 +00:00
|
|
|
|
ls.register_renamed("clippy::zero_width_space", "clippy::invisible_characters");
|
2020-11-05 13:29:48 +00:00
|
|
|
|
ls.register_renamed("clippy::single_char_push_str", "clippy::single_char_add_str");
|
2021-09-28 17:03:12 +00:00
|
|
|
|
ls.register_renamed("clippy::if_let_some_result", "clippy::match_result_ok");
|
2021-12-06 11:33:31 +00:00
|
|
|
|
ls.register_renamed("clippy::disallowed_type", "clippy::disallowed_types");
|
|
|
|
|
ls.register_renamed("clippy::disallowed_method", "clippy::disallowed_methods");
|
2022-01-27 14:12:45 +00:00
|
|
|
|
ls.register_renamed("clippy::ref_in_deref", "clippy::needless_borrow");
|
2021-12-28 18:27:11 +00:00
|
|
|
|
ls.register_renamed("clippy::to_string_in_display", "clippy::recursive_format_impl");
|
2021-04-22 09:31:13 +00:00
|
|
|
|
|
|
|
|
|
// uplifted lints
|
|
|
|
|
ls.register_renamed("clippy::invalid_ref", "invalid_value");
|
|
|
|
|
ls.register_renamed("clippy::into_iter_on_array", "array_into_iter");
|
|
|
|
|
ls.register_renamed("clippy::unused_label", "unused_labels");
|
|
|
|
|
ls.register_renamed("clippy::drop_bounds", "drop_bounds");
|
|
|
|
|
ls.register_renamed("clippy::temporary_cstring_as_ptr", "temporary_cstring_as_ptr");
|
2021-06-29 18:33:31 +00:00
|
|
|
|
ls.register_renamed("clippy::panic_params", "non_fmt_panics");
|
2021-04-22 09:31:13 +00:00
|
|
|
|
ls.register_renamed("clippy::unknown_clippy_lints", "unknown_lints");
|
2020-12-02 23:16:12 +00:00
|
|
|
|
ls.register_renamed("clippy::invalid_atomic_ordering", "invalid_atomic_ordering");
|
2021-10-11 08:10:16 +00:00
|
|
|
|
ls.register_renamed("clippy::mem_discriminant_non_enum", "enum_intrinsics_non_enums");
|
2016-05-24 16:25:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// only exists to let the dogfood integration test works.
|
|
|
|
|
// Don't run clippy as an executable directly
|
2018-11-17 12:47:27 +00:00
|
|
|
|
#[allow(dead_code)]
|
2016-05-24 16:25:25 +00:00
|
|
|
|
fn main() {
|
|
|
|
|
panic!("Please use the cargo-clippy executable");
|
|
|
|
|
}
|