Skip to content

Commit

Permalink
Merge commit '3ae8faff4d46ad92f194c2a4b941c3152a701b31' into clippyup
Browse files Browse the repository at this point in the history
  • Loading branch information
flip1995 committed Jun 3, 2021
1 parent 91aa821 commit 6c27482
Show file tree
Hide file tree
Showing 189 changed files with 2,552 additions and 1,490 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2493,6 +2493,7 @@ Released 2018-09-13
[`manual_ok_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_or
[`manual_range_contains`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains
[`manual_saturating_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_saturating_arithmetic
[`manual_str_repeat`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_str_repeat
[`manual_strip`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_strip
[`manual_swap`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_swap
[`manual_unwrap_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or
Expand Down Expand Up @@ -2622,6 +2623,7 @@ Released 2018-09-13
[`redundant_pub_crate`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pub_crate
[`redundant_slicing`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_slicing
[`redundant_static_lifetimes`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes
[`ref_binding_to_reference`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_binding_to_reference
[`ref_in_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_in_deref
[`ref_option_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_option_ref
[`regex_macro`]: https://rust-lang.github.io/rust-clippy/master/index.html#regex_macro
Expand Down Expand Up @@ -2670,6 +2672,7 @@ Released 2018-09-13
[`suspicious_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_map
[`suspicious_op_assign_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_op_assign_impl
[`suspicious_operation_groupings`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_operation_groupings
[`suspicious_splitn`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_splitn
[`suspicious_unary_op_formatting`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_unary_op_formatting
[`tabs_in_doc_comments`]: https://rust-lang.github.io/rust-clippy/master/index.html#tabs_in_doc_comments
[`temporary_assignment`]: https://rust-lang.github.io/rust-clippy/master/index.html#temporary_assignment
Expand Down
2 changes: 1 addition & 1 deletion COPYRIGHT
@@ -1,4 +1,4 @@
Copyright 2014-2020 The Rust Project Developers
Copyright 2014-2021 The Rust Project Developers

Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Expand Up @@ -33,12 +33,13 @@ tempfile = { version = "3.1.0", optional = true }
cargo_metadata = "0.12"
compiletest_rs = { version = "0.6.0", features = ["tmp"] }
tester = "0.9"
clippy-mini-macro-test = { version = "0.2", path = "mini-macro" }
serde = { version = "1.0", features = ["derive"] }
derive-new = "0.5"
regex = "1.4"
quote = "1"
syn = { version = "1", features = ["full"] }
# This is used by the `collect-metadata` alias.
filetime = "0.2"

# A noop dependency that changes in the Rust repository, it's a bit of a hack.
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`
Expand Down
2 changes: 1 addition & 1 deletion LICENSE-APACHE
Expand Up @@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2014-2020 The Rust Project Developers
Copyright 2014-2021 The Rust Project Developers

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE-MIT
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2014-2020 The Rust Project Developers
Copyright (c) 2014-2021 The Rust Project Developers

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
Expand Down
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -147,6 +147,7 @@ Some lints can be configured in a TOML file named `clippy.toml` or `.clippy.toml
value` mapping eg.

```toml
avoid-breaking-exported-api = false
blacklisted-names = ["toto", "tata", "titi"]
cognitive-complexity-threshold = 30
```
Expand Down Expand Up @@ -236,7 +237,7 @@ If you want to contribute to Clippy, you can find more information in [CONTRIBUT

## License

Copyright 2014-2020 The Rust Project Developers
Copyright 2014-2021 The Rust Project Developers

Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
[https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)> or the MIT license
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Expand Up @@ -14,6 +14,6 @@ fn main() {
);
println!(
"cargo:rustc-env=RUSTC_RELEASE_CHANNEL={}",
rustc_tools_util::get_channel().unwrap_or_default()
rustc_tools_util::get_channel()
);
}
1 change: 1 addition & 0 deletions clippy.toml
@@ -0,0 +1 @@
avoid-breaking-exported-api = false
3 changes: 1 addition & 2 deletions clippy_lints/src/absurd_extreme_comparisons.rs
Expand Up @@ -3,9 +3,8 @@ use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty;
use rustc_session::{declare_lint_pass, declare_tool_lint};

use crate::consts::{constant, Constant};

use clippy_utils::comparisons::{normalize_comparison, Rel};
use clippy_utils::consts::{constant, Constant};
use clippy_utils::diagnostics::span_lint_and_help;
use clippy_utils::source::snippet;
use clippy_utils::ty::is_isize_or_usize;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/arithmetic.rs
@@ -1,4 +1,4 @@
use crate::consts::constant_simple;
use clippy_utils::consts::constant_simple;
use clippy_utils::diagnostics::span_lint;
use rustc_hir as hir;
use rustc_lint::{LateContext, LateLintPass};
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/assertions_on_constants.rs
@@ -1,4 +1,4 @@
use crate::consts::{constant, Constant};
use clippy_utils::consts::{constant, Constant};
use clippy_utils::diagnostics::span_lint_and_help;
use clippy_utils::source::snippet_opt;
use clippy_utils::{is_direct_expn_of, is_expn_of, match_panic_call};
Expand Down Expand Up @@ -63,7 +63,7 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants {
&format!("`assert!(false, {})` should probably be replaced", panic_message),
None,
&format!("use `panic!({})` or `unreachable!({})`", panic_message, panic_message),
)
);
};

if let Some(debug_assert_span) = is_expn_of(e.span, "debug_assert") {
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/attrs.rs
Expand Up @@ -273,7 +273,7 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
let attrs = cx.tcx.hir().attrs(item.hir_id());
if is_relevant_item(cx, item) {
check_attrs(cx, item.span, item.ident.name, attrs)
check_attrs(cx, item.span, item.ident.name, attrs);
}
match item.kind {
ItemKind::ExternCrate(..) | ItemKind::Use(..) => {
Expand Down Expand Up @@ -343,13 +343,13 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {

fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
if is_relevant_impl(cx, item) {
check_attrs(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id()))
check_attrs(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id()));
}
}

fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'_>) {
if is_relevant_trait(cx, item) {
check_attrs(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id()))
check_attrs(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id()));
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/bit_mask.rs
@@ -1,4 +1,4 @@
use crate::consts::{constant, Constant};
use clippy_utils::consts::{constant, Constant};
use clippy_utils::diagnostics::{span_lint, span_lint_and_then};
use clippy_utils::sugg::Sugg;
use if_chain::if_chain;
Expand Down Expand Up @@ -115,9 +115,9 @@ impl<'tcx> LateLintPass<'tcx> for BitMask {
if let ExprKind::Binary(cmp, left, right) = &e.kind {
if cmp.node.is_comparison() {
if let Some(cmp_opt) = fetch_int_literal(cx, right) {
check_compare(cx, left, cmp.node, cmp_opt, e.span)
check_compare(cx, left, cmp.node, cmp_opt, e.span);
} else if let Some(cmp_val) = fetch_int_literal(cx, left) {
check_compare(cx, right, invert_cmp(cmp.node), cmp_val, e.span)
check_compare(cx, right, invert_cmp(cmp.node), cmp_val, e.span);
}
}
}
Expand Down Expand Up @@ -171,7 +171,7 @@ fn check_compare(cx: &LateContext<'_>, bit_op: &Expr<'_>, cmp_op: BinOpKind, cmp
}
fetch_int_literal(cx, right)
.or_else(|| fetch_int_literal(cx, left))
.map_or((), |mask| check_bit_mask(cx, op.node, cmp_op, mask, cmp_value, span))
.map_or((), |mask| check_bit_mask(cx, op.node, cmp_op, mask, cmp_value, span));
}
}

Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/booleans.rs
Expand Up @@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for NonminimalBool {
_: Span,
_: HirId,
) {
NonminimalBoolVisitor { cx }.visit_body(body)
NonminimalBoolVisitor { cx }.visit_body(body);
}
}

Expand Down Expand Up @@ -184,7 +184,7 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
Term(n) => {
let terminal = self.terminals[n as usize];
if let Some(str) = simplify_not(self.cx, terminal) {
self.output.push_str(&str)
self.output.push_str(&str);
} else {
self.output.push('!');
let snip = snippet_opt(self.cx, terminal.span)?;
Expand Down Expand Up @@ -452,7 +452,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
}
match &e.kind {
ExprKind::Binary(binop, _, _) if binop.node == BinOpKind::Or || binop.node == BinOpKind::And => {
self.bool_expr(e)
self.bool_expr(e);
},
ExprKind::Unary(UnOp::Not, inner) => {
if self.cx.typeck_results().node_types()[inner.hir_id].is_bool() {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/casts/cast_sign_loss.rs
@@ -1,4 +1,4 @@
use crate::consts::{constant, Constant};
use clippy_utils::consts::{constant, Constant};
use clippy_utils::diagnostics::span_lint;
use clippy_utils::{method_chain_args, sext};
use if_chain::if_chain;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/collapsible_if.rs
Expand Up @@ -92,7 +92,7 @@ declare_lint_pass!(CollapsibleIf => [COLLAPSIBLE_IF, COLLAPSIBLE_ELSE_IF]);
impl EarlyLintPass for CollapsibleIf {
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) {
if !expr.span.from_expansion() {
check_if(cx, expr)
check_if(cx, expr);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/comparison_chain.rs
Expand Up @@ -120,7 +120,7 @@ impl<'tcx> LateLintPass<'tcx> for ComparisonChain {
"`if` chain can be rewritten with `match`",
None,
"consider rewriting the `if` chain to use `cmp` and `match`",
)
);
}
}

Expand Down
1 change: 0 additions & 1 deletion clippy_lints/src/consts.rs

This file was deleted.

2 changes: 1 addition & 1 deletion clippy_lints/src/copies.rs
Expand Up @@ -476,7 +476,7 @@ fn emit_branches_sharing_code_lint(
}

suggestions.push(("end", span, suggestion.to_string()));
add_expr_note = !cx.typeck_results().expr_ty(if_expr).is_unit()
add_expr_note = !cx.typeck_results().expr_ty(if_expr).is_unit();
}

let add_optional_msgs = |diag: &mut DiagnosticBuilder<'_>| {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/default_numeric_fallback.rs
Expand Up @@ -181,9 +181,9 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> {
match stmt.kind {
StmtKind::Local(local) => {
if local.ty.is_some() {
self.ty_bounds.push(TyBound::Any)
self.ty_bounds.push(TyBound::Any);
} else {
self.ty_bounds.push(TyBound::Nothing)
self.ty_bounds.push(TyBound::Nothing);
}
},

Expand Down
19 changes: 19 additions & 0 deletions clippy_lints/src/deprecated_lints.rs
Expand Up @@ -141,3 +141,22 @@ declare_deprecated_lint! {
pub FILTER_MAP,
"this lint has been replaced by `manual_filter_map`, a more specific lint"
}

declare_deprecated_lint! {
/// **What it does:** Nothing. This lint has been deprecated.
///
/// **Deprecation reason:** The `avoid_breaking_exported_api` config option was added, which
/// enables the `enum_variant_names` lint for public items.
/// ```
pub PUB_ENUM_VARIANT_NAMES,
"set the `avoid_breaking_exported_api` config option to `false` to enable the `enum_variant_names` lint for public items"
}

declare_deprecated_lint! {
/// **What it does:** Nothing. This lint has been deprecated.
///
/// **Deprecation reason:** The `avoid_breaking_exported_api` config option was added, which
/// enables the `wrong_self_conversion` lint for public items.
pub WRONG_PUB_SELF_CONVENTION,
"set the `avoid_breaking_exported_api` config option to `false` to enable the `wrong_self_convention` lint for public items"
}
8 changes: 4 additions & 4 deletions clippy_lints/src/double_comparison.rs
Expand Up @@ -70,16 +70,16 @@ impl<'tcx> DoubleComparisons {
#[rustfmt::skip]
match (op, lkind, rkind) {
(BinOpKind::Or, BinOpKind::Eq, BinOpKind::Lt) | (BinOpKind::Or, BinOpKind::Lt, BinOpKind::Eq) => {
lint_double_comparison!(<=)
lint_double_comparison!(<=);
},
(BinOpKind::Or, BinOpKind::Eq, BinOpKind::Gt) | (BinOpKind::Or, BinOpKind::Gt, BinOpKind::Eq) => {
lint_double_comparison!(>=)
lint_double_comparison!(>=);
},
(BinOpKind::Or, BinOpKind::Lt, BinOpKind::Gt) | (BinOpKind::Or, BinOpKind::Gt, BinOpKind::Lt) => {
lint_double_comparison!(!=)
lint_double_comparison!(!=);
},
(BinOpKind::And, BinOpKind::Le, BinOpKind::Ge) | (BinOpKind::And, BinOpKind::Ge, BinOpKind::Le) => {
lint_double_comparison!(==)
lint_double_comparison!(==);
},
_ => (),
};
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/duration_subsec.rs
Expand Up @@ -7,7 +7,7 @@ use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::source_map::Spanned;

use crate::consts::{constant, Constant};
use clippy_utils::consts::{constant, Constant};
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::paths;

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/entry.rs
Expand Up @@ -469,7 +469,7 @@ impl<'tcx> Visitor<'tcx> for InsertSearcher<'_, 'tcx> {
let mut is_map_used = self.is_map_used;
for arm in arms {
if let Some(Guard::If(guard) | Guard::IfLet(_, guard)) = arm.guard {
self.visit_non_tail_expr(guard)
self.visit_non_tail_expr(guard);
}
is_map_used |= self.visit_cond_arm(arm.body);
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/enum_clike.rs
@@ -1,7 +1,7 @@
//! lint on C-like enums that are `repr(isize/usize)` and have values that
//! don't fit into an `i32`

use crate::consts::{miri_to_const, Constant};
use clippy_utils::consts::{miri_to_const, Constant};
use clippy_utils::diagnostics::span_lint;
use rustc_hir::{Item, ItemKind};
use rustc_lint::{LateContext, LateLintPass};
Expand Down

0 comments on commit 6c27482

Please sign in to comment.