Skip to content

Commit 72d8d8d

Browse files
committed
Auto merge of #125202 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update r? `@Manishearth`
2 parents 791adf7 + bb1481a commit 72d8d8d

File tree

124 files changed

+4025
-1120
lines changed

Some content is hidden

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

124 files changed

+4025
-1120
lines changed

src/tools/clippy/.github/driver.sh

+11-8
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22

33
set -ex
44

5+
sysroot="$(rustc --print sysroot)"
6+
case $OS in
7+
Linux) export LD_LIBRARY_PATH="$sysroot/lib" ;;
8+
macOS) export DYLD_FALLBACK_LIBRARY_PATH="$sysroot/lib" ;;
9+
Windows) export PATH="$(cygpath "$sysroot")/bin:$PATH" ;;
10+
*) exit 1
11+
esac
12+
513
# Check sysroot handling
6-
sysroot=$(./target/debug/clippy-driver --print sysroot)
7-
test "$sysroot" = "$(rustc --print sysroot)"
8-
9-
if [[ ${OS} == "Windows" ]]; then
10-
desired_sysroot=C:/tmp
11-
else
12-
desired_sysroot=/tmp
13-
fi
14+
test "$(./target/debug/clippy-driver --print sysroot)" = "$sysroot"
15+
16+
desired_sysroot="target/sysroot"
1417
# Set --sysroot in command line
1518
sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot)
1619
test "$sysroot" = $desired_sysroot

src/tools/clippy/.github/workflows/clippy.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ jobs:
6969
working-directory: clippy_dev
7070

7171
- name: Test clippy-driver
72-
run: |
73-
TOOLCHAIN=$(rustup show active-toolchain | cut -f1 -d' ')
74-
rustup run $TOOLCHAIN bash .github/driver.sh
72+
run: .github/driver.sh
73+
env:
74+
OS: ${{ runner.os }}

src/tools/clippy/.github/workflows/clippy_bors.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ jobs:
116116
working-directory: clippy_dev
117117

118118
- name: Test clippy-driver
119-
run: |
120-
TOOLCHAIN=$(rustup show active-toolchain | cut -f1 -d' ')
121-
rustup run $TOOLCHAIN bash .github/driver.sh
119+
run: .github/driver.sh
122120
env:
123121
OS: ${{ runner.os }}
124122

src/tools/clippy/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -5249,6 +5249,7 @@ Released 2018-09-13
52495249
[`disallowed_type`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_type
52505250
[`disallowed_types`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types
52515251
[`diverging_sub_expression`]: https://rust-lang.github.io/rust-clippy/master/index.html#diverging_sub_expression
5252+
[`doc_lazy_continuation`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_lazy_continuation
52525253
[`doc_link_with_quotes`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_link_with_quotes
52535254
[`doc_markdown`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
52545255
[`double_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_comparisons
@@ -5447,6 +5448,7 @@ Released 2018-09-13
54475448
[`little_endian_bytes`]: https://rust-lang.github.io/rust-clippy/master/index.html#little_endian_bytes
54485449
[`logic_bug`]: https://rust-lang.github.io/rust-clippy/master/index.html#logic_bug
54495450
[`lossy_float_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#lossy_float_literal
5451+
[`macro_metavars_in_unsafe`]: https://rust-lang.github.io/rust-clippy/master/index.html#macro_metavars_in_unsafe
54505452
[`macro_use_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#macro_use_imports
54515453
[`main_recursion`]: https://rust-lang.github.io/rust-clippy/master/index.html#main_recursion
54525454
[`manual_assert`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_assert
@@ -5702,6 +5704,7 @@ Released 2018-09-13
57025704
[`ref_option_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_option_ref
57035705
[`ref_patterns`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_patterns
57045706
[`regex_macro`]: https://rust-lang.github.io/rust-clippy/master/index.html#regex_macro
5707+
[`renamed_function_params`]: https://rust-lang.github.io/rust-clippy/master/index.html#renamed_function_params
57055708
[`repeat_once`]: https://rust-lang.github.io/rust-clippy/master/index.html#repeat_once
57065709
[`repeat_vec_with_capacity`]: https://rust-lang.github.io/rust-clippy/master/index.html#repeat_vec_with_capacity
57075710
[`replace_consts`]: https://rust-lang.github.io/rust-clippy/master/index.html#replace_consts
@@ -5908,6 +5911,7 @@ Released 2018-09-13
59085911
[`verbose_file_reads`]: https://rust-lang.github.io/rust-clippy/master/index.html#verbose_file_reads
59095912
[`vtable_address_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#vtable_address_comparisons
59105913
[`waker_clone_wake`]: https://rust-lang.github.io/rust-clippy/master/index.html#waker_clone_wake
5914+
[`while_float`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_float
59115915
[`while_immutable_condition`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_immutable_condition
59125916
[`while_let_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_let_loop
59135917
[`while_let_on_iterator`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_let_on_iterator
@@ -5939,8 +5943,10 @@ Released 2018-09-13
59395943
[`allow-expect-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-expect-in-tests
59405944
[`allow-mixed-uninlined-format-args`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-mixed-uninlined-format-args
59415945
[`allow-one-hash-in-raw-strings`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-one-hash-in-raw-strings
5946+
[`allow-panic-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-panic-in-tests
59425947
[`allow-print-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-print-in-tests
59435948
[`allow-private-module-inception`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-private-module-inception
5949+
[`allow-renamed-params-for`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-renamed-params-for
59445950
[`allow-unwrap-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-unwrap-in-tests
59455951
[`allow-useless-vec-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-useless-vec-in-tests
59465952
[`allowed-dotfiles`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allowed-dotfiles
@@ -6002,4 +6008,5 @@ Released 2018-09-13
60026008
[`vec-box-size-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#vec-box-size-threshold
60036009
[`verbose-bit-mask-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#verbose-bit-mask-threshold
60046010
[`warn-on-all-wildcard-imports`]: https://doc.rust-lang.org/clippy/lint_configuration.html#warn-on-all-wildcard-imports
6011+
[`warn-unsafe-macro-metavars-in-private-macros`]: https://doc.rust-lang.org/clippy/lint_configuration.html#warn-unsafe-macro-metavars-in-private-macros
60056012
<!-- end autogenerated links to configuration documentation -->

src/tools/clippy/book/src/lint_configuration.md

+42
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ Whether to allow `r#""#` when `r""` can be used
101101
* [`unnecessary_raw_string_hashes`](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_raw_string_hashes)
102102

103103

104+
## `allow-panic-in-tests`
105+
Whether `panic` should be allowed in test functions or `#[cfg(test)]`
106+
107+
**Default Value:** `false`
108+
109+
---
110+
**Affected lints:**
111+
* [`panic`](https://rust-lang.github.io/rust-clippy/master/index.html#panic)
112+
113+
104114
## `allow-print-in-tests`
105115
Whether print macros (ex. `println!`) should be allowed in test functions or `#[cfg(test)]`
106116

@@ -122,6 +132,28 @@ Whether to allow module inception if it's not public.
122132
* [`module_inception`](https://rust-lang.github.io/rust-clippy/master/index.html#module_inception)
123133

124134

135+
## `allow-renamed-params-for`
136+
List of trait paths to ignore when checking renamed function parameters.
137+
138+
#### Example
139+
140+
```toml
141+
allow-renamed-params-for = [ "std::convert::From" ]
142+
```
143+
144+
#### Noteworthy
145+
146+
- By default, the following traits are ignored: `From`, `TryFrom`, `FromStr`
147+
- `".."` can be used as part of the list to indicate that the configured values should be appended to the
148+
default configuration of Clippy. By default, any configuration will replace the default value.
149+
150+
**Default Value:** `["core::convert::From", "core::convert::TryFrom", "core::str::FromStr"]`
151+
152+
---
153+
**Affected lints:**
154+
* [`renamed_function_params`](https://rust-lang.github.io/rust-clippy/master/index.html#renamed_function_params)
155+
156+
125157
## `allow-unwrap-in-tests`
126158
Whether `unwrap` should be allowed in test functions or `#[cfg(test)]`
127159

@@ -900,3 +932,13 @@ Whether to allow certain wildcard imports (prelude, super in tests).
900932
* [`wildcard_imports`](https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_imports)
901933

902934

935+
## `warn-unsafe-macro-metavars-in-private-macros`
936+
Whether to also emit warnings for unsafe blocks with metavariable expansions in **private** macros.
937+
938+
**Default Value:** `false`
939+
940+
---
941+
**Affected lints:**
942+
* [`macro_metavars_in_unsafe`](https://rust-lang.github.io/rust-clippy/master/index.html#macro_metavars_in_unsafe)
943+
944+

src/tools/clippy/clippy_config/src/conf.rs

+31
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ const DEFAULT_DOC_VALID_IDENTS: &[&str] = &[
4040
const DEFAULT_DISALLOWED_NAMES: &[&str] = &["foo", "baz", "quux"];
4141
const DEFAULT_ALLOWED_IDENTS_BELOW_MIN_CHARS: &[&str] = &["i", "j", "x", "y", "z", "w", "n"];
4242
const DEFAULT_ALLOWED_PREFIXES: &[&str] = &["to", "as", "into", "from", "try_into", "try_from"];
43+
const DEFAULT_ALLOWED_TRAITS_WITH_RENAMED_PARAMS: &[&str] =
44+
&["core::convert::From", "core::convert::TryFrom", "core::str::FromStr"];
4345

4446
/// Conf with parse errors
4547
#[derive(Default)]
@@ -455,6 +457,10 @@ define_Conf! {
455457
///
456458
/// Whether `unwrap` should be allowed in test functions or `#[cfg(test)]`
457459
(allow_unwrap_in_tests: bool = false),
460+
/// Lint: PANIC.
461+
///
462+
/// Whether `panic` should be allowed in test functions or `#[cfg(test)]`
463+
(allow_panic_in_tests: bool = false),
458464
/// Lint: DBG_MACRO.
459465
///
460466
/// Whether `dbg!` should be allowed in test functions or `#[cfg(test)]`
@@ -613,6 +619,27 @@ define_Conf! {
613619
/// - Use `".."` as part of the list to indicate that the configured values should be appended to the
614620
/// default configuration of Clippy. By default, any configuration will replace the default value
615621
(allowed_prefixes: Vec<String> = DEFAULT_ALLOWED_PREFIXES.iter().map(ToString::to_string).collect()),
622+
/// Lint: RENAMED_FUNCTION_PARAMS.
623+
///
624+
/// List of trait paths to ignore when checking renamed function parameters.
625+
///
626+
/// #### Example
627+
///
628+
/// ```toml
629+
/// allow-renamed-params-for = [ "std::convert::From" ]
630+
/// ```
631+
///
632+
/// #### Noteworthy
633+
///
634+
/// - By default, the following traits are ignored: `From`, `TryFrom`, `FromStr`
635+
/// - `".."` can be used as part of the list to indicate that the configured values should be appended to the
636+
/// default configuration of Clippy. By default, any configuration will replace the default value.
637+
(allow_renamed_params_for: Vec<String> =
638+
DEFAULT_ALLOWED_TRAITS_WITH_RENAMED_PARAMS.iter().map(ToString::to_string).collect()),
639+
/// Lint: MACRO_METAVARS_IN_UNSAFE.
640+
///
641+
/// Whether to also emit warnings for unsafe blocks with metavariable expansions in **private** macros.
642+
(warn_unsafe_macro_metavars_in_private_macros: bool = false),
616643
}
617644

618645
/// Search for the configuration file.
@@ -674,6 +701,10 @@ fn deserialize(file: &SourceFile) -> TryConf {
674701
extend_vec_if_indicator_present(&mut conf.conf.doc_valid_idents, DEFAULT_DOC_VALID_IDENTS);
675702
extend_vec_if_indicator_present(&mut conf.conf.disallowed_names, DEFAULT_DISALLOWED_NAMES);
676703
extend_vec_if_indicator_present(&mut conf.conf.allowed_prefixes, DEFAULT_ALLOWED_PREFIXES);
704+
extend_vec_if_indicator_present(
705+
&mut conf.conf.allow_renamed_params_for,
706+
DEFAULT_ALLOWED_TRAITS_WITH_RENAMED_PARAMS,
707+
);
677708
// TODO: THIS SHOULD BE TESTED, this comment will be gone soon
678709
if conf.conf.allowed_idents_below_min_chars.contains("..") {
679710
conf.conf

src/tools/clippy/clippy_config/src/msrvs.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ msrv_aliases! {
2626
1,63,0 { CLONE_INTO }
2727
1,62,0 { BOOL_THEN_SOME, DEFAULT_ENUM_ATTRIBUTE }
2828
1,59,0 { THREAD_LOCAL_INITIALIZER_CAN_BE_MADE_CONST }
29-
1,58,0 { FORMAT_ARGS_CAPTURE, PATTERN_TRAIT_CHAR_ARRAY }
29+
1,58,0 { FORMAT_ARGS_CAPTURE, PATTERN_TRAIT_CHAR_ARRAY, CONST_RAW_PTR_DEREF }
30+
1,56,0 { CONST_FN_UNION }
3031
1,55,0 { SEEK_REWIND }
3132
1,54,0 { INTO_KEYS }
3233
1,53,0 { OR_PATTERNS, MANUAL_BITS, BTREE_MAP_RETAIN, BTREE_SET_RETAIN, ARRAY_INTO_ITERATOR }

src/tools/clippy/clippy_dev/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
[package]
22
name = "clippy_dev"
3+
description = "Clippy developer tooling"
34
version = "0.0.1"
45
edition = "2021"
56

67
[dependencies]
78
aho-corasick = "1.0"
8-
clap = "4.1.4"
9+
clap = { version = "4.4", features = ["derive"] }
910
indoc = "1.0"
1011
itertools = "0.12"
1112
opener = "0.6"

0 commit comments

Comments
 (0)