Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
168 commits
Select commit Hold shift + click to select a range
c1de8ed
`incompatible_msrv`: Don't check the const version for functions refe…
Jarcho Sep 30, 2025
13ee69d
Update bundled musl to 1.2.5
est31 May 29, 2024
a014a9b
update all other references to musl 1.2.3 to 1.2.5
Gankra Jun 18, 2025
52513ab
bump powerpc64le-unknown-linux-musl's musl to 1.2.5
Gankra Oct 2, 2025
d860954
Remove boxes from ast Pat lists
camsteffen Sep 4, 2025
303a828
pin all musl deconfigs to 1.2.5
Gankra Oct 7, 2025
22e6656
remove references to upstreamed patches
Gankra Oct 7, 2025
b64cdd0
bump musl-cross-make commit to get fixes
Gankra Oct 7, 2025
010b690
fmt
Gankra Oct 7, 2025
813eb08
`clippy_dev`: Move parsing code to it's own module.
Jarcho May 31, 2025
4f403f3
`clippy_dev`: Validate lint name format during argument parsing.
Jarcho Oct 10, 2025
88c0674
`clippy_dev`: Rename `RustSearcher` to `Cursor` and move it to its ow…
Jarcho Oct 10, 2025
5e36990
`clippy_dev`: Use the new ranges.
Jarcho Oct 10, 2025
422d459
`clippy_dev`: Capture token patterns by position and length.
Jarcho Oct 10, 2025
1b31b09
`clippy_dev`: Add specialized helpers for finding identifiers to the …
Jarcho Oct 11, 2025
3e1f862
clean-up tests
ada4a Oct 12, 2025
2fe9d4b
option_option: split part of diagnostic message into help message
ada4a Oct 12, 2025
5f0f7d8
return spans out of is_doc_comment to reduce reliance on .span() on a…
jdonszelmann Oct 14, 2025
1e1c1f3
Add multiple-inherent-impl tests
nickdrozd Oct 14, 2025
14b446c
Rollup merge of #147676 - jdonszelmann:span-is-doc-comment, r=Guillau…
matthiaskrgr Oct 15, 2025
2c8a9e2
Auto merge of #146221 - camsteffen:ast-boxes, r=cjgillot
bors Oct 16, 2025
d449806
`manual_unwrap_or(_default)`: don't lint if not safe to move scrutinee
zihan0822 Oct 4, 2025
8f61305
Merge commit 'd9fb15c4b1ebe9e7dc419e07f53af681d7860cbe' into clippy-s…
flip1995 Oct 16, 2025
6a0aa12
Fix clippy for impl_trait_header changes
camsteffen Oct 7, 2025
269679e
Update link to the Code of Conduct
alex-semenyuk Oct 17, 2025
1ecb18a
Update link to the Code of Conduct (#15903)
Alexendoo Oct 17, 2025
4463ba7
clean-up tests
ada4a Oct 12, 2025
b0ecbdf
fix `option_map_unit_fn_unfixable.rs`
ada4a Oct 12, 2025
98db098
improve the suggestion
ada4a Oct 12, 2025
c6426f5
Revert "fix(elidable_lifetime_names): avoid overlapping spans in sugg…
ada4a Oct 19, 2025
9ee9fd0
refactor(manual_div_ceil): move to under `operators/`
ada4a Oct 19, 2025
70de06f
clean-up a bit
ada4a Oct 19, 2025
c8c23bc
fix(empty_enum): don't lint if all variants happen to be `cfg`-d out
ada4a Oct 19, 2025
1ac3cc1
fix(empty_enum): don't lint if all variants happen to be `cfg`-d out …
samueltardieu Oct 20, 2025
95dd88d
refactor(manual_div_ceil_: move to under `operators/` (#15909)
samueltardieu Oct 20, 2025
5578908
chore(empty_enum): rename to `empty_enums`
ada4a Oct 19, 2025
4e3fa96
refactor(option_as_ref_cloned): move the `method_call` call out of th…
ada4a Oct 20, 2025
0702934
`manual_let_else` fix when expression finishes with '}'
teofr Oct 20, 2025
973e596
`option_option`: split part of diagnostic message into help message (…
Alexendoo Oct 20, 2025
b5c3ed0
refactor: Move to anstream + anstyle for styling
Muscraft Jun 4, 2025
960c01f
Add not-null pointer patterns to pattern types
oli-obk Jan 24, 2025
d9ecbb7
clean-up
ada4a Oct 20, 2025
c5215b6
clean-up a bit
ada4a Oct 21, 2025
a8fa9e1
clean-up
ada4a Oct 21, 2025
91dbaae
improve diagnostics
ada4a Oct 21, 2025
cb33ccd
improve diagnostics
ada4a Oct 21, 2025
97d6049
Mark range expr with desugaring
camsteffen Sep 10, 2025
a6e5159
fix: parenthesise the receiver if needed
ada4a Oct 21, 2025
37ebd4c
move the lint file to under `methods/`
ada4a Oct 21, 2025
81d2300
move to `methods/`, for real this time
ada4a Oct 21, 2025
039b40f
`match_as_ref`: improve diagnostics (#15928)
samueltardieu Oct 21, 2025
fb82de5
`manual_option_as_slice: improve diagnostics (#15926)
samueltardieu Oct 21, 2025
c6c71af
refactor(option_as_ref_cloned): move the `method_call` call out of th…
samueltardieu Oct 21, 2025
17f1942
Adapt the logic from `extra_unused_type_parameters`
ada4a Oct 19, 2025
bab7519
Update mod.rs
Oct 22, 2025
fd20839
Make docs more clear (#15933)
samueltardieu Oct 22, 2025
5ff804e
misc: move infallible stuff out of the way
ada4a Oct 22, 2025
2bb3d0c
refactor(elidable_lifetimes): harmonize suggestion-building logic wit…
samueltardieu Oct 22, 2025
22bdd9f
fix(match_as_ref): suggest `as_ref` when the reference needs to be cast
ada4a Oct 21, 2025
0c592df
fix(match_as_ref): suggest `as_ref` when the reference needs to be ca…
samueltardieu Oct 22, 2025
2c1ceea
Auto merge of #147207 - Muscraft:anstyle-anstream, r=davidtwco
bors Oct 22, 2025
00f68d5
`clippy_dev`: parsing revamp 1/N (#15866)
samueltardieu Oct 22, 2025
de63d25
fix: Don't add diff symbol to unchanged lines
Muscraft Oct 22, 2025
fcfab5f
`clippy_dev`: Move all parsing within a parse context.
Jarcho Oct 10, 2025
7579e71
`clippy_dev`: Inline and simplify `read_src_with_module`.
Jarcho Oct 11, 2025
bae625f
`clippy_dev`: Allocate onto an arena when parsing.
Jarcho Oct 11, 2025
6026cc9
Replace NullOp::SizeOf and NullOp::AlignOf by lang items.
cjgillot Oct 16, 2025
26b12a9
Retire ast::TyAliasWhereClauses.
cjgillot Oct 15, 2025
cd5b0b6
Auto merge of #147793 - cjgillot:no-null-op, r=scottmcm,oli-obk
bors Oct 23, 2025
ab15129
Rollup merge of #147713 - cjgillot:where-cfg, r=fmease
jhpratt Oct 23, 2025
8d15b5f
Auto merge of #148014 - jhpratt:rollup-aglren3, r=jhpratt
bors Oct 23, 2025
82d729c
`clippy_dev`: Parsing revamp part 2/N (#15921)
samueltardieu Oct 23, 2025
09c3237
chore(empty_enum): rename to `empty_enums` (#15912)
dswij Oct 23, 2025
9fd359b
clean-up
ada4a Oct 21, 2025
9145cee
make the spans more precise
ada4a Oct 21, 2025
c238924
Revert "Auto merge of #146121 - Muscraft:filter-suggestion-parts, r=p…
lqd Oct 23, 2025
0cc1594
Fix trait method checking in book
samueltardieu Oct 23, 2025
9eba2cc
fix: `len_zero` FP on unstable methods
profetia Oct 16, 2025
8ff0cf8
Fix `len_zero` FP on unstable methods (#15894)
samueltardieu Oct 23, 2025
21d3b9d
split test files for `use_debug` and `print_stdout`
ada4a Oct 24, 2025
f975caa
Fix trait method checking in book (#15941)
Jarcho Oct 24, 2025
3dcf399
fix(`manual_let_else`): expressions ending with `'}'` (#15919)
Jarcho Oct 24, 2025
d1b51ea
`{option,result}_map_unit_fn`: fix and clean-up tests, make suggestio…
Jarcho Oct 24, 2025
622a77d
feat(search_is_some): Fix when the closure spans multiple lines
Oct 16, 2025
aae10d7
refactor(double_comparison): clean-up, simplify lint logic
ada4a Oct 26, 2025
ce2ef31
fix(needless_if): don't expand macro invocations in the suggestion
ada4a Oct 26, 2025
0ba9ba7
Prepare for mdbook 0.5
ehuss Oct 26, 2025
25cbcb4
refactor(lines_filter_map_ok): move to under `methods/` (#15925)
Jarcho Oct 26, 2025
05aaed9
Auto merge of #146069 - camsteffen:range-desugar-span, r=SparrowLii
bors Oct 27, 2025
12b011b
Lint precedence possible ambiguity between closure and method call
samueltardieu Mar 16, 2025
da89652
refactor(double_comparison): clean-up, simplify lint logic (#15955)
samueltardieu Oct 27, 2025
c5714b0
Prepare for mdbook 0.5 (#15965)
samueltardieu Oct 27, 2025
a0a347e
fix(needless_if): don't expand macro invocations in the suggestion (#…
samueltardieu Oct 27, 2025
640e118
chore(needless_if): rename to `needless_ifs`
ada4a Oct 26, 2025
d349b20
fix(use_debug): don't get confused by nested `Debug` impls
ada4a Oct 24, 2025
b0d93f1
chore(needless_if): rename to `needless_ifs` (#15961)
Alexendoo Oct 27, 2025
0029a91
Lint precedence possible ambiguity between closure and method call (#…
Alexendoo Oct 27, 2025
a5b3c44
Consider labels of inline asm as conditionally executed
samueltardieu Sep 14, 2025
ca168c0
`unnecessary_{find,filter}_map`: make diagnostic spans more precise (…
dswij Oct 27, 2025
0226fa9
Consider labels of inline asm as conditionally executed (#15676)
Alexendoo Oct 27, 2025
0ff3a38
Improve doc comment code language tag parsing, don't use a full parser
Alexendoo Oct 27, 2025
bc5bd29
Remove QPath::LangItem from for loops
camsteffen Sep 1, 2025
ae9d202
Remove QPath::LangItem from ranges
camsteffen Aug 17, 2025
930dfc8
Remove QPath::LangItem from async
camsteffen Aug 17, 2025
e2b3508
Remove QPath::LangItem from try
camsteffen Sep 1, 2025
a2d8955
Remove QPath::LangItem
camsteffen Sep 1, 2025
f144c6c
feat(search_is_some): Fix when the closure spans multiple lines (#15902)
Jarcho Oct 28, 2025
02e4516
fix(double_parens): don't lint in proc-macros
ada4a Oct 23, 2025
78db66e
Remove AssignDesugar span
camsteffen Oct 28, 2025
97e681f
Changelog for Clippy 1.91
alex-semenyuk Oct 25, 2025
e71b46f
refactor(invalid_upcast_comparisons): move to under `operators`
ada4a Oct 26, 2025
d74200a
refactor(invalid_upcast_comparisons): move to under `operators`, simp…
samueltardieu Oct 28, 2025
7012a5d
`incompatible_msrv`: Don't check the const MSRV for uncalled function…
samueltardieu Oct 29, 2025
90b34cb
put the operators in backticks in the diagnostics
ada4a Oct 25, 2025
967d2b1
chore(integer_division_remainder_used): move to under `operators`
ada4a Oct 25, 2025
35e55a6
`manual_unwrap_or(_default)`: don't lint if not safe to move scrutine…
flip1995 Oct 29, 2025
c95db07
test(while_immutable_condition): call the test file the same as the lint
ada4a Oct 29, 2025
7c86faa
test(while_immutable_condition): call the test file the same as the l…
llogiq Oct 29, 2025
5a90737
Add multiple-inherent-impl tests (#15886)
llogiq Oct 29, 2025
d05f74e
refactor(integer_division_remainder_used): move to under `operators` …
samueltardieu Oct 29, 2025
26f35ae
Implement pattern matching for `&pin mut|const T`
frank-king Apr 13, 2025
9fc1d8a
require `T: !Unpin` for `&pin mut T` to be projected to `&pin mut T.U…
frank-king Jul 19, 2025
7070709
Remove `!Unpin` related bounds
frank-king Aug 3, 2025
cb369ab
Fix `pin_ergonomics` tests
frank-king Aug 3, 2025
b36f15e
Add `#[pin_project]` attribute for structurally pinning
frank-king Sep 27, 2025
ace8345
Rename `#[pin_project]` to `#[pin_v2]` to avoid naming conflicts
frank-king Oct 24, 2025
52fa003
Auto merge of #148193 - camsteffen:remove-qpath-langitem, r=cjgillot
bors Oct 30, 2025
7319811
[rustdoc search] Include extern crates when filtering on `import`
GuillaumeGomez Oct 30, 2025
5e7ce90
Improve doc comment code language tag parsing, don't use a full parse…
dswij Oct 30, 2025
e614ed4
Restrict `#[pin_v2]` test on `global_asm!` to stablized archs only
frank-king Oct 31, 2025
d8ace32
Remove the `#[pin_v2]` test since it produces different errors on dif…
frank-king Oct 31, 2025
b69d2ff
Changelog for Clippy 1.91 🎃 (#15971)
Jarcho Oct 31, 2025
bcc40ce
fix(double_parens): don't lint in proc-macros (#15939)
Jarcho Oct 31, 2025
e415911
fix(use_debug): don't get confused by nested `Debug` impls (#15946)
Jarcho Oct 31, 2025
88554d6
Remove/fix setTimeout logic in lints page
Alexendoo Oct 29, 2025
23edbb6
Don't require dlltool with the dummy backend on MinGW
bjorn3 Oct 31, 2025
04a10f7
Simplify code to generate line numbers in highlight
GuillaumeGomez Oct 27, 2025
5fabd2d
Improve code
GuillaumeGomez Oct 31, 2025
0b784f8
Remove/fix setTimeout logic in lints page (#15983)
Jarcho Oct 31, 2025
efb9a41
cleanup: upstream dropped amx-transpose functionality
durin42 Oct 31, 2025
f64e401
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Oct 31, 2025
2b9c8f1
Bump nightly version -> 2025-10-31
flip1995 Oct 31, 2025
a531040
Bump Clippy version -> 0.1.93
flip1995 Oct 31, 2025
c936595
Rustup (#16000)
flip1995 Oct 31, 2025
534b81c
Merge commit 'c936595d17413c1f08e162e117e504fb4ed126e4' into clippy-s…
flip1995 Oct 31, 2025
be5093e
Update Cargo.lock
flip1995 Oct 31, 2025
af5b798
Add Ord::clamp_min and clamp_max
Kyuuhachi Oct 16, 2025
c169ea0
Unpin `libc` in `compiler` and `rustbook`
clubby789 Oct 29, 2025
7069400
revert combined nonpoison/poison tests for condvar
connortsui20 Oct 31, 2025
3d5a408
update `nonpoison::Condvar` to take guards by reference
connortsui20 Oct 31, 2025
c1153b0
move condvar test from mutex to condvar test file
connortsui20 Oct 31, 2025
2e01acc
Add tests for some cases mentioned in #135589
estebank Jan 16, 2025
8ba2950
Detect case of missing lifetime in assoc type
estebank Jan 16, 2025
1e9e1f2
On unconstrained lifetime on `impl` block, suggest using it if there'…
estebank Jan 16, 2025
75bb675
Do not suggest introducing lifetime in impl assoc type
estebank Jan 16, 2025
8d51667
fix typo
estebank Oct 31, 2025
2a1595e
Add regression test for including extern crates in import filtering
GuillaumeGomez Oct 30, 2025
56247f1
Rollup merge of #135602 - estebank:issue-135589, r=Nadrieril
matthiaskrgr Nov 1, 2025
f38192d
Rollup merge of #139751 - frank-king:feature/pin-project, r=Nadrieril…
matthiaskrgr Nov 1, 2025
331f53d
Rollup merge of #142682 - Gankra:update_musl_1.2.5, r=wesleywiser
matthiaskrgr Nov 1, 2025
5effb6e
Rollup merge of #147786 - Kyuuhachi:clamp-min-max, r=joboet
matthiaskrgr Nov 1, 2025
3e83013
Rollup merge of #148171 - GuillaumeGomez:line-number-highlight, r=yot…
matthiaskrgr Nov 1, 2025
9d70884
Rollup merge of #148263 - clubby789:bump-libc, r=ehuss
matthiaskrgr Nov 1, 2025
e6edc6d
Rollup merge of #148301 - GuillaumeGomez:import-filter, r=notriddle
matthiaskrgr Nov 1, 2025
9cbc1b7
Rollup merge of #148330 - bjorn3:dummy_backend_no_dlltool, r=mati865
matthiaskrgr Nov 1, 2025
bc77e59
Rollup merge of #148338 - durin42:llvm-22-amx-transpose, r=workingjub…
matthiaskrgr Nov 1, 2025
894c723
Rollup merge of #148340 - flip1995:clippy-subtree-update, r=Manishearth
matthiaskrgr Nov 1, 2025
c972d22
Rollup merge of #148343 - connortsui20:guard-ref-condvar, r=Amanieu
matthiaskrgr Nov 1, 2025
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
25 changes: 16 additions & 9 deletions clippy_lints/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_ast::{
FormatPlaceholder, FormatTrait,
};
use rustc_errors::Applicability;
use rustc_hir::{Expr, Impl, Item, ItemKind};
use rustc_hir::{Expr, Impl, Item, ItemKind, OwnerId};
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_session::impl_lint_pass;
use rustc_span::{BytePos, Span};
Expand Down Expand Up @@ -240,18 +240,23 @@ declare_clippy_lint! {

pub struct Write {
format_args: FormatArgsStorage,
in_debug_impl: bool,
// The outermost `impl Debug` we're currently in. While we're in one, `USE_DEBUG` is deactivated
outermost_debug_impl: Option<OwnerId>,
allow_print_in_tests: bool,
}

impl Write {
pub fn new(conf: &'static Conf, format_args: FormatArgsStorage) -> Self {
Self {
format_args,
in_debug_impl: false,
outermost_debug_impl: None,
allow_print_in_tests: conf.allow_print_in_tests,
}
}

fn in_debug_impl(&self) -> bool {
self.outermost_debug_impl.is_some()
}
}

impl_lint_pass!(Write => [
Expand All @@ -268,14 +273,16 @@ impl_lint_pass!(Write => [

impl<'tcx> LateLintPass<'tcx> for Write {
fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
if is_debug_impl(cx, item) {
self.in_debug_impl = true;
// Only check for `impl Debug`s if we're not already in one
if self.outermost_debug_impl.is_none() && is_debug_impl(cx, item) {
self.outermost_debug_impl = Some(item.owner_id);
}
}

fn check_item_post(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
if is_debug_impl(cx, item) {
self.in_debug_impl = false;
fn check_item_post(&mut self, _cx: &LateContext<'_>, item: &Item<'_>) {
// Only clear `self.outermost_debug_impl` if we're escaping the _outermost_ debug impl
if self.outermost_debug_impl == Some(item.owner_id) {
self.outermost_debug_impl = None;
}
}

Expand Down Expand Up @@ -329,7 +336,7 @@ impl<'tcx> LateLintPass<'tcx> for Write {

check_literal(cx, format_args, name);

if !self.in_debug_impl {
if !self.in_debug_impl() {
for piece in &format_args.template {
if let &FormatArgsPiece::Placeholder(FormatPlaceholder {
span: Some(span),
Expand Down
44 changes: 0 additions & 44 deletions tests/ui/print.rs

This file was deleted.

56 changes: 0 additions & 56 deletions tests/ui/print.stderr

This file was deleted.

23 changes: 23 additions & 0 deletions tests/ui/print_stdout.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#![expect(clippy::print_literal)]
#![warn(clippy::print_stdout)]

fn main() {
println!("Hello");
//~^ print_stdout

print!("Hello");
//~^ print_stdout

print!("Hello {}", "World");
//~^ print_stdout

print!("Hello {:?}", "World");
//~^ print_stdout

print!("Hello {:#?}", "#orld");
//~^ print_stdout

assert_eq!(42, 1337);

vec![1, 2];
}
35 changes: 35 additions & 0 deletions tests/ui/print_stdout.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
error: use of `println!`
--> tests/ui/print_stdout.rs:5:5
|
LL | println!("Hello");
| ^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::print-stdout` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::print_stdout)]`

error: use of `print!`
--> tests/ui/print_stdout.rs:8:5
|
LL | print!("Hello");
| ^^^^^^^^^^^^^^^

error: use of `print!`
--> tests/ui/print_stdout.rs:11:5
|
LL | print!("Hello {}", "World");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: use of `print!`
--> tests/ui/print_stdout.rs:14:5
|
LL | print!("Hello {:?}", "World");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: use of `print!`
--> tests/ui/print_stdout.rs:17:5
|
LL | print!("Hello {:#?}", "#orld");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 5 previous errors

50 changes: 50 additions & 0 deletions tests/ui/use_debug.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#![warn(clippy::use_debug)]

use std::fmt::{Debug, Display, Formatter, Result};

struct Foo;

impl Display for Foo {
fn fmt(&self, f: &mut Formatter) -> Result {
write!(f, "{:?}", 43.1415)
//~^ use_debug
}
}

impl Debug for Foo {
fn fmt(&self, f: &mut Formatter) -> Result {
// ok, we can use `Debug` formatting in `Debug` implementations
write!(f, "{:?}", 42.718)
}
}

fn main() {
print!("Hello {:?}", "World");
//~^ use_debug

print!("Hello {:#?}", "#orld");
//~^ use_debug

assert_eq!(42, 1337);

vec![1, 2];
}

// don't get confused by nested impls
fn issue15942() {
struct Bar;
impl Debug for Bar {
fn fmt(&self, f: &mut Formatter) -> Result {
struct Baz;
impl Debug for Baz {
fn fmt(&self, f: &mut Formatter) -> Result {
// ok, we can use `Debug` formatting in `Debug` implementations
write!(f, "{:?}", 42.718)
}
}

// ok, we can use `Debug` formatting in `Debug` implementations
write!(f, "{:?}", 42.718)
}
}
}
23 changes: 23 additions & 0 deletions tests/ui/use_debug.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
error: use of `Debug`-based formatting
--> tests/ui/use_debug.rs:9:20
|
LL | write!(f, "{:?}", 43.1415)
| ^^^^
|
= note: `-D clippy::use-debug` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::use_debug)]`

error: use of `Debug`-based formatting
--> tests/ui/use_debug.rs:22:19
|
LL | print!("Hello {:?}", "World");
| ^^^^

error: use of `Debug`-based formatting
--> tests/ui/use_debug.rs:25:19
|
LL | print!("Hello {:#?}", "#orld");
| ^^^^^

error: aborting due to 3 previous errors