Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
ae310e2
fix: `redundant_pattern_matching` misses `)` in suggestion span
profetia Nov 12, 2025
c17b4a2
Clarify `strlen_on_c_strings` documentation
felix91gr Sep 19, 2025
558ff51
`transmuting_null`: Check single expression const blocks and blocks
Coca162 Dec 18, 2025
a2102a5
fix: `new_without_default` misses where clause in `new`
profetia Dec 20, 2025
4c4b2a1
fix: `str_to_string` wrongly unmangled macros
profetia Dec 20, 2025
1377de0
fix: `bool_assert_comparison` suggests wrongly for macros
profetia Dec 21, 2025
4d0dbee
Make attr path symbols rather than idents
JonathanBrouwer Dec 9, 2025
bc943aa
fix: `checked_conversions` wrongly unmangled macros
profetia Dec 23, 2025
ffbdb57
fix: `manual_ignore_case_cmp` wrongly unmangled macros
profetia Dec 23, 2025
d30647b
fix: `manual_ilog2` wrongly unmangled macros
profetia Dec 23, 2025
01b3965
fix: `needless_bool_assign` wrongly unmangled macros
profetia Dec 23, 2025
21eaa04
fix: `needless_for_each` FN when `for_each` is in the expr of a block
profetia Dec 24, 2025
6bc6509
fix: `manual_is_multiple_of` wrongly unmangled macros
profetia Dec 24, 2025
54e9e8c
Merge commit '99edcadfd5f6f6e8da34b1ba62774b53f5ca3863' into clippy-s…
flip1995 Dec 25, 2025
ec91742
Fix `multiple_inherent_impl` false negatives for generic impl blocks
borngraced Dec 22, 2025
e12e19d
fix double_parens FP on macro repetition patterns
borngraced Dec 26, 2025
86405fb
Fix ICE by rejecting const blocks in patterns during AST lowering
Shinonn23 Dec 5, 2025
871cc74
move `multiple_bound_locations` to style
cyrgani Dec 26, 2025
1a1e335
Fix `double_parens` FP on macro repetition patterns (#16301)
dswij Dec 27, 2025
981fddb
Fix typoed mention of config value using `_` of `-`
Astralchroma Dec 27, 2025
7481abc
Various fixes for handling of macros (#16296)
dswij Dec 28, 2025
22c1389
Fix typoed mention of config value using `_` of `-` (#16304)
samueltardieu Dec 28, 2025
4d166cd
Rollup merge of #149667 - Shinonn23:fix-ice-constblock-148138, r=dianne
JonathanBrouwer Dec 28, 2025
9aa3931
Clarify `strlen_on_c_strings` documentation (#15711)
Alexendoo Dec 29, 2025
67a76f9
fix: `implicit_saturating_sub` suggests wrongly on untyped int literal
profetia Dec 29, 2025
b2670b4
Fix `redundant_pattern_matching` misses `)` in suggestion span (#16084)
dswij Dec 30, 2025
ea3839a
Remove a single allocation on doc lints
blyxyas Dec 30, 2025
bddcea7
Remove a single allocation on doc lints (#16314)
llogiq Dec 30, 2025
a74de27
remove another single allocation
llogiq Dec 30, 2025
4a301a0
remove another single allocation (#16315)
blyxyas Dec 30, 2025
cc01b1c
Back into rotation
samueltardieu Dec 31, 2025
e029f60
Back into rotation (#16318)
samueltardieu Dec 31, 2025
c2f97d1
Added check for next_multiple_of in manual_div_ceil
mnemonikr Dec 11, 2025
5a97a17
`manual_div_ceil`: Added check for variant `x.next_multiple_of(y) / y…
Jarcho Jan 1, 2026
7d41f1d
Fix `implicit_saturating_sub` suggests wrongly on untyped int literal…
Jarcho Jan 1, 2026
bacb819
move `multiple_bound_locations` to style (#16302)
llogiq Jan 1, 2026
0a983a7
Fix `new_without_default` misses where clause in `new` (#16268)
llogiq Jan 1, 2026
a390881
Do not make suggestion machine-applicable if it may change semantics
samueltardieu Jan 1, 2026
f07c787
Fix `bool_assert_comparison` suggests wrongly for macros (#16280)
llogiq Jan 1, 2026
461f060
`transmuting_null`: Check single expression const blocks and blocks (…
dswij Jan 1, 2026
48657ce
Update year
alex-semenyuk Jan 1, 2026
343cde9
Update year 🎄 (#16326)
samueltardieu Jan 1, 2026
aa4ec54
fix: `cmp_owned` wrongly unmangled macros
profetia Jan 2, 2026
86eaeaa
Do not make suggestion machine-applicable if it may change semantics …
llogiq Jan 2, 2026
b527468
Fix `needless_for_each` FN when `for_each` is in the expr of a block …
dswij Jan 2, 2026
da1ffbe
fix: restrict match_bool to 2 arms
alhubanov Jan 2, 2026
4882141
Fix: `cmp_owned` wrongly unmangled macros (#16331)
dswij Jan 3, 2026
a767bf7
init impl
Kivooeo Jan 1, 2026
6c83a47
Fix `multiple_inherent_impl` false negatives for generic impl blocks …
dswij Jan 4, 2026
814ee13
Bump `askama` to 0.15
clubby789 Jan 4, 2026
af5bebe
Merge `associated_const_equality` feature gate into MGCA
AprilNEA Jan 3, 2026
8584e93
Rollup merge of #149790 - JonathanBrouwer:attr-path-perf, r=jdonszelmann
Kobzol Jan 5, 2026
85d7fb0
Remove copyright year
xtqqczze Jan 5, 2026
8df2c6d
Auto merge of #150640 - AprilNEA:mgca-merge-associated-const-equality…
bors Jan 6, 2026
f1ce0dd
Convert clippy to use the new parsed representation
JonathanBrouwer Dec 26, 2025
f39e7e0
fix: restrict match_bool to 2 arms (#16333)
llogiq Jan 6, 2026
8aed185
Bump `askama` dev-dependency to 0.15 (#16341)
Jarcho Jan 6, 2026
e3c975f
Fix `str_to_string` wrongly unmangled macros (#16276)
Jarcho Jan 6, 2026
064b95e
Allow `expect` on `impl` for `derive_ord_xor_partial_ord`
profetia Dec 27, 2025
d227bf4
Allow `expect` on `impl` for `derive_ord_xor_partial_ord` (#16303)
Jarcho Jan 6, 2026
1f207ed
fix(useless_conversion): stop adjustments when target type is reached
keirsalterego Dec 17, 2025
3e80a8c
Remove copyright year (#16345)
flip1995 Jan 7, 2026
a5a44b8
Do not warn about large stack arrays without having a valid span
samueltardieu Jan 7, 2026
98ced04
Do not warn about large stack arrays without having a valid span (#16…
dswij Jan 7, 2026
f36b249
missing_enforced_import_rename: Do not enforce for underscores
sergiogiro Jan 7, 2026
ac505cc
fix: `str_to_string` wrongly unmangled macros
profetia Dec 20, 2025
15fc6cf
fix: `string_from_utf8_as_bytes` wrongly unmangled macros
profetia Jan 2, 2026
2617622
fix: `redundant_pattern_matching` wrongly unmangled macros
profetia Jan 2, 2026
02e4f85
fix: `unnecessary_fold` wrongly unmangled macros
profetia Jan 2, 2026
0cfbe56
fix: `match_as_ref` wrongly unmangled macros
profetia Jan 2, 2026
9d08eb4
fix: `match_bool` wrongly unmangled macros
profetia Jan 2, 2026
908860e
fix: `match_ok_err` wrongly unmangled macros
profetia Jan 2, 2026
8ccfc83
fix: `for_kv_map` wrongly unmangled macros
profetia Jan 3, 2026
209e4d7
fix: `question_mark` wrongly unmangled macros
profetia Jan 3, 2026
108436c
fix: `iter_kv_map` wrongly unmangled macros
profetia Jan 4, 2026
8c129e4
fix: `mutex_atomic` wrongly unmangled macros
profetia Jan 5, 2026
ac0b17b
fix: `unnecessary_to_owned` wrongly unmangled macros
profetia Jan 7, 2026
9302f1b
More fixes for handling of macros (#16337)
Jarcho Jan 8, 2026
327c558
missing_enforced_import_rename: Do not enforce for underscores (#16352)
Jarcho Jan 8, 2026
bcf3c08
Improve `useless_conversion` `.into_iter()` suggestion for nested ref…
Jarcho Jan 8, 2026
3fac496
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Jan 8, 2026
5356be0
Bump nightly version -> 2026-01-08
flip1995 Jan 8, 2026
3b282fe
Rustup (#16361)
flip1995 Jan 8, 2026
6836569
A `return` in an iterator closure should not trigger `never_loop`
samueltardieu Jan 8, 2026
156b081
fix(single_range_in_vec_init): don't apply the suggestion automatically
ada4a Jan 8, 2026
1a5bb37
fix(single_range_in_vec_init): don't apply the suggestion automatical…
samueltardieu Jan 8, 2026
adade16
A `return` in an iterator closure should not trigger `never_loop` (#1…
Jarcho Jan 8, 2026
500e0ff
Fix `unnecessary_to_owned` wrongly unmangled macros (#16354)
llogiq Jan 8, 2026
d9c1685
Merge commit '500e0ff18726cd44b23004a02fc1b99f52c11ab1' into clippy-s…
flip1995 Jan 9, 2026
a3690a2
Make Clippy compile with `ConstArgKind::Tup()`
samueltardieu Jan 8, 2026
d283798
Update Cargo.lock
flip1995 Jan 9, 2026
330358a
Further Clippy fixes for Tup/Literal ConstArgKind
flip1995 Jan 9, 2026
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
52 changes: 5 additions & 47 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,6 @@ version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"

[[package]]
name = "askama"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f75363874b771be265f4ffe307ca705ef6f3baa19011c149da8674a87f1b75c4"
dependencies = [
"askama_derive 0.14.0",
"itoa",
"percent-encoding",
"serde",
"serde_json",
]

[[package]]
name = "askama"
version = "0.15.1"
Expand All @@ -208,30 +195,13 @@ dependencies = [
"serde_json",
]

[[package]]
name = "askama_derive"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "129397200fe83088e8a68407a8e2b1f826cf0086b21ccdb866a722c8bcd3a94f"
dependencies = [
"askama_parser 0.14.0",
"basic-toml",
"memchr",
"proc-macro2",
"quote",
"rustc-hash 2.1.1",
"serde",
"serde_derive",
"syn 2.0.110",
]

[[package]]
name = "askama_derive"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ba5e7259a1580c61571e3116ebaaa01e3c001b2132b17c4cc5c70780ca3e994"
dependencies = [
"askama_parser 0.15.1",
"askama_parser",
"basic-toml",
"memchr",
"proc-macro2",
Expand All @@ -248,19 +218,7 @@ version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "236ce20b77cb13506eaf5024899f4af6e12e8825f390bd943c4c37fd8f322e46"
dependencies = [
"askama_derive 0.15.1",
]

[[package]]
name = "askama_parser"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6ab5630b3d5eaf232620167977f95eb51f3432fc76852328774afbd242d4358"
dependencies = [
"memchr",
"serde",
"serde_derive",
"winnow 0.7.13",
"askama_derive",
]

[[package]]
Expand Down Expand Up @@ -675,7 +633,7 @@ name = "clippy"
version = "0.1.94"
dependencies = [
"anstream",
"askama 0.14.0",
"askama",
"cargo_metadata 0.18.1",
"clippy_config",
"clippy_lints",
Expand Down Expand Up @@ -1566,7 +1524,7 @@ name = "generate-copyright"
version = "0.1.0"
dependencies = [
"anyhow",
"askama 0.15.1",
"askama",
"cargo_metadata 0.21.0",
"serde",
"serde_json",
Expand Down Expand Up @@ -4913,7 +4871,7 @@ name = "rustdoc"
version = "0.0.0"
dependencies = [
"arrayvec",
"askama 0.15.1",
"askama",
"base64",
"expect-test",
"indexmap",
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/COPYRIGHT
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// REUSE-IgnoreStart

Copyright 2014-2025 The Rust Project Developers
Copyright (c) The Rust Project Contributors

Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ walkdir = "2.3"
filetime = "0.2.9"
itertools = "0.12"
pulldown-cmark = { version = "0.11", default-features = false, features = ["html"] }
askama = { version = "0.14", default-features = false, features = ["alloc", "config", "derive"] }
askama = { version = "0.15", default-features = false, features = ["alloc", "config", "derive"] }

[dev-dependencies.toml]
version = "0.9.7"
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/LICENSE-APACHE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2014-2025 The Rust Project Developers
Copyright (c) The Rust Project Contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2014-2025 The Rust Project Developers
Copyright (c) The Rust Project Contributors

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ If you want to contribute to Clippy, you can find more information in [CONTRIBUT

<!-- REUSE-IgnoreStart -->

Copyright 2014-2025 The Rust Project Developers
Copyright (c) The Rust Project Contributors

Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
[https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)> or the MIT license
Expand Down
9 changes: 2 additions & 7 deletions src/tools/clippy/clippy_lints/src/attrs/allow_attributes.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use super::ALLOW_ATTRIBUTES;
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::is_from_proc_macro;
use rustc_ast::attr::AttributeExt;
use rustc_ast::{AttrStyle, Attribute};
use rustc_errors::Applicability;
use rustc_lint::{EarlyContext, LintContext};
use rustc_ast::attr::AttributeExt;

// Separate each crate's features.
pub fn check<'cx>(cx: &EarlyContext<'cx>, attr: &'cx Attribute) {
Expand All @@ -15,12 +15,7 @@ pub fn check<'cx>(cx: &EarlyContext<'cx>, attr: &'cx Attribute) {
{
#[expect(clippy::collapsible_span_lint_calls, reason = "rust-clippy#7797")]
span_lint_and_then(cx, ALLOW_ATTRIBUTES, path_span, "#[allow] attribute found", |diag| {
diag.span_suggestion(
path_span,
"replace it with",
"expect",
Applicability::MachineApplicable,
);
diag.span_suggestion(path_span, "replace it with", "expect", Applicability::MachineApplicable);
});
}
}
6 changes: 4 additions & 2 deletions src/tools/clippy/clippy_lints/src/attrs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mod utils;
use clippy_config::Conf;
use clippy_utils::diagnostics::span_lint_and_help;
use clippy_utils::msrvs::{self, Msrv, MsrvStack};
use rustc_ast::{self as ast, AttrArgs, AttrKind, Attribute, MetaItemInner, MetaItemKind, AttrItemKind};
use rustc_ast::{self as ast, AttrArgs, AttrItemKind, AttrKind, Attribute, MetaItemInner, MetaItemKind};
use rustc_hir::{ImplItem, Item, ItemKind, TraitItem};
use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass};
use rustc_session::impl_lint_pass;
Expand Down Expand Up @@ -604,7 +604,9 @@ impl EarlyLintPass for PostExpansionEarlyAttributes {

if attr.has_name(sym::ignore)
&& match &attr.kind {
AttrKind::Normal(normal_attr) => !matches!(normal_attr.item.args, AttrItemKind::Unparsed(AttrArgs::Eq { .. })),
AttrKind::Normal(normal_attr) => {
!matches!(normal_attr.item.args, AttrItemKind::Unparsed(AttrArgs::Eq { .. }))
},
AttrKind::DocComment(..) => true,
}
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::{Attribute, SHOULD_PANIC_WITHOUT_EXPECT};
use clippy_utils::diagnostics::span_lint_and_sugg;
use rustc_ast::token::{Token, TokenKind};
use rustc_ast::tokenstream::TokenTree;
use rustc_ast::{AttrArgs, AttrKind, AttrItemKind};
use rustc_ast::{AttrArgs, AttrItemKind, AttrKind};
use rustc_errors::Applicability;
use rustc_lint::EarlyContext;
use rustc_span::sym;
Expand Down
33 changes: 18 additions & 15 deletions src/tools/clippy/clippy_lints/src/bool_assert_comparison.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::macros::{find_assert_eq_args, root_macro_call_first_node};
use clippy_utils::source::walk_span_to_context;
use clippy_utils::sugg::Sugg;
use clippy_utils::sym;
use clippy_utils::ty::{implements_trait, is_copy};
Expand Down Expand Up @@ -130,22 +131,24 @@ impl<'tcx> LateLintPass<'tcx> for BoolAssertComparison {

let mut suggestions = vec![(name_span, non_eq_mac.to_string()), (lit_span, String::new())];

if let Some(sugg) = Sugg::hir_opt(cx, non_lit_expr) {
let sugg = if bool_value ^ eq_macro {
!sugg.maybe_paren()
} else if ty::Bool == *non_lit_ty.kind() {
sugg
} else {
!!sugg.maybe_paren()
};
suggestions.push((non_lit_expr.span, sugg.to_string()));
let mut applicability = Applicability::MachineApplicable;
let sugg = Sugg::hir_with_context(cx, non_lit_expr, macro_call.span.ctxt(), "..", &mut applicability);
let sugg = if bool_value ^ eq_macro {
!sugg.maybe_paren()
} else if ty::Bool == *non_lit_ty.kind() {
sugg
} else {
!!sugg.maybe_paren()
};
let non_lit_expr_span =
walk_span_to_context(non_lit_expr.span, macro_call.span.ctxt()).unwrap_or(non_lit_expr.span);
suggestions.push((non_lit_expr_span, sugg.to_string()));

diag.multipart_suggestion(
format!("replace it with `{non_eq_mac}!(..)`"),
suggestions,
Applicability::MachineApplicable,
);
}
diag.multipart_suggestion(
format!("replace it with `{non_eq_mac}!(..)`"),
suggestions,
applicability,
);
},
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/tools/clippy/clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use rustc_lint::{LateContext, LateLintPass, Level};
use rustc_session::impl_lint_pass;
use rustc_span::def_id::LocalDefId;
use rustc_span::{Span, Symbol, SyntaxContext};
use std::fmt::Write as _;

declare_clippy_lint! {
/// ### What it does
Expand Down Expand Up @@ -356,7 +357,7 @@ impl SuggestContext<'_, '_, '_> {
if app != Applicability::MachineApplicable {
return None;
}
self.output.push_str(&(!snip).to_string());
let _cannot_fail = write!(&mut self.output, "{}", &(!snip));
}
},
True | False | Not(_) => {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/cargo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ declare_clippy_lint! {
/// Because this can be caused purely by the dependencies
/// themselves, it's not always possible to fix this issue.
/// In those cases, you can allow that specific crate using
/// the `allowed_duplicate_crates` configuration option.
/// the `allowed-duplicate-crates` configuration option.
///
/// ### Example
/// ```toml
Expand Down
13 changes: 5 additions & 8 deletions src/tools/clippy/clippy_lints/src/cfg_not_test.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use clippy_utils::diagnostics::span_lint_and_then;
use rustc_ast::attr::data_structures::CfgEntry;
use rustc_ast::{AttrItemKind, EarlyParsedAttribute};
use rustc_lint::{EarlyContext, EarlyLintPass};
use rustc_session::declare_lint_pass;
use rustc_ast::AttrItemKind;
use rustc_ast::EarlyParsedAttribute;
use rustc_span::sym;
use rustc_ast::attr::data_structures::CfgEntry;

declare_clippy_lint! {
/// ### What it does
Expand Down Expand Up @@ -40,7 +39,7 @@ impl EarlyLintPass for CfgNotTest {
unreachable!()
};

if contains_not_test(&cfg, false) {
if contains_not_test(cfg, false) {
span_lint_and_then(
cx,
CFG_NOT_TEST,
Expand All @@ -58,11 +57,9 @@ impl EarlyLintPass for CfgNotTest {

fn contains_not_test(cfg: &CfgEntry, not: bool) -> bool {
match cfg {
CfgEntry::All(subs, _) | CfgEntry::Any(subs, _) => subs.iter().any(|item| {
contains_not_test(item, not)
}),
CfgEntry::All(subs, _) | CfgEntry::Any(subs, _) => subs.iter().any(|item| contains_not_test(item, not)),
CfgEntry::Not(sub, _) => contains_not_test(sub, !not),
CfgEntry::NameValue { name: sym::test, .. } => not,
_ => false
_ => false,
}
}
5 changes: 3 additions & 2 deletions src/tools/clippy/clippy_lints/src/checked_conversions.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use clippy_config::Conf;
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::msrvs::{self, Msrv};
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::source::snippet_with_context;
use clippy_utils::{SpanlessEq, is_in_const_context, is_integer_literal, sym};
use rustc_errors::Applicability;
use rustc_hir::{BinOpKind, Expr, ExprKind, QPath, TyKind};
Expand Down Expand Up @@ -80,7 +80,8 @@ impl LateLintPass<'_> for CheckedConversions {
&& self.msrv.meets(cx, msrvs::TRY_FROM)
{
let mut applicability = Applicability::MachineApplicable;
let snippet = snippet_with_applicability(cx, cv.expr_to_cast.span, "_", &mut applicability);
let (snippet, _) =
snippet_with_context(cx, cv.expr_to_cast.span, item.span.ctxt(), "_", &mut applicability);
span_lint_and_sugg(
cx,
CHECKED_CONVERSIONS,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
use clippy_utils::diagnostics::span_lint_hir_and_then;
use clippy_utils::fulfill_or_allowed;
use rustc_hir::{self as hir, HirId};
use rustc_lint::LateContext;
use rustc_middle::ty::Ty;
use rustc_span::{Span, sym};
use rustc_span::sym;

use super::DERIVE_ORD_XOR_PARTIAL_ORD;

/// Implementation of the `DERIVE_ORD_XOR_PARTIAL_ORD` lint.
pub(super) fn check<'tcx>(
cx: &LateContext<'tcx>,
span: Span,
item: &hir::Item<'_>,
trait_ref: &hir::TraitRef<'_>,
ty: Ty<'tcx>,
adt_hir_id: HirId,
Expand All @@ -19,6 +20,8 @@ pub(super) fn check<'tcx>(
&& let Some(partial_ord_trait_def_id) = cx.tcx.lang_items().partial_ord_trait()
&& let Some(def_id) = &trait_ref.trait_def_id()
&& *def_id == ord_trait_def_id
&& let item_hir_id = cx.tcx.local_def_id_to_hir_id(item.owner_id)
&& !fulfill_or_allowed(cx, DERIVE_ORD_XOR_PARTIAL_ORD, [adt_hir_id])
{
// Look for the PartialOrd implementations for `ty`
cx.tcx.for_each_relevant_impl(partial_ord_trait_def_id, ty, |impl_id| {
Expand All @@ -39,7 +42,7 @@ pub(super) fn check<'tcx>(
"you are deriving `Ord` but have implemented `PartialOrd` explicitly"
};

span_lint_hir_and_then(cx, DERIVE_ORD_XOR_PARTIAL_ORD, adt_hir_id, span, mess, |diag| {
span_lint_hir_and_then(cx, DERIVE_ORD_XOR_PARTIAL_ORD, item_hir_id, item.span, mess, |diag| {
if let Some(local_def_id) = impl_id.as_local() {
let hir_id = cx.tcx.local_def_id_to_hir_id(local_def_id);
diag.span_note(cx.tcx.hir_span(hir_id), "`PartialOrd` implemented here");
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/derive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl<'tcx> LateLintPass<'tcx> for Derive {
let is_automatically_derived = cx.tcx.is_automatically_derived(item.owner_id.to_def_id());

derived_hash_with_manual_eq::check(cx, item.span, trait_ref, ty, adt_hir_id, is_automatically_derived);
derive_ord_xor_partial_ord::check(cx, item.span, trait_ref, ty, adt_hir_id, is_automatically_derived);
derive_ord_xor_partial_ord::check(cx, item, trait_ref, ty, adt_hir_id, is_automatically_derived);

if is_automatically_derived {
unsafe_derive_deserialize::check(cx, item, trait_ref, ty, adt_hir_id);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::source::snippet_opt;
use rustc_ast::{AttrArgs, AttrKind, AttrStyle, Attribute, AttrItemKind};
use rustc_ast::{AttrArgs, AttrItemKind, AttrKind, AttrStyle, Attribute};
use rustc_errors::Applicability;
use rustc_lint::EarlyContext;

Expand Down
10 changes: 6 additions & 4 deletions src/tools/clippy/clippy_lints/src/doc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -869,10 +869,12 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs: &[
}),
true,
);
let mut doc = fragments.iter().fold(String::new(), |mut acc, fragment| {
add_doc_fragment(&mut acc, fragment);
acc
});

let mut doc = String::with_capacity(fragments.iter().map(|frag| frag.doc.as_str().len() + 1).sum());

for fragment in &fragments {
add_doc_fragment(&mut doc, fragment);
}
doc.pop();

if doc.trim().is_empty() {
Expand Down
Loading
Loading