Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy subtree sync #116489

Merged
merged 83 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
1c77b0b
Move needless_raw_string_hashes to pedantic
Alexendoo Aug 27, 2023
b5941a2
Partially outline code inside the panic! macro
Zoxc Sep 3, 2023
39f7f69
Add msrv test template for `cargo dev new_lint --msrv`
Alexendoo Sep 23, 2023
772296c
Merge commit '7671c283a50b5d1168841f3014b14000f01dd204' into clippyup
flip1995 Sep 25, 2023
6ad218c
Add colored help
blyxyas Sep 13, 2023
78ddc8d
Auto merge of #11495 - blyxyas:help_message_reformat, r=flip1995
bors Sep 25, 2023
1972cc8
Test that each config value exists in a test clippy.toml
Alexendoo Sep 25, 2023
84d6894
it's not Miri but MIR constants
RalfJung Sep 25, 2023
ce45221
simply some valtree-to-const conversion
RalfJung Sep 25, 2023
0f19857
mir_to_const: fix handling of float arrays
RalfJung Sep 25, 2023
6c48ef3
Auto merge of #11557 - Alexendoo:dev-new-lint-msrv-test, r=Manishearth
bors Sep 25, 2023
bf4c998
Auto merge of #11564 - Alexendoo:config-test-test, r=giraffate
bors Sep 26, 2023
5507482
Don't store lazyness in DefKind
compiler-errors Sep 26, 2023
fab9000
Do not lint when imported item contains underscore
koka831 Feb 6, 2023
f2efdba
subst -> instantiate
lcnr Sep 25, 2023
585b56f
Auto merge of #10300 - koka831:fix/9942, r=xFrednet
bors Sep 26, 2023
6cdff10
Describe the type of string in raw_strings lints
Alexendoo Sep 26, 2023
ec2f626
Add `manual_hash_one` lint
Alexendoo Sep 23, 2023
493ab53
Auto merge of #11556 - Alexendoo:manual-hash-one, r=Manishearth
bors Sep 26, 2023
4494b69
Auto merge of #11569 - Alexendoo:needless-raw-string-descr, r=llogiq
bors Sep 26, 2023
7f132e8
Auto merge of #116144 - lcnr:subst-less, r=oli-obk
bors Sep 26, 2023
3b75db7
Auto merge of #116163 - compiler-errors:lazyness, r=oli-obk
bors Sep 27, 2023
62b8ef3
Mention that `missing_assert_message` lint ignores test functions
unexge Sep 27, 2023
124f1b0
Auto merge of #11574 - unexge:missing-assert-message-docs, r=Alexendoo
bors Sep 28, 2023
b413bf6
Fix index of the remaining positional arguments
koka831 Sep 28, 2023
29ed6fa
Auto merge of #11415 - Alexendoo:needless-raw-string-hashes-pedantic,…
bors Sep 28, 2023
d18d01a
Auto merge of #11576 - koka831:fix/10128, r=llogiq
bors Sep 28, 2023
91997a4
Auto merge of #11565 - RalfJung:mir_to_const, r=Jarcho
bors Sep 28, 2023
82207f4
Move needless_raw_string_hashes to pedantic
Alexendoo Aug 27, 2023
330ebbb
new lint: `iter_without_into_iter`
y21 Sep 17, 2023
38fd80a
Remove `rustc_lint_defs::lint_array`
DaniPopes Sep 28, 2023
a4d11d9
Reverse postorder instead of using reversed postorder
WaffleLapkin Sep 28, 2023
ad5653b
Add missing lint description headers
DaniPopes Sep 29, 2023
d38fa1a
Auto merge of #11527 - y21:iter_without_into_iter, r=Jarcho
bors Sep 29, 2023
1a82ca0
Rollup merge of #116245 - flip1995:clippy-backport, r=Manishearth
matthiaskrgr Sep 29, 2023
67a83ff
Auto merge of #11582 - DaniPopes:missing-headers, r=xFrednet
bors Sep 29, 2023
2d20179
[`manual_let_else`]: only omit block if span is from same ctxt
y21 Sep 28, 2023
b00236d
Auto merge of #11580 - y21:issue11579, r=Jarcho
bors Sep 29, 2023
ad0b7ed
Auto merge of #116254 - WaffleLapkin:nicen-traversal, r=cjgillot
bors Sep 30, 2023
44b6aca
Avoid linting in external/proc macro
koka831 Sep 30, 2023
d5cc97e
Add macro for test which use std internally
koka831 Sep 30, 2023
8eb586d
new lint: `into_iter_without_iter`
y21 Sep 30, 2023
0e43a04
Auto merge of #11587 - y21:into_iter_without_iter, r=Jarcho
bors Sep 30, 2023
e683e3e
Don't lint `manual_non_exhaustive` when enum explicitly marked as `no…
Tyrubias Oct 1, 2023
3169423
Auto merge of #115670 - Zoxc:outline-panic-macro-1, r=Mark-Simulacrum
bors Oct 1, 2023
9dfd60c
Remove extraneous `#[non_exhaustive]` check in lint
Tyrubias Oct 1, 2023
6f1a78f
Use Span#from_expansion instead of in_external_macro
koka831 Oct 1, 2023
0f8b862
Fix documentation link
schubart Oct 1, 2023
cbe67bc
Auto merge of #11590 - Tyrubias:non_ex_false_positive, r=Alexendoo
bors Oct 1, 2023
ec15630
Auto merge of #11592 - schubart:fix_documentation_link, r=flip1995
bors Oct 1, 2023
aee3daf
Auto merge of #11593 - koka831:fix/10511, r=xFrednet
bors Oct 1, 2023
258b9a8
Don't escape unicode escape braces in print_literal
Alexendoo Jul 31, 2023
331d01e
Auto merge of #11265 - Alexendoo:print-literal-unicode-escapes, r=llogiq
bors Oct 1, 2023
3f0da4d
Move `needless_pass_by_ref_mut`: `suspicious` -> `nursery`
blyxyas Oct 2, 2023
07e6329
Modify tests to account for the new allow-by-default `needless_pass_b…
blyxyas Oct 2, 2023
08c429f
Auto merge of #11596 - blyxyas:fix-fp-needless_pass_by_ref_mut, r=Jarcho
bors Oct 2, 2023
ea4b388
subtyping_projections
ouz-a Aug 16, 2023
81400e2
Auto merge of #11589 - koka831:fix/10198, r=giraffate
bors Oct 3, 2023
2c525fd
Point to full async fn for future
compiler-errors Oct 2, 2023
f107a50
Auto merge of #115025 - ouz-a:ouz_testing, r=lcnr
bors Oct 3, 2023
e465264
Avoid invoking `ignored_unit_patterns` in macro definition
koka831 Oct 3, 2023
1a56f90
Fix: avoid changing drop order
koka831 Oct 3, 2023
29958f0
Auto merge of #11602 - koka831:fix/11601, r=xFrednet
bors Oct 3, 2023
c715267
Apply review suggestions from @y21
koka831 Oct 3, 2023
b437069
Auto merge of #11603 - koka831:fix/11599, r=y21
bors Oct 3, 2023
eab0a75
Update version attribute for 1.73 lints
xFrednet Oct 3, 2023
8d920a8
Changelog for Rust 1.73 :pen:
xFrednet Oct 3, 2023
9483555
sudo CI=green
xFrednet Oct 3, 2023
404217e
Address PR Review <3
xFrednet Oct 4, 2023
716f211
Auto merge of #116360 - compiler-errors:async-span, r=oli-obk
bors Oct 4, 2023
9554e47
Auto merge of #11605 - xFrednet:changelog-1-73, r=blyxyas
bors Oct 4, 2023
56794fa
Fix clippy
compiler-errors Oct 2, 2023
c5c6d70
Point to closure return instead of output if defaulted
compiler-errors Oct 2, 2023
dcc4001
Fix `items_after_test_module` for non root modules, add applicable su…
Alexendoo Oct 4, 2023
48d2770
Improve `redundant_locals` help message
koka831 Oct 6, 2023
279127c
Auto merge of #11611 - Alexendoo:items-after-test-module-check-crate,…
bors Oct 6, 2023
7217c0f
Auto merge of #11628 - koka831:fix/11625, r=blyxyas
bors Oct 6, 2023
82c3064
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Oct 6, 2023
50754da
Bump nightly version -> 2023-10-06
flip1995 Oct 6, 2023
b8677e5
Bump Clippy version -> 0.1.75
flip1995 Oct 6, 2023
b105fb4
Auto merge of #11629 - flip1995:rustup, r=flip1995
bors Oct 6, 2023
3c8c3ad
Merge commit 'b105fb4c39bc1a010807a6c076193cef8d93c109' into clippyup
flip1995 Oct 6, 2023
6233d44
Update Cargo.lock
flip1995 Oct 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -508,10 +508,12 @@ checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"

[[package]]
name = "clippy"
version = "0.1.74"
version = "0.1.75"
dependencies = [
"anstream",
"clippy_lints",
"clippy_utils",
"color-print",
"filetime",
"futures",
"if_chain",
Expand Down Expand Up @@ -546,7 +548,7 @@ dependencies = [

[[package]]
name = "clippy_lints"
version = "0.1.74"
version = "0.1.75"
dependencies = [
"arrayvec",
"cargo_metadata",
Expand All @@ -566,11 +568,12 @@ dependencies = [
"unicode-normalization",
"unicode-script",
"url",
"walkdir",
]

[[package]]
name = "clippy_utils"
version = "0.1.74"
version = "0.1.75"
dependencies = [
"arrayvec",
"if_chain",
Expand Down Expand Up @@ -603,6 +606,27 @@ dependencies = [
"tracing-error",
]

[[package]]
name = "color-print"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a858372ff14bab9b1b30ea504f2a4bc534582aee3e42ba2d41d2a7baba63d5d"
dependencies = [
"color-print-proc-macro",
]

[[package]]
name = "color-print-proc-macro"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57e37866456a721d0a404439a1adae37a31be4e0055590d053dfe6981e05003f"
dependencies = [
"nom",
"proc-macro2",
"quote",
"syn 1.0.109",
]

[[package]]
name = "color-spantrace"
version = "0.2.0"
Expand Down Expand Up @@ -933,7 +957,7 @@ checksum = "a0afaad2b26fa326569eb264b1363e8ae3357618c43982b3f285f0774ce76b69"

[[package]]
name = "declare_clippy_lint"
version = "0.1.74"
version = "0.1.75"
dependencies = [
"itertools",
"quote",
Expand Down
97 changes: 95 additions & 2 deletions src/tools/clippy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,101 @@ document.

## Unreleased / Beta / In Rust Nightly

[37f4c172...master](https://github.com/rust-lang/rust-clippy/compare/37f4c172...master)
[1e8fdf49...master](https://github.com/rust-lang/rust-clippy/compare/1e8fdf49...master)

## Rust 1.73

Current stable, released 2023-10-05

[View all 103 merged pull requests](https://github.com/rust-lang/rust-clippy/pulls?q=merged%3A2023-07-02T12%3A24%3A40Z..2023-08-11T11%3A09%3A56Z+base%3Amaster)

### New Lints

* [`impossible_comparisons`]
[#10843](https://github.com/rust-lang/rust-clippy/pull/10843)
* [`redundant_comparisons`]
[#10843](https://github.com/rust-lang/rust-clippy/pull/10843)
* [`ignored_unit_patterns`]
[#11242](https://github.com/rust-lang/rust-clippy/pull/11242)
* [`readonly_write_lock`]
[#11210](https://github.com/rust-lang/rust-clippy/pull/11210)
* [`filter_map_bool_then`]
[#11115](https://github.com/rust-lang/rust-clippy/pull/11115)
* [`needless_return_with_question_mark`]
[#11031](https://github.com/rust-lang/rust-clippy/pull/11031)
* [`redundant_guards`]
[#10955](https://github.com/rust-lang/rust-clippy/pull/10955)
* [`redundant_locals`]
[#10885](https://github.com/rust-lang/rust-clippy/pull/10885)
* [`absolute_paths`]
[#11003](https://github.com/rust-lang/rust-clippy/pull/11003)
* [`error_impl_error`]
[#11107](https://github.com/rust-lang/rust-clippy/pull/11107)
* [`iter_skip_zero`]
[#11046](https://github.com/rust-lang/rust-clippy/pull/11046)
* [`string_lit_chars_any`]
[#11052](https://github.com/rust-lang/rust-clippy/pull/11052)
* [`four_forward_slashes`]
[#11140](https://github.com/rust-lang/rust-clippy/pull/11140)
* [`format_collect`]
[#11116](https://github.com/rust-lang/rust-clippy/pull/11116)
* [`needless_pass_by_ref_mut`]
[#10900](https://github.com/rust-lang/rust-clippy/pull/10900)
* [`manual_is_infinite`]
[#11049](https://github.com/rust-lang/rust-clippy/pull/11049)
* [`manual_is_finite`]
[#11049](https://github.com/rust-lang/rust-clippy/pull/11049)
* [`incorrect_partial_ord_impl_on_ord_type`]
[#10788](https://github.com/rust-lang/rust-clippy/pull/10788)
* [`read_line_without_trim`]
[#10970](https://github.com/rust-lang/rust-clippy/pull/10970)
* [`type_id_on_box`]
[#10987](https://github.com/rust-lang/rust-clippy/pull/10987)

### Moves and Deprecations

* Renamed `unwrap_or_else_default` to [`unwrap_or_default`]
[#10120](https://github.com/rust-lang/rust-clippy/pull/10120)
* Moved [`tuple_array_conversions`] to `pedantic` (Now allow-by-default)
[#11146](https://github.com/rust-lang/rust-clippy/pull/11146)
* Moved [`arc_with_non_send_sync`] to `suspicious` (Now warn-by-default)
[#11104](https://github.com/rust-lang/rust-clippy/pull/11104)
* Moved [`needless_raw_string_hashes`] to `pedantic` (Now allow-by-default)
[#11415](https://github.com/rust-lang/rust-clippy/pull/11415)

### Enhancements

* [`unwrap_used`]: No longer lints on the never-type or never-like enums
[#11252](https://github.com/rust-lang/rust-clippy/pull/11252)
* [`expect_used`]: No longer lints on the never-type or never-like enums
[#11252](https://github.com/rust-lang/rust-clippy/pull/11252)

### False Positive Fixes

* [`panic_in_result_fn`]: No longer triggers on `todo!`, `unimplemented!`, `unreachable!`
[#11123](https://github.com/rust-lang/rust-clippy/pull/11123)

### Suggestion Fixes/Improvements

* [`semicolon_if_nothing_returned`]: The suggestion is now machine-applicable with rustfix
[#11083](https://github.com/rust-lang/rust-clippy/pull/11083)

### ICE Fixes

* [`filter_map_bool_then`]: No longer crashes on late-bound regions
[#11318](https://github.com/rust-lang/rust-clippy/pull/11318)
* [`unwrap_or_default`]: No longer crashes on alias types for local items
[#11258](https://github.com/rust-lang/rust-clippy/pull/11258)
* [`unnecessary_literal_unwrap`]: No longer crashes on `None.unwrap_or_default()`
[#11106](https://github.com/rust-lang/rust-clippy/pull/11106)
* Fixed MIR-related ICE
[#11130](https://github.com/rust-lang/rust-clippy/pull/11130)
* [`missing_fields_in_debug`]: No longer crashes on non-ADT self types
[#11069](https://github.com/rust-lang/rust-clippy/pull/11069)

## Rust 1.72

Current stable, released 2023-08-24
Released 2023-08-24

[View all 131 merged pull requests](https://github.com/rust-lang/rust-clippy/pulls?q=merged%3A2023-05-22T14%3A53%3A59Z..2023-07-01T22%3A57%3A20Z+base%3Amaster)

Expand Down Expand Up @@ -5011,6 +5101,7 @@ Released 2018-09-13
[`integer_division`]: https://rust-lang.github.io/rust-clippy/master/index.html#integer_division
[`into_iter_on_array`]: https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_array
[`into_iter_on_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_ref
[`into_iter_without_iter`]: https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_without_iter
[`invalid_atomic_ordering`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_atomic_ordering
[`invalid_null_ptr_usage`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_null_ptr_usage
[`invalid_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_ref
Expand All @@ -5036,6 +5127,7 @@ Released 2018-09-13
[`iter_skip_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_skip_next
[`iter_skip_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_skip_zero
[`iter_with_drain`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_with_drain
[`iter_without_into_iter`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_without_into_iter
[`iterator_step_by_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#iterator_step_by_zero
[`just_underscores_and_digits`]: https://rust-lang.github.io/rust-clippy/master/index.html#just_underscores_and_digits
[`large_const_arrays`]: https://rust-lang.github.io/rust-clippy/master/index.html#large_const_arrays
Expand Down Expand Up @@ -5072,6 +5164,7 @@ Released 2018-09-13
[`manual_find`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_find
[`manual_find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_find_map
[`manual_flatten`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_flatten
[`manual_hash_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_hash_one
[`manual_instant_elapsed`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_instant_elapsed
[`manual_is_ascii_check`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_ascii_check
[`manual_is_finite`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_finite
Expand Down
4 changes: 3 additions & 1 deletion src/tools/clippy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clippy"
version = "0.1.74"
version = "0.1.75"
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
repository = "https://github.com/rust-lang/rust-clippy"
readme = "README.md"
Expand All @@ -25,6 +25,8 @@ clippy_lints = { path = "clippy_lints" }
rustc_tools_util = "0.3.0"
tempfile = { version = "3.2", optional = true }
termize = "0.1"
color-print = "0.3.4" # Sync version with Cargo
anstream = "0.5.0"

[dev-dependencies]
ui_test = "0.20"
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/book/src/development/adding_lints.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ impl EarlyLintPass for FooFunctions {}
[declare_clippy_lint]: https://github.com/rust-lang/rust-clippy/blob/557f6848bd5b7183f55c1e1522a326e9e1df6030/clippy_lints/src/lib.rs#L60
[example_lint_page]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints
[category_level_mapping]: https://github.com/rust-lang/rust-clippy/blob/557f6848bd5b7183f55c1e1522a326e9e1df6030/clippy_lints/src/lib.rs#L110
[category_level_mapping]: ../index.html

## Lint registration

Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/book/src/lint_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ The minimum rust version that the project supports
* [`type_repetition_in_bounds`](https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds)
* [`tuple_array_conversions`](https://rust-lang.github.io/rust-clippy/master/index.html#tuple_array_conversions)
* [`manual_try_fold`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_try_fold)
* [`manual_hash_one`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_hash_one)


## `cognitive-complexity-threshold`
Expand Down
63 changes: 51 additions & 12 deletions src/tools/clippy/clippy_dev/src/new_lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn create(
};

create_lint(&lint, msrv).context("Unable to create lint implementation")?;
create_test(&lint).context("Unable to create a test for the new lint")?;
create_test(&lint, msrv).context("Unable to create a test for the new lint")?;

if lint.ty.is_none() {
add_lint(&lint, msrv).context("Unable to add lint to clippy_lints/src/lib.rs")?;
Expand Down Expand Up @@ -88,15 +88,21 @@ fn create_lint(lint: &LintData<'_>, enable_msrv: bool) -> io::Result<()> {
}
}

fn create_test(lint: &LintData<'_>) -> io::Result<()> {
fn create_project_layout<P: Into<PathBuf>>(lint_name: &str, location: P, case: &str, hint: &str) -> io::Result<()> {
fn create_test(lint: &LintData<'_>, msrv: bool) -> io::Result<()> {
fn create_project_layout<P: Into<PathBuf>>(
lint_name: &str,
location: P,
case: &str,
hint: &str,
msrv: bool,
) -> io::Result<()> {
let mut path = location.into().join(case);
fs::create_dir(&path)?;
write_file(path.join("Cargo.toml"), get_manifest_contents(lint_name, hint))?;

path.push("src");
fs::create_dir(&path)?;
write_file(path.join("main.rs"), get_test_file_contents(lint_name))?;
write_file(path.join("main.rs"), get_test_file_contents(lint_name, msrv))?;

Ok(())
}
Expand All @@ -106,13 +112,25 @@ fn create_test(lint: &LintData<'_>) -> io::Result<()> {
let test_dir = lint.project_root.join(&relative_test_dir);
fs::create_dir(&test_dir)?;

create_project_layout(lint.name, &test_dir, "fail", "Content that triggers the lint goes here")?;
create_project_layout(lint.name, &test_dir, "pass", "This file should not trigger the lint")?;
create_project_layout(
lint.name,
&test_dir,
"fail",
"Content that triggers the lint goes here",
msrv,
)?;
create_project_layout(
lint.name,
&test_dir,
"pass",
"This file should not trigger the lint",
false,
)?;

println!("Generated test directories: `{relative_test_dir}/pass`, `{relative_test_dir}/fail`");
} else {
let test_path = format!("tests/ui/{}.rs", lint.name);
let test_contents = get_test_file_contents(lint.name);
let test_contents = get_test_file_contents(lint.name, msrv);
write_file(lint.project_root.join(&test_path), test_contents)?;

println!("Generated test file: `{test_path}`");
Expand Down Expand Up @@ -194,16 +212,38 @@ pub(crate) fn get_stabilization_version() -> String {
parse_manifest(&contents).expect("Unable to find package version in `Cargo.toml`")
}

fn get_test_file_contents(lint_name: &str) -> String {
formatdoc!(
fn get_test_file_contents(lint_name: &str, msrv: bool) -> String {
let mut test = formatdoc!(
r#"
#![warn(clippy::{lint_name})]

fn main() {{
// test code goes here
}}
"#
)
);

if msrv {
let _ = writedoc!(
test,
r#"

// TODO: set xx to the version one below the MSRV used by the lint, and yy to
// the version used by the lint
#[clippy::msrv = "1.xx"]
fn msrv_1_xx() {{
// a simple example that would trigger the lint if the MSRV were met
}}

#[clippy::msrv = "1.yy"]
fn msrv_1_yy() {{
// the same example as above
}}
"#
);
}

test
}

fn get_manifest_contents(lint_name: &str, hint: &str) -> String {
Expand Down Expand Up @@ -258,7 +298,7 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
)
});

let _: fmt::Result = write!(result, "{}", get_lint_declaration(&name_upper, category));
let _: fmt::Result = writeln!(result, "{}", get_lint_declaration(&name_upper, category));

result.push_str(&if enable_msrv {
formatdoc!(
Expand All @@ -281,7 +321,6 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
}}

// TODO: Add MSRV level to `clippy_utils/src/msrvs.rs` if needed.
// TODO: Add MSRV test to `tests/ui/min_rust_version_attr.rs`.
// TODO: Update msrv config comment in `clippy_lints/src/utils/conf.rs`
"#
)
Expand Down
5 changes: 4 additions & 1 deletion src/tools/clippy/clippy_lints/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clippy_lints"
version = "0.1.74"
version = "0.1.75"
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
repository = "https://github.com/rust-lang/rust-clippy"
readme = "README.md"
Expand Down Expand Up @@ -28,6 +28,9 @@ semver = "1.0"
rustc-semver = "1.1"
url = "2.2"

[dev-dependencies]
walkdir = "2.3"

[features]
deny-warnings = ["clippy_utils/deny-warnings"]
# build clippy with internal lints enabled, off by default
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/allow_attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use rustc_middle::lint::in_external_macro;
use rustc_session::{declare_lint_pass, declare_tool_lint};

declare_clippy_lint! {
/// ### What it does
/// Checks for usage of the `#[allow]` attribute and suggests replacing it with
/// the `#[expect]` (See [RFC 2383](https://rust-lang.github.io/rfcs/2383-lint-reasons.html))
///
Expand All @@ -19,7 +20,6 @@ declare_clippy_lint! {
/// (`#![allow]`) are usually used to enable or disable lints on a global scale.
///
/// ### Why is this bad?
///
/// `#[expect]` attributes suppress the lint emission, but emit a warning, if
/// the expectation is unfulfilled. This can be useful to be notified when the
/// lint is no longer triggered.
Expand Down
Loading
Loading