Skip to content

Commit 9ac237d

Browse files
committed
Auto merge of rust-lang#100419 - flip1995:clippyup, r=Manishearth
Update Clippy r? `@Manishearth`
2 parents 4d8b6d4 + dc29cfb commit 9ac237d

File tree

182 files changed

+2239
-826
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+2239
-826
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ Released 2021-09-09
965965
[#7407](https://github.com/rust-lang/rust-clippy/pull/7407)
966966
* [`redundant_allocation`]: Now additionally supports the `Arc<>` type
967967
[#7308](https://github.com/rust-lang/rust-clippy/pull/7308)
968-
* [`blacklisted_name`]: Now allows blacklisted names in test code
968+
* [`disallowed_names`]: Now allows disallowed names in test code
969969
[#7379](https://github.com/rust-lang/rust-clippy/pull/7379)
970970
* [`redundant_closure`]: Suggests `&mut` for `FnMut`
971971
[#7437](https://github.com/rust-lang/rust-clippy/pull/7437)
@@ -2066,7 +2066,7 @@ Released 2020-08-27
20662066
[#5692](https://github.com/rust-lang/rust-clippy/pull/5692)
20672067
* [`if_same_then_else`]: Don't assume multiplication is always commutative
20682068
[#5702](https://github.com/rust-lang/rust-clippy/pull/5702)
2069-
* [`blacklisted_name`]: Remove `bar` from the default configuration
2069+
* [`disallowed_names`]: Remove `bar` from the default configuration
20702070
[#5712](https://github.com/rust-lang/rust-clippy/pull/5712)
20712071
* [`redundant_pattern_matching`]: Avoid suggesting non-`const fn` calls in const contexts
20722072
[#5724](https://github.com/rust-lang/rust-clippy/pull/5724)
@@ -3522,6 +3522,7 @@ Released 2018-09-13
35223522
[`derive_partial_eq_without_eq`]: https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq
35233523
[`disallowed_method`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_method
35243524
[`disallowed_methods`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods
3525+
[`disallowed_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names
35253526
[`disallowed_script_idents`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_script_idents
35263527
[`disallowed_type`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_type
35273528
[`disallowed_types`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types
@@ -3685,6 +3686,7 @@ Released 2018-09-13
36853686
[`manual_find`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_find
36863687
[`manual_find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_find_map
36873688
[`manual_flatten`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_flatten
3689+
[`manual_instant_elapsed`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_instant_elapsed
36883690
[`manual_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_map
36893691
[`manual_memcpy`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_memcpy
36903692
[`manual_non_exhaustive`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_non_exhaustive
@@ -3816,11 +3818,13 @@ Released 2018-09-13
38163818
[`or_then_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#or_then_unwrap
38173819
[`out_of_bounds_indexing`]: https://rust-lang.github.io/rust-clippy/master/index.html#out_of_bounds_indexing
38183820
[`overflow_check_conditional`]: https://rust-lang.github.io/rust-clippy/master/index.html#overflow_check_conditional
3821+
[`overly_complex_bool_expr`]: https://rust-lang.github.io/rust-clippy/master/index.html#overly_complex_bool_expr
38193822
[`panic`]: https://rust-lang.github.io/rust-clippy/master/index.html#panic
38203823
[`panic_in_result_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#panic_in_result_fn
38213824
[`panic_params`]: https://rust-lang.github.io/rust-clippy/master/index.html#panic_params
38223825
[`panicking_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#panicking_unwrap
38233826
[`partialeq_ne_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#partialeq_ne_impl
3827+
[`partialeq_to_none`]: https://rust-lang.github.io/rust-clippy/master/index.html#partialeq_to_none
38243828
[`path_buf_push_overwrite`]: https://rust-lang.github.io/rust-clippy/master/index.html#path_buf_push_overwrite
38253829
[`pattern_type_mismatch`]: https://rust-lang.github.io/rust-clippy/master/index.html#pattern_type_mismatch
38263830
[`possible_missing_comma`]: https://rust-lang.github.io/rust-clippy/master/index.html#possible_missing_comma

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ All contributors are expected to follow the [Rust Code of Conduct].
3030
## The Clippy book
3131

3232
If you're new to Clippy and don't know where to start the [Clippy book] includes
33-
a developer guide and is a good place to start your journey.
33+
a [developer guide] and is a good place to start your journey.
3434

35-
<!-- FIXME: Link to the deployed book, once it is deployed through CI -->
36-
[Clippy book]: book/src
35+
[Clippy book]: https://doc.rust-lang.org/nightly/clippy/index.html
36+
[developer guide]: https://doc.rust-lang.org/nightly/clippy/development/index.html
3737

3838
## High level approach
3939

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.64"
3+
version = "0.1.65"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ value` mapping e.g.
144144

145145
```toml
146146
avoid-breaking-exported-api = false
147-
blacklisted-names = ["toto", "tata", "titi"]
147+
disallowed-names = ["toto", "tata", "titi"]
148148
cognitive-complexity-threshold = 30
149149
```
150150

book/src/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ basic `variable = value` mapping eg.
77

88
```toml
99
avoid-breaking-exported-api = false
10-
blacklisted-names = ["toto", "tata", "titi"]
10+
disallowed-names = ["toto", "tata", "titi"]
1111
cognitive-complexity-threshold = 30
1212
```
1313

clippy_dev/src/new_lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ fn setup_mod_file(path: &Path, lint: &LintData<'_>) -> io::Result<&'static str>
438438
let mut lint_context = None;
439439

440440
let mut iter = rustc_lexer::tokenize(&file_contents).map(|t| {
441-
let range = offset..offset + t.len;
441+
let range = offset..offset + t.len as usize;
442442
offset = range.end;
443443

444444
LintDeclSearchResult {

clippy_dev/src/update_lints.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ pub(crate) struct LintDeclSearchResult<'a> {
836836
fn parse_contents(contents: &str, module: &str, lints: &mut Vec<Lint>) {
837837
let mut offset = 0usize;
838838
let mut iter = tokenize(contents).map(|t| {
839-
let range = offset..offset + t.len;
839+
let range = offset..offset + t.len as usize;
840840
offset = range.end;
841841

842842
LintDeclSearchResult {
@@ -899,7 +899,7 @@ fn parse_contents(contents: &str, module: &str, lints: &mut Vec<Lint>) {
899899
fn parse_deprecated_contents(contents: &str, lints: &mut Vec<DeprecatedLint>) {
900900
let mut offset = 0usize;
901901
let mut iter = tokenize(contents).map(|t| {
902-
let range = offset..offset + t.len;
902+
let range = offset..offset + t.len as usize;
903903
offset = range.end;
904904

905905
LintDeclSearchResult {
@@ -946,7 +946,7 @@ fn parse_renamed_contents(contents: &str, lints: &mut Vec<RenamedLint>) {
946946
for line in contents.lines() {
947947
let mut offset = 0usize;
948948
let mut iter = tokenize(line).map(|t| {
949-
let range = offset..offset + t.len;
949+
let range = offset..offset + t.len as usize;
950950
offset = range.end;
951951

952952
LintDeclSearchResult {

clippy_lints/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_lints"
3-
version = "0.1.64"
3+
version = "0.1.65"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"

clippy_lints/src/assertions_on_result_states.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnResultStates {
5353
if result_type_with_refs != result_type {
5454
return;
5555
} else if let Res::Local(binding_id) = path_res(cx, recv)
56-
&& local_used_after_expr(cx, binding_id, recv) {
56+
&& local_used_after_expr(cx, binding_id, recv)
57+
{
5758
return;
5859
}
5960
}
6061
let mut app = Applicability::MachineApplicable;
6162
match method_segment.ident.as_str() {
62-
"is_ok" if has_debug_impl(cx, substs.type_at(1)) => {
63+
"is_ok" if type_suitable_to_unwrap(cx, substs.type_at(1)) => {
6364
span_lint_and_sugg(
6465
cx,
6566
ASSERTIONS_ON_RESULT_STATES,
@@ -73,7 +74,7 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnResultStates {
7374
app,
7475
);
7576
}
76-
"is_err" if has_debug_impl(cx, substs.type_at(0)) => {
77+
"is_err" if type_suitable_to_unwrap(cx, substs.type_at(0)) => {
7778
span_lint_and_sugg(
7879
cx,
7980
ASSERTIONS_ON_RESULT_STATES,
@@ -99,3 +100,7 @@ fn has_debug_impl<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
99100
.get_diagnostic_item(sym::Debug)
100101
.map_or(false, |debug| implements_trait(cx, ty, debug, &[]))
101102
}
103+
104+
fn type_suitable_to_unwrap<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
105+
has_debug_impl(cx, ty) && !ty.is_unit() && !ty.is_never()
106+
}

clippy_lints/src/booleans.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ declare_clippy_lint! {
6464
/// if a {}
6565
/// ```
6666
#[clippy::version = "pre 1.29.0"]
67-
pub LOGIC_BUG,
67+
pub OVERLY_COMPLEX_BOOL_EXPR,
6868
correctness,
6969
"boolean expressions that contain terminals which can be eliminated"
7070
}
7171

7272
// For each pairs, both orders are considered.
7373
const METHODS_WITH_NEGATION: [(&str, &str); 2] = [("is_some", "is_none"), ("is_err", "is_ok")];
7474

75-
declare_lint_pass!(NonminimalBool => [NONMINIMAL_BOOL, LOGIC_BUG]);
75+
declare_lint_pass!(NonminimalBool => [NONMINIMAL_BOOL, OVERLY_COMPLEX_BOOL_EXPR]);
7676

7777
impl<'tcx> LateLintPass<'tcx> for NonminimalBool {
7878
fn check_fn(
@@ -396,7 +396,7 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
396396
if stats.terminals[i] != 0 && simplified_stats.terminals[i] == 0 {
397397
span_lint_hir_and_then(
398398
self.cx,
399-
LOGIC_BUG,
399+
OVERLY_COMPLEX_BOOL_EXPR,
400400
e.hir_id,
401401
e.span,
402402
"this boolean expression contains a logic bug",

0 commit comments

Comments
 (0)