Skip to content

Commit b639b23

Browse files
committed
Merge remote-tracking branch 'upstream/master' into rustup
2 parents 60bb2a7 + a9d31e7 commit b639b23

File tree

230 files changed

+3582
-2054
lines changed

Some content is hidden

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

230 files changed

+3582
-2054
lines changed

.github/ISSUE_TEMPLATE/blank_issue.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ body:
99
attributes:
1010
label: Description
1111
description: >
12-
Please provide a discription of the issue, along with any information
12+
Please provide a description of the issue, along with any information
1313
you feel relevant to replicate it.
1414
validations:
1515
required: true

.github/ISSUE_TEMPLATE/false_negative.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ body:
2323
id: reproducer
2424
attributes:
2525
label: Reproducer
26-
description: Please provide the code and steps to repoduce the bug
26+
description: Please provide the code and steps to reproduce the bug
2727
value: |
2828
I tried this code:
2929

.github/ISSUE_TEMPLATE/false_positive.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ body:
2424
attributes:
2525
label: Reproducer
2626
description: >
27-
Please provide the code and steps to repoduce the bug together with the
27+
Please provide the code and steps to reproduce the bug together with the
2828
output from Clippy.
2929
value: |
3030
I tried this code:

.github/workflows/clippy.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ on:
66
branches-ignore:
77
- auto
88
- try
9-
# Don't run Clippy tests, when only textfiles were modified
9+
# Don't run Clippy tests, when only text files were modified
1010
paths-ignore:
1111
- 'COPYRIGHT'
1212
- 'LICENSE-*'
1313
- '**.md'
1414
- '**.txt'
1515
pull_request:
16-
# Don't run Clippy tests, when only textfiles were modified
16+
# Don't run Clippy tests, when only text files were modified
1717
paths-ignore:
1818
- 'COPYRIGHT'
1919
- 'LICENSE-*'

CHANGELOG.md

+110-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,108 @@ document.
66

77
## Unreleased / In Rust Nightly
88

9-
[57b3c4b...master](https://github.com/rust-lang/rust-clippy/compare/57b3c4b...master)
9+
[d0cf3481...master](https://github.com/rust-lang/rust-clippy/compare/d0cf3481...master)
10+
11+
## Rust 1.61 (beta)
12+
13+
Current beta, released 2022-05-19
14+
15+
[57b3c4b...d0cf3481](https://github.com/rust-lang/rust-clippy/compare/57b3c4b...d0cf3481)
16+
17+
### New Lints
18+
19+
* [`only_used_in_recursion`]
20+
[#8422](https://github.com/rust-lang/rust-clippy/pull/8422)
21+
* [`cast_enum_truncation`]
22+
[#8381](https://github.com/rust-lang/rust-clippy/pull/8381)
23+
* [`missing_spin_loop`]
24+
[#8174](https://github.com/rust-lang/rust-clippy/pull/8174)
25+
* [`deref_by_slicing`]
26+
[#8218](https://github.com/rust-lang/rust-clippy/pull/8218)
27+
* [`needless_match`]
28+
[#8471](https://github.com/rust-lang/rust-clippy/pull/8471)
29+
* [`allow_attributes_without_reason`] (Requires `#![feature(lint_reasons)]`)
30+
[#8504](https://github.com/rust-lang/rust-clippy/pull/8504)
31+
* [`print_in_format_impl`]
32+
[#8253](https://github.com/rust-lang/rust-clippy/pull/8253)
33+
* [`unnecessary_find_map`]
34+
[#8489](https://github.com/rust-lang/rust-clippy/pull/8489)
35+
* [`or_then_unwrap`]
36+
[#8561](https://github.com/rust-lang/rust-clippy/pull/8561)
37+
* [`unnecessary_join`]
38+
[#8579](https://github.com/rust-lang/rust-clippy/pull/8579)
39+
* [`iter_with_drain`]
40+
[#8483](https://github.com/rust-lang/rust-clippy/pull/8483)
41+
* [`cast_enum_constructor`]
42+
[#8562](https://github.com/rust-lang/rust-clippy/pull/8562)
43+
* [`cast_slice_different_sizes`]
44+
[#8445](https://github.com/rust-lang/rust-clippy/pull/8445)
45+
46+
### Moves and Deprecations
47+
48+
* Moved [`transmute_undefined_repr`] to `nursery` (now allow-by-default)
49+
[#8432](https://github.com/rust-lang/rust-clippy/pull/8432)
50+
* Moved [`try_err`] to `restriction`
51+
[#8544](https://github.com/rust-lang/rust-clippy/pull/8544)
52+
* Move [`iter_with_drain`] to `nursery`
53+
[#8541](https://github.com/rust-lang/rust-clippy/pull/8541)
54+
* Renamed `to_string_in_display` to [`recursive_format_impl`]
55+
[#8188](https://github.com/rust-lang/rust-clippy/pull/8188)
56+
57+
### Enhancements
58+
59+
* [`dbg_macro`]: The lint level can now be set with crate attributes and works inside macros
60+
[#8411](https://github.com/rust-lang/rust-clippy/pull/8411)
61+
* [`ptr_as_ptr`]: Now works inside macros
62+
[#8442](https://github.com/rust-lang/rust-clippy/pull/8442)
63+
* [`use_self`]: Now works for variants in match expressions
64+
[#8456](https://github.com/rust-lang/rust-clippy/pull/8456)
65+
* [`await_holding_lock`]: Now lints for `parking_lot::{Mutex, RwLock}`
66+
[#8419](https://github.com/rust-lang/rust-clippy/pull/8419)
67+
* [`recursive_format_impl`]: Now checks for format calls on `self`
68+
[#8188](https://github.com/rust-lang/rust-clippy/pull/8188)
69+
70+
### False Positive Fixes
71+
72+
* [`new_without_default`]: No longer lints for `new()` methods with `#[doc(hidden)]`
73+
[#8472](https://github.com/rust-lang/rust-clippy/pull/8472)
74+
* [`transmute_undefined_repr`]: No longer lints for single field structs with `#[repr(C)]`,
75+
generic parameters, wide pointers, unions, tuples and allow several forms of type erasure
76+
[#8425](https://github.com/rust-lang/rust-clippy/pull/8425)
77+
[#8553](https://github.com/rust-lang/rust-clippy/pull/8553)
78+
[#8440](https://github.com/rust-lang/rust-clippy/pull/8440)
79+
[#8547](https://github.com/rust-lang/rust-clippy/pull/8547)
80+
* [`match_single_binding`], [`match_same_arms`], [`match_as_ref`], [`match_bool`]: No longer
81+
lint `match` expressions with `cfg`ed arms
82+
[#8443](https://github.com/rust-lang/rust-clippy/pull/8443)
83+
* [`single_component_path_imports`]: No longer lint on macros
84+
[#8537](https://github.com/rust-lang/rust-clippy/pull/8537)
85+
* [`ptr_arg`]: Allow `&mut` arguments for `Cow<_>`
86+
[#8552](https://github.com/rust-lang/rust-clippy/pull/8552)
87+
* [`needless_borrow`]: No longer lints for method calls
88+
[#8441](https://github.com/rust-lang/rust-clippy/pull/8441)
89+
* [`match_same_arms`]: Now ensures that interposing arm patterns don't overlap
90+
[#8232](https://github.com/rust-lang/rust-clippy/pull/8232)
91+
* [`default_trait_access`]: Now allows `Default::default` in update expressions
92+
[#8433](https://github.com/rust-lang/rust-clippy/pull/8433)
93+
94+
### Suggestion Fixes/Improvements
95+
96+
* [`redundant_slicing`]: Fixed suggestion for a method calls
97+
[#8218](https://github.com/rust-lang/rust-clippy/pull/8218)
98+
* [`map_flatten`]: Long suggestions will now be split up into two help messages
99+
[#8520](https://github.com/rust-lang/rust-clippy/pull/8520)
100+
* [`unnecessary_lazy_evaluations`]: Now shows suggestions for longer code snippets
101+
[#8543](https://github.com/rust-lang/rust-clippy/pull/8543)
102+
* [`unnecessary_sort_by`]: Now suggests `Reverse` including the path
103+
[#8462](https://github.com/rust-lang/rust-clippy/pull/8462)
104+
* [`search_is_some`]: More suggestions are now `MachineApplicable`
105+
[#8536](https://github.com/rust-lang/rust-clippy/pull/8536)
106+
107+
### Documentation Improvements
108+
109+
* [`new_without_default`]: Document `pub` requirement for the struct and fields
110+
[#8429](https://github.com/rust-lang/rust-clippy/pull/8429)
10111

11112
## Rust 1.60
12113

@@ -3182,6 +3283,7 @@ Released 2018-09-13
31823283
[`assign_op_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#assign_op_pattern
31833284
[`assign_ops`]: https://rust-lang.github.io/rust-clippy/master/index.html#assign_ops
31843285
[`async_yields_async`]: https://rust-lang.github.io/rust-clippy/master/index.html#async_yields_async
3286+
[`await_holding_invalid_type`]: https://rust-lang.github.io/rust-clippy/master/index.html#await_holding_invalid_type
31853287
[`await_holding_lock`]: https://rust-lang.github.io/rust-clippy/master/index.html#await_holding_lock
31863288
[`await_holding_refcell_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#await_holding_refcell_ref
31873289
[`bad_bit_mask`]: https://rust-lang.github.io/rust-clippy/master/index.html#bad_bit_mask
@@ -3198,6 +3300,7 @@ Released 2018-09-13
31983300
[`boxed_local`]: https://rust-lang.github.io/rust-clippy/master/index.html#boxed_local
31993301
[`branches_sharing_code`]: https://rust-lang.github.io/rust-clippy/master/index.html#branches_sharing_code
32003302
[`builtin_type_shadow`]: https://rust-lang.github.io/rust-clippy/master/index.html#builtin_type_shadow
3303+
[`bytes_count_to_len`]: https://rust-lang.github.io/rust-clippy/master/index.html#bytes_count_to_len
32013304
[`bytes_nth`]: https://rust-lang.github.io/rust-clippy/master/index.html#bytes_nth
32023305
[`cargo_common_metadata`]: https://rust-lang.github.io/rust-clippy/master/index.html#cargo_common_metadata
32033306
[`case_sensitive_file_extension_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#case_sensitive_file_extension_comparisons
@@ -3262,6 +3365,7 @@ Released 2018-09-13
32623365
[`duplicate_underscore_argument`]: https://rust-lang.github.io/rust-clippy/master/index.html#duplicate_underscore_argument
32633366
[`duration_subsec`]: https://rust-lang.github.io/rust-clippy/master/index.html#duration_subsec
32643367
[`else_if_without_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#else_if_without_else
3368+
[`empty_drop`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_drop
32653369
[`empty_enum`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_enum
32663370
[`empty_line_after_outer_attr`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_outer_attr
32673371
[`empty_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_loop
@@ -3314,6 +3418,7 @@ Released 2018-09-13
33143418
[`forget_non_drop`]: https://rust-lang.github.io/rust-clippy/master/index.html#forget_non_drop
33153419
[`forget_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#forget_ref
33163420
[`format_in_format_args`]: https://rust-lang.github.io/rust-clippy/master/index.html#format_in_format_args
3421+
[`format_push_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#format_push_string
33173422
[`from_iter_instead_of_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#from_iter_instead_of_collect
33183423
[`from_over_into`]: https://rust-lang.github.io/rust-clippy/master/index.html#from_over_into
33193424
[`from_str_radix_10`]: https://rust-lang.github.io/rust-clippy/master/index.html#from_str_radix_10
@@ -3356,6 +3461,7 @@ Released 2018-09-13
33563461
[`invalid_regex`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_regex
33573462
[`invalid_upcast_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_upcast_comparisons
33583463
[`invisible_characters`]: https://rust-lang.github.io/rust-clippy/master/index.html#invisible_characters
3464+
[`is_digit_ascii_radix`]: https://rust-lang.github.io/rust-clippy/master/index.html#is_digit_ascii_radix
33593465
[`items_after_statements`]: https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements
33603466
[`iter_cloned_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_cloned_collect
33613467
[`iter_count`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_count
@@ -3472,6 +3578,7 @@ Released 2018-09-13
34723578
[`needless_lifetimes`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
34733579
[`needless_match`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_match
34743580
[`needless_option_as_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_option_as_deref
3581+
[`needless_option_take`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_option_take
34753582
[`needless_pass_by_value`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value
34763583
[`needless_question_mark`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_question_mark
34773584
[`needless_range_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_range_loop
@@ -3527,6 +3634,7 @@ Released 2018-09-13
35273634
[`ptr_eq`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_eq
35283635
[`ptr_offset_with_cast`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_with_cast
35293636
[`pub_enum_variant_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#pub_enum_variant_names
3637+
[`pub_use`]: https://rust-lang.github.io/rust-clippy/master/index.html#pub_use
35303638
[`question_mark`]: https://rust-lang.github.io/rust-clippy/master/index.html#question_mark
35313639
[`range_minus_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#range_minus_one
35323640
[`range_plus_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#range_plus_one
@@ -3650,6 +3758,7 @@ Released 2018-09-13
36503758
[`unnecessary_lazy_evaluations`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
36513759
[`unnecessary_mut_passed`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_mut_passed
36523760
[`unnecessary_operation`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_operation
3761+
[`unnecessary_owned_empty_strings`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_owned_empty_strings
36533762
[`unnecessary_self_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_self_imports
36543763
[`unnecessary_sort_by`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_sort_by
36553764
[`unnecessary_to_owned`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned

clippy_dev/src/main.rs

+44-7
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,31 @@ fn main() {
3636
}
3737
},
3838
("setup", Some(sub_command)) => match sub_command.subcommand() {
39-
("intellij", Some(matches)) => setup::intellij::setup_rustc_src(
40-
matches
41-
.value_of("rustc-repo-path")
42-
.expect("this field is mandatory and therefore always valid"),
43-
),
44-
("git-hook", Some(matches)) => setup::git_hook::install_hook(matches.is_present("force-override")),
45-
("vscode-tasks", Some(matches)) => setup::vscode::install_tasks(matches.is_present("force-override")),
39+
("intellij", Some(matches)) => {
40+
if matches.is_present("remove") {
41+
setup::intellij::remove_rustc_src();
42+
} else {
43+
setup::intellij::setup_rustc_src(
44+
matches
45+
.value_of("rustc-repo-path")
46+
.expect("this field is mandatory and therefore always valid"),
47+
);
48+
}
49+
},
50+
("git-hook", Some(matches)) => {
51+
if matches.is_present("remove") {
52+
setup::git_hook::remove_hook();
53+
} else {
54+
setup::git_hook::install_hook(matches.is_present("force-override"));
55+
}
56+
},
57+
("vscode-tasks", Some(matches)) => {
58+
if matches.is_present("remove") {
59+
setup::vscode::remove_tasks();
60+
} else {
61+
setup::vscode::install_tasks(matches.is_present("force-override"));
62+
}
63+
},
4664
_ => {},
4765
},
4866
("remove", Some(sub_command)) => match sub_command.subcommand() {
@@ -167,19 +185,32 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
167185
.subcommand(
168186
SubCommand::with_name("intellij")
169187
.about("Alter dependencies so Intellij Rust can find rustc internals")
188+
.arg(
189+
Arg::with_name("remove")
190+
.long("remove")
191+
.help("Remove the dependencies added with 'cargo dev setup intellij'")
192+
.required(false),
193+
)
170194
.arg(
171195
Arg::with_name("rustc-repo-path")
172196
.long("repo-path")
173197
.short("r")
174198
.help("The path to a rustc repo that will be used for setting the dependencies")
175199
.takes_value(true)
176200
.value_name("path")
201+
.conflicts_with("remove")
177202
.required(true),
178203
),
179204
)
180205
.subcommand(
181206
SubCommand::with_name("git-hook")
182207
.about("Add a pre-commit git hook that formats your code to make it look pretty")
208+
.arg(
209+
Arg::with_name("remove")
210+
.long("remove")
211+
.help("Remove the pre-commit hook added with 'cargo dev setup git-hook'")
212+
.required(false),
213+
)
183214
.arg(
184215
Arg::with_name("force-override")
185216
.long("force-override")
@@ -191,6 +222,12 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
191222
.subcommand(
192223
SubCommand::with_name("vscode-tasks")
193224
.about("Add several tasks to vscode for formatting, validation and testing")
225+
.arg(
226+
Arg::with_name("remove")
227+
.long("remove")
228+
.help("Remove the tasks added with 'cargo dev setup vscode-tasks'")
229+
.required(false),
230+
)
194231
.arg(
195232
Arg::with_name("force-override")
196233
.long("force-override")

clippy_dev/src/new_lint.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::clippy_project_root;
22
use indoc::indoc;
3+
use std::fmt::Write as _;
34
use std::fs::{self, OpenOptions};
45
use std::io::prelude::*;
56
use std::io::{self, ErrorKind};
@@ -232,7 +233,8 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
232233
)
233234
});
234235

235-
result.push_str(&format!(
236+
let _ = write!(
237+
result,
236238
indoc! {r#"
237239
declare_clippy_lint! {{
238240
/// ### What it does
@@ -256,7 +258,7 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
256258
version = version,
257259
name_upper = name_upper,
258260
category = category,
259-
));
261+
);
260262

261263
result.push_str(&if enable_msrv {
262264
format!(

clippy_dev/src/setup/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::path::Path;
77
const CLIPPY_DEV_DIR: &str = "clippy_dev";
88

99
/// This function verifies that the tool is being executed in the clippy directory.
10-
/// This is useful to ensure that setups only modify Clippys resources. The verification
10+
/// This is useful to ensure that setups only modify Clippy's resources. The verification
1111
/// is done by checking that `clippy_dev` is a sub directory of the current directory.
1212
///
1313
/// It will print an error message and return `false` if the directory could not be
@@ -17,7 +17,7 @@ fn verify_inside_clippy_dir() -> bool {
1717
if path.exists() && path.is_dir() {
1818
true
1919
} else {
20-
eprintln!("error: unable to verify that the working directory is clippys directory");
20+
eprintln!("error: unable to verify that the working directory is clippy's directory");
2121
false
2222
}
2323
}

clippy_dev/src/update_lints.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,13 @@ fn gen_lint_group_list<'a>(group_name: &str, lints: impl Iterator<Item = &'a Lin
217217

218218
let mut output = GENERATED_FILE_COMMENT.to_string();
219219

220-
output.push_str(&format!(
221-
"store.register_group(true, \"clippy::{0}\", Some(\"clippy_{0}\"), vec![\n",
220+
let _ = writeln!(
221+
output,
222+
"store.register_group(true, \"clippy::{0}\", Some(\"clippy_{0}\"), vec![",
222223
group_name
223-
));
224+
);
224225
for (module, name) in details {
225-
output.push_str(&format!(" LintId::of({}::{}),\n", module, name));
226+
let _ = writeln!(output, " LintId::of({}::{}),", module, name);
226227
}
227228
output.push_str("])\n");
228229

@@ -235,15 +236,16 @@ fn gen_deprecated(lints: &[DeprecatedLint]) -> String {
235236
let mut output = GENERATED_FILE_COMMENT.to_string();
236237
output.push_str("{\n");
237238
for lint in lints {
238-
output.push_str(&format!(
239+
let _ = write!(
240+
output,
239241
concat!(
240242
" store.register_removed(\n",
241243
" \"clippy::{}\",\n",
242244
" \"{}\",\n",
243245
" );\n"
244246
),
245247
lint.name, lint.reason,
246-
));
248+
);
247249
}
248250
output.push_str("}\n");
249251

@@ -269,7 +271,7 @@ fn gen_register_lint_list<'a>(
269271
if !is_public {
270272
output.push_str(" #[cfg(feature = \"internal\")]\n");
271273
}
272-
output.push_str(&format!(" {}::{},\n", module_name, lint_name));
274+
let _ = writeln!(output, " {}::{},", module_name, lint_name);
273275
}
274276
output.push_str("])\n");
275277

0 commit comments

Comments
 (0)