Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b998821

Browse files
committed
Auto merge of rust-lang#100419 - flip1995:clippyup, r=Manishearth
Update Clippy r? `@Manishearth`
2 parents 2ed0f29 + ea90d4b commit b998821

File tree

183 files changed

+2242
-829
lines changed

Some content is hidden

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

183 files changed

+2242
-829
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ dependencies = [
661661

662662
[[package]]
663663
name = "clippy"
664-
version = "0.1.64"
664+
version = "0.1.65"
665665
dependencies = [
666666
"clippy_lints",
667667
"clippy_utils",
@@ -704,7 +704,7 @@ dependencies = [
704704

705705
[[package]]
706706
name = "clippy_lints"
707-
version = "0.1.64"
707+
version = "0.1.65"
708708
dependencies = [
709709
"cargo_metadata 0.14.0",
710710
"clippy_utils",
@@ -726,7 +726,7 @@ dependencies = [
726726

727727
[[package]]
728728
name = "clippy_utils"
729-
version = "0.1.64"
729+
version = "0.1.65"
730730
dependencies = [
731731
"arrayvec",
732732
"if_chain",

src/tools/clippy/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

src/tools/clippy/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

src/tools/clippy/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"

src/tools/clippy/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

src/tools/clippy/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

src/tools/clippy/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 {

src/tools/clippy/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 {

src/tools/clippy/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"

src/tools/clippy/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+
}

0 commit comments

Comments
 (0)