// error-pattern:cargo-clippy
#![feature(box_syntax)]
-#![feature(custom_attribute)]
#![feature(rustc_private)]
#![feature(slice_patterns)]
#![feature(stmt_expr_attributes)]
-#![feature(conservative_impl_trait)]
#![feature(range_contains)]
#![feature(macro_vis_matcher)]
-#![allow(unknown_lints, indexing_slicing, shadow_reuse, missing_docs_in_private_items)]
+#![allow(unknown_lints, shadow_reuse, missing_docs_in_private_items)]
#![recursion_limit = "256"]
-// FIXME(mark-i-m) remove after i128 stablization merges
#![allow(stable_features)]
-#![feature(i128, i128_type)]
+#![feature(iterator_find_map)]
+#![feature(macro_at_most_once_rep)]
+#![feature(rust_2018_preview)]
+#![warn(rust_2018_idioms)]
-#[macro_use]
-extern crate rustc;
-extern crate rustc_typeck;
-extern crate syntax;
-extern crate syntax_pos;
-
-extern crate toml;
-
-// for unicode nfc normalization
-
-extern crate unicode_normalization;
-
-// for semver check in attrs.rs
-
-extern crate semver;
+use toml;
+use rustc_plugin;
-// for regex checking
-
-extern crate regex_syntax;
-
-// for finding minimal boolean expressions
-
-extern crate quine_mc_cluskey;
-
-extern crate rustc_const_math;
-extern crate rustc_errors;
-extern crate rustc_plugin;
-
-#[macro_use]
-extern crate matches as matches_macro;
-
-extern crate serde;
-#[macro_use]
-extern crate serde_derive;
-
-#[macro_use]
-extern crate lazy_static;
-
-extern crate itertools;
-extern crate pulldown_cmark;
-extern crate url;
-
-#[macro_use]
-extern crate if_chain;
macro_rules! declare_clippy_lint {
{ pub $name:tt, style, $description:tt } => {
{ pub $name:tt, restriction, $description:tt } => {
declare_lint! { pub $name, Allow, $description }
};
+ { pub $name:tt, cargo, $description:tt } => {
+ declare_lint! { pub $name, Allow, $description }
+ };
{ pub $name:tt, nursery, $description:tt } => {
declare_lint! { pub $name, Allow, $description }
};
// begin lints modules, do not remove this comment, it’s used in `update_lints`
pub mod approx_const;
pub mod arithmetic;
-pub mod array_indexing;
pub mod assign_ops;
pub mod attrs;
pub mod bit_mask;
pub mod const_static_lifetime;
pub mod copies;
pub mod cyclomatic_complexity;
+pub mod default_trait_access;
pub mod derive;
pub mod doc;
pub mod double_comparison;
pub mod double_parens;
pub mod drop_forget_ref;
+pub mod duration_subsec;
pub mod else_if_without_else;
pub mod empty_enum;
pub mod entry;
pub mod escape;
pub mod eta_reduction;
pub mod eval_order_dependence;
+pub mod excessive_precision;
pub mod explicit_write;
pub mod fallible_impl_from;
pub mod format;
pub mod identity_op;
pub mod if_let_redundant_pattern_matching;
pub mod if_not_else;
+pub mod indexing_slicing;
+pub mod infallible_destructuring_match;
pub mod infinite_iter;
+pub mod inherent_impl;
pub mod inline_fn_without_body;
pub mod int_plus_one;
pub mod invalid_ref;
pub mod literal_representation;
pub mod loops;
pub mod map_clone;
-pub mod option_map_unit_fn;
+pub mod map_unit_fn;
pub mod matches;
pub mod mem_forget;
pub mod methods;
pub mod misc;
pub mod misc_early;
pub mod missing_doc;
+pub mod missing_inline;
+pub mod multiple_crate_versions;
pub mod mut_mut;
pub mod mut_reference;
pub mod mutex_atomic;
pub mod needless_continue;
pub mod needless_pass_by_value;
pub mod needless_update;
+pub mod neg_cmp_op_on_partial_ord;
pub mod neg_multiply;
pub mod new_without_default;
pub mod no_effect;
+pub mod non_copy_const;
pub mod non_expressive_names;
pub mod ok_if_let;
pub mod open_options;
pub mod overflow_check_conditional;
-pub mod panic;
+pub mod panic_unimplemented;
pub mod partialeq_ne_impl;
pub mod precedence;
pub mod ptr;
pub mod swap;
pub mod temporary_assignment;
pub mod transmute;
+pub mod trivially_copy_pass_by_ref;
pub mod types;
pub mod unicode;
pub mod unsafe_removed_from_name;
pub mod unused_io_amount;
pub mod unused_label;
+pub mod unwrap;
pub mod use_self;
pub mod vec;
pub mod write;
// end lints modules, do not remove this comment, it’s used in `update_lints`
mod reexport {
- pub use syntax::ast::{Name, NodeId};
+ crate use syntax::ast::{Name, NodeId};
}
#[cfg_attr(rustfmt, rustfmt_skip)]
reg.register_early_lint_pass(box enum_variants::EnumVariantNames::new(conf.enum_variant_name_threshold));
reg.register_late_lint_pass(box enum_glob_use::EnumGlobUse);
reg.register_late_lint_pass(box enum_clike::UnportableVariant);
+ reg.register_late_lint_pass(box excessive_precision::ExcessivePrecision);
reg.register_late_lint_pass(box bit_mask::BitMask::new(conf.verbose_bit_mask_threshold));
reg.register_late_lint_pass(box ptr::PointerPass);
reg.register_late_lint_pass(box needless_bool::NeedlessBool);
);
reg.register_late_lint_pass(box escape::Pass{too_large_for_stack: conf.too_large_for_stack});
reg.register_early_lint_pass(box misc_early::MiscEarly);
- reg.register_late_lint_pass(box array_indexing::ArrayIndexing);
- reg.register_late_lint_pass(box panic::Pass);
+ reg.register_late_lint_pass(box panic_unimplemented::Pass);
reg.register_late_lint_pass(box strings::StringLitAsBytes);
reg.register_late_lint_pass(box derive::Derive);
reg.register_late_lint_pass(box types::CharLitAsU8);
reg.register_late_lint_pass(box let_if_seq::LetIfSeq);
reg.register_late_lint_pass(box eval_order_dependence::EvalOrderDependence);
reg.register_late_lint_pass(box missing_doc::MissingDoc::new());
+ reg.register_late_lint_pass(box missing_inline::MissingInline);
reg.register_late_lint_pass(box ok_if_let::Pass);
reg.register_late_lint_pass(box if_let_redundant_pattern_matching::Pass);
reg.register_late_lint_pass(box partialeq_ne_impl::Pass);
reg.register_early_lint_pass(box reference::Pass);
+ reg.register_early_lint_pass(box reference::DerefPass);
reg.register_early_lint_pass(box double_parens::DoubleParens);
reg.register_late_lint_pass(box unused_io_amount::UnusedIoAmount);
reg.register_late_lint_pass(box large_enum_variant::LargeEnumVariant::new(conf.enum_variant_size_threshold));
reg.register_late_lint_pass(box explicit_write::Pass);
reg.register_late_lint_pass(box needless_pass_by_value::NeedlessPassByValue);
+ reg.register_late_lint_pass(box trivially_copy_pass_by_ref::TriviallyCopyPassByRef::new(
+ conf.trivial_copy_size_limit,
+ ®.sess.target,
+ ));
reg.register_early_lint_pass(box literal_representation::LiteralDigitGrouping);
reg.register_early_lint_pass(box literal_representation::LiteralRepresentation::new(
conf.literal_representation_threshold
reg.register_late_lint_pass(box question_mark::QuestionMarkPass);
reg.register_late_lint_pass(box suspicious_trait_impl::SuspiciousImpl);
reg.register_late_lint_pass(box redundant_field_names::RedundantFieldNames);
- reg.register_late_lint_pass(box option_map_unit_fn::Pass);
-
+ reg.register_early_lint_pass(box multiple_crate_versions::Pass);
+ reg.register_late_lint_pass(box map_unit_fn::Pass);
+ reg.register_late_lint_pass(box infallible_destructuring_match::Pass);
+ reg.register_late_lint_pass(box inherent_impl::Pass::default());
+ reg.register_late_lint_pass(box neg_cmp_op_on_partial_ord::NoNegCompOpForPartialOrd);
+ reg.register_late_lint_pass(box unwrap::Pass);
+ reg.register_late_lint_pass(box duration_subsec::DurationSubsec);
+ reg.register_late_lint_pass(box default_trait_access::DefaultTraitAccess);
+ reg.register_late_lint_pass(box indexing_slicing::IndexingSlicing);
+ reg.register_late_lint_pass(box non_copy_const::NonCopyConst);
reg.register_lint_group("clippy_restriction", vec![
arithmetic::FLOAT_ARITHMETIC,
arithmetic::INTEGER_ARITHMETIC,
- array_indexing::INDEXING_SLICING,
assign_ops::ASSIGN_OPS,
else_if_without_else::ELSE_IF_WITHOUT_ELSE,
+ inherent_impl::MULTIPLE_INHERENT_IMPL,
literal_representation::DECIMAL_LITERAL_REPRESENTATION,
mem_forget::MEM_FORGET,
methods::CLONE_ON_REF_PTR,
methods::WRONG_PUB_SELF_CONVENTION,
misc::FLOAT_CMP_CONST,
missing_doc::MISSING_DOCS_IN_PRIVATE_ITEMS,
- write::PRINT_STDOUT,
- write::USE_DEBUG,
+ missing_inline::MISSING_INLINE_IN_PUBLIC_ITEMS,
+ panic_unimplemented::UNIMPLEMENTED,
shadow::SHADOW_REUSE,
shadow::SHADOW_SAME,
shadow::SHADOW_UNRELATED,
strings::STRING_ADD,
+ write::PRINT_STDOUT,
+ write::USE_DEBUG,
]);
reg.register_lint_group("clippy_pedantic", vec![
attrs::INLINE_ALWAYS,
copies::MATCH_SAME_ARMS,
+ default_trait_access::DEFAULT_TRAIT_ACCESS,
derive::EXPL_IMPL_CLONE_ON_COPY,
doc::DOC_MARKDOWN,
empty_enum::EMPTY_ENUM,
enum_variants::PUB_ENUM_VARIANT_NAMES,
enum_variants::STUTTER,
if_not_else::IF_NOT_ELSE,
+ indexing_slicing::INDEXING_SLICING,
infinite_iter::MAYBE_INFINITE_ITER,
items_after_statements::ITEMS_AFTER_STATEMENTS,
- option_map_unit_fn::OPTION_MAP_UNIT_FN,
matches::SINGLE_MATCH_ELSE,
methods::FILTER_MAP,
methods::OPTION_MAP_UNWRAP_OR,
reg.register_lint_group("clippy", vec![
approx_const::APPROX_CONSTANT,
- array_indexing::OUT_OF_BOUNDS_INDEXING,
assign_ops::ASSIGN_OP_PATTERN,
assign_ops::MISREFACTORED_ASSIGN_OP,
attrs::DEPRECATED_SEMVER,
drop_forget_ref::DROP_REF,
drop_forget_ref::FORGET_COPY,
drop_forget_ref::FORGET_REF,
+ duration_subsec::DURATION_SUBSEC,
entry::MAP_ENTRY,
enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
enum_variants::ENUM_VARIANT_NAMES,
eta_reduction::REDUNDANT_CLOSURE,
eval_order_dependence::DIVERGING_SUB_EXPRESSION,
eval_order_dependence::EVAL_ORDER_DEPENDENCE,
+ excessive_precision::EXCESSIVE_PRECISION,
explicit_write::EXPLICIT_WRITE,
format::USELESS_FORMAT,
formatting::POSSIBLE_MISSING_COMMA,
identity_conversion::IDENTITY_CONVERSION,
identity_op::IDENTITY_OP,
if_let_redundant_pattern_matching::IF_LET_REDUNDANT_PATTERN_MATCHING,
+ indexing_slicing::OUT_OF_BOUNDS_INDEXING,
+ infallible_destructuring_match::INFALLIBLE_DESTRUCTURING_MATCH,
infinite_iter::INFINITE_ITER,
inline_fn_without_body::INLINE_FN_WITHOUT_BODY,
int_plus_one::INT_PLUS_ONE,
len_zero::LEN_WITHOUT_IS_EMPTY,
len_zero::LEN_ZERO,
let_if_seq::USELESS_LET_IF_SEQ,
+ lifetimes::EXTRA_UNUSED_LIFETIMES,
lifetimes::NEEDLESS_LIFETIMES,
- lifetimes::UNUSED_LIFETIMES,
literal_representation::INCONSISTENT_DIGIT_GROUPING,
literal_representation::LARGE_DIGIT_GROUPS,
literal_representation::UNREADABLE_LITERAL,
loops::WHILE_LET_LOOP,
loops::WHILE_LET_ON_ITERATOR,
map_clone::MAP_CLONE,
+ map_unit_fn::OPTION_MAP_UNIT_FN,
+ map_unit_fn::RESULT_MAP_UNIT_FN,
matches::MATCH_AS_REF,
matches::MATCH_BOOL,
matches::MATCH_OVERLAPPING_ARM,
methods::CHARS_NEXT_CMP,
methods::CLONE_DOUBLE_REF,
methods::CLONE_ON_COPY,
+ methods::EXPECT_FUN_CALL,
methods::FILTER_NEXT,
methods::GET_UNWRAP,
methods::ITER_CLONED_COLLECT,
needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
needless_pass_by_value::NEEDLESS_PASS_BY_VALUE,
needless_update::NEEDLESS_UPDATE,
+ neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD,
neg_multiply::NEG_MULTIPLY,
new_without_default::NEW_WITHOUT_DEFAULT,
new_without_default::NEW_WITHOUT_DEFAULT_DERIVE,
no_effect::NO_EFFECT,
no_effect::UNNECESSARY_OPERATION,
+ non_copy_const::BORROW_INTERIOR_MUTABLE_CONST,
+ non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST,
non_expressive_names::JUST_UNDERSCORES_AND_DIGITS,
non_expressive_names::MANY_SINGLE_CHAR_NAMES,
ok_if_let::IF_LET_SOME_RESULT,
open_options::NONSENSICAL_OPEN_OPTIONS,
overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
- panic::PANIC_PARAMS,
+ panic_unimplemented::PANIC_PARAMS,
partialeq_ne_impl::PARTIALEQ_NE_IMPL,
precedence::PRECEDENCE,
- write::PRINT_LITERAL,
- write::PRINT_WITH_NEWLINE,
- write::PRINTLN_EMPTY_STRING,
ptr::CMP_NULL,
ptr::MUT_FROM_REF,
ptr::PTR_ARG,
ranges::RANGE_ZIP_WITH_LEN,
redundant_field_names::REDUNDANT_FIELD_NAMES,
reference::DEREF_ADDROF,
+ reference::REF_IN_DEREF,
regex::INVALID_REGEX,
regex::REGEX_MACRO,
regex::TRIVIAL_REGEX,
transmute::TRANSMUTE_INT_TO_BOOL,
transmute::TRANSMUTE_INT_TO_CHAR,
transmute::TRANSMUTE_INT_TO_FLOAT,
- transmute::TRANSMUTE_PTR_TO_REF,
transmute::TRANSMUTE_PTR_TO_PTR,
+ transmute::TRANSMUTE_PTR_TO_REF,
transmute::USELESS_TRANSMUTE,
transmute::WRONG_TRANSMUTE,
+ trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF,
types::ABSURD_EXTREME_COMPARISONS,
types::BORROWED_BOX,
types::BOX_VEC,
types::CAST_LOSSLESS,
types::CAST_PTR_ALIGNMENT,
types::CHAR_LIT_AS_U8,
+ types::FN_TO_NUMERIC_CAST,
+ types::FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
types::IMPLICIT_HASHER,
types::LET_UNIT_VALUE,
types::OPTION_OPTION,
unused_io_amount::UNUSED_IO_AMOUNT,
unused_label::UNUSED_LABEL,
vec::USELESS_VEC,
+ write::PRINT_LITERAL,
+ write::PRINT_WITH_NEWLINE,
+ write::PRINTLN_EMPTY_STRING,
+ write::WRITE_LITERAL,
+ write::WRITE_WITH_NEWLINE,
+ write::WRITELN_EMPTY_STRING,
zero_div_zero::ZERO_DIVIDED_BY_ZERO,
]);
enum_variants::MODULE_INCEPTION,
eq_op::OP_REF,
eta_reduction::REDUNDANT_CLOSURE,
+ excessive_precision::EXCESSIVE_PRECISION,
formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING,
formatting::SUSPICIOUS_ELSE_FORMATTING,
if_let_redundant_pattern_matching::IF_LET_REDUNDANT_PATTERN_MATCHING,
+ infallible_destructuring_match::INFALLIBLE_DESTRUCTURING_MATCH,
len_zero::LEN_WITHOUT_IS_EMPTY,
len_zero::LEN_ZERO,
let_if_seq::USELESS_LET_IF_SEQ,
non_expressive_names::JUST_UNDERSCORES_AND_DIGITS,
non_expressive_names::MANY_SINGLE_CHAR_NAMES,
ok_if_let::IF_LET_SOME_RESULT,
- panic::PANIC_PARAMS,
- write::PRINT_LITERAL,
- write::PRINT_WITH_NEWLINE,
- write::PRINTLN_EMPTY_STRING,
+ panic_unimplemented::PANIC_PARAMS,
ptr::CMP_NULL,
ptr::PTR_ARG,
question_mark::QUESTION_MARK,
returns::LET_AND_RETURN,
returns::NEEDLESS_RETURN,
strings::STRING_LIT_AS_BYTES,
+ types::FN_TO_NUMERIC_CAST,
types::IMPLICIT_HASHER,
types::LET_UNIT_VALUE,
unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
+ write::PRINT_LITERAL,
+ write::PRINT_WITH_NEWLINE,
+ write::PRINTLN_EMPTY_STRING,
+ write::WRITE_LITERAL,
+ write::WRITE_WITH_NEWLINE,
+ write::WRITELN_EMPTY_STRING,
]);
reg.register_lint_group("clippy_complexity", vec![
cyclomatic_complexity::CYCLOMATIC_COMPLEXITY,
double_comparison::DOUBLE_COMPARISONS,
double_parens::DOUBLE_PARENS,
+ duration_subsec::DURATION_SUBSEC,
eval_order_dependence::DIVERGING_SUB_EXPRESSION,
eval_order_dependence::EVAL_ORDER_DEPENDENCE,
explicit_write::EXPLICIT_WRITE,
identity_conversion::IDENTITY_CONVERSION,
identity_op::IDENTITY_OP,
int_plus_one::INT_PLUS_ONE,
+ lifetimes::EXTRA_UNUSED_LIFETIMES,
lifetimes::NEEDLESS_LIFETIMES,
- lifetimes::UNUSED_LIFETIMES,
loops::EXPLICIT_COUNTER_LOOP,
loops::MUT_RANGE_BOUND,
loops::WHILE_LET_LOOP,
+ map_unit_fn::OPTION_MAP_UNIT_FN,
+ map_unit_fn::RESULT_MAP_UNIT_FN,
matches::MATCH_AS_REF,
methods::CHARS_NEXT_CMP,
methods::CLONE_ON_COPY,
needless_bool::NEEDLESS_BOOL,
needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
needless_update::NEEDLESS_UPDATE,
+ neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD,
no_effect::NO_EFFECT,
no_effect::UNNECESSARY_OPERATION,
overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
precedence::PRECEDENCE,
ranges::RANGE_ZIP_WITH_LEN,
reference::DEREF_ADDROF,
+ reference::REF_IN_DEREF,
swap::MANUAL_SWAP,
temporary_assignment::TEMPORARY_ASSIGNMENT,
transmute::CROSSPOINTER_TRANSMUTE,
transmute::TRANSMUTE_INT_TO_BOOL,
transmute::TRANSMUTE_INT_TO_CHAR,
transmute::TRANSMUTE_INT_TO_FLOAT,
- transmute::TRANSMUTE_PTR_TO_REF,
transmute::TRANSMUTE_PTR_TO_PTR,
+ transmute::TRANSMUTE_PTR_TO_REF,
transmute::USELESS_TRANSMUTE,
types::BORROWED_BOX,
types::CAST_LOSSLESS,
reg.register_lint_group("clippy_correctness", vec![
approx_const::APPROX_CONSTANT,
- array_indexing::OUT_OF_BOUNDS_INDEXING,
attrs::DEPRECATED_SEMVER,
attrs::USELESS_ATTRIBUTE,
bit_mask::BAD_BIT_MASK,
erasing_op::ERASING_OP,
formatting::POSSIBLE_MISSING_COMMA,
functions::NOT_UNSAFE_PTR_ARG_DEREF,
+ indexing_slicing::OUT_OF_BOUNDS_INDEXING,
infinite_iter::INFINITE_ITER,
inline_fn_without_body::INLINE_FN_WITHOUT_BODY,
invalid_ref::INVALID_REF,
misc::CMP_NAN,
misc::FLOAT_CMP,
misc::MODULO_ONE,
+ non_copy_const::BORROW_INTERIOR_MUTABLE_CONST,
+ non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST,
open_options::NONSENSICAL_OPEN_OPTIONS,
ptr::MUT_FROM_REF,
ranges::ITERATOR_STEP_BY_ZERO,
transmute::WRONG_TRANSMUTE,
types::ABSURD_EXTREME_COMPARISONS,
types::CAST_PTR_ALIGNMENT,
+ types::FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
types::UNIT_CMP,
unicode::ZERO_WIDTH_SPACE,
unused_io_amount::UNUSED_IO_AMOUNT,
large_enum_variant::LARGE_ENUM_VARIANT,
loops::MANUAL_MEMCPY,
loops::UNUSED_COLLECT,
+ methods::EXPECT_FUN_CALL,
methods::ITER_NTH,
methods::OR_FUN_CALL,
methods::SINGLE_CHAR_PATTERN,
misc::CMP_OWNED,
mutex_atomic::MUTEX_ATOMIC,
+ trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF,
types::BOX_VEC,
vec::USELESS_VEC,
]);
+ reg.register_lint_group("clippy_cargo", vec![
+ multiple_crate_versions::MULTIPLE_CRATE_VERSIONS,
+ ]);
+
reg.register_lint_group("clippy_nursery", vec![
attrs::EMPTY_LINE_AFTER_OUTER_ATTR,
fallible_impl_from::FALLIBLE_IMPL_FROM,
mutex_atomic::MUTEX_INTEGER,
needless_borrow::NEEDLESS_BORROW,
ranges::RANGE_PLUS_ONE,
+ unwrap::PANICKING_UNWRAP,
+ unwrap::UNNECESSARY_UNWRAP,
]);
}