Skip to content

Commit c12d6f8

Browse files
authored
Merge pull request rust-lang#4474 from rust-lang/rustup-2025-07-18
Automatic Rustup
2 parents 5887014 + 6c5fc67 commit c12d6f8

20 files changed

+41
-41
lines changed

clippy_lints/src/arbitrary_source_item_ordering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
306306
cur_f = Some(field);
307307
}
308308
},
309-
ItemKind::Trait(is_auto, _safety, _ident, _generics, _generic_bounds, item_ref)
309+
ItemKind::Trait(_constness, is_auto, _safety, _ident, _generics, _generic_bounds, item_ref)
310310
if self.enable_ordering_for_trait && *is_auto == IsAuto::No =>
311311
{
312312
let mut cur_t: Option<(TraitItemId, Ident)> = None;

clippy_lints/src/doc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ impl<'tcx> LateLintPass<'tcx> for Documentation {
740740
);
741741
}
742742
},
743-
ItemKind::Trait(_, unsafety, ..) => match (headers.safety, unsafety) {
743+
ItemKind::Trait(_, _, unsafety, ..) => match (headers.safety, unsafety) {
744744
(false, Safety::Unsafe) => span_lint(
745745
cx,
746746
MISSING_SAFETY_DOC,

clippy_lints/src/len_zero.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ declare_lint_pass!(LenZero => [LEN_ZERO, LEN_WITHOUT_IS_EMPTY, COMPARISON_TO_EMP
125125

126126
impl<'tcx> LateLintPass<'tcx> for LenZero {
127127
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
128-
if let ItemKind::Trait(_, _, ident, _, _, trait_items) = item.kind
128+
if let ItemKind::Trait(_, _, _, ident, _, _, trait_items) = item.kind
129129
&& !item.span.from_expansion()
130130
{
131131
check_trait_items(cx, item, ident, trait_items);

clippy_lints/src/methods/from_iter_instead_of_collect.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg;
44
use clippy_utils::source::snippet_with_applicability;
55
use clippy_utils::ty::implements_trait;
66
use clippy_utils::{is_path_diagnostic_item, sugg};
7+
use rustc_ast::join_path_idents;
78
use rustc_errors::Applicability;
89
use rustc_hir::def::Res;
910
use rustc_hir::{self as hir, Expr, ExprKind, GenericArg, QPath, TyKind};
@@ -47,7 +48,7 @@ fn build_full_type(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, app: &mut Applica
4748
&& let QPath::Resolved(None, ty_path) = &ty_qpath
4849
&& let Res::Def(_, ty_did) = ty_path.res
4950
{
50-
let mut ty_str = itertools::join(ty_path.segments.iter().map(|s| s.ident), "::");
51+
let mut ty_str = join_path_idents(ty_path.segments.iter().map(|seg| seg.ident));
5152
let mut first = true;
5253
let mut append = |arg: &str| {
5354
write!(&mut ty_str, "{}{arg}", [", ", "<"][usize::from(first)]).unwrap();

clippy_lints/src/missing_inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
101101
let attrs = cx.tcx.hir_attrs(it.hir_id());
102102
check_missing_inline_attrs(cx, attrs, it.span, desc);
103103
},
104-
hir::ItemKind::Trait(ref _is_auto, ref _unsafe, _ident, _generics, _bounds, trait_items) => {
104+
hir::ItemKind::Trait(ref _constness, ref _is_auto, ref _unsafe, _ident, _generics, _bounds, trait_items) => {
105105
// note: we need to check if the trait is exported so we can't use
106106
// `LateLintPass::check_trait_item` here.
107107
for &tit in trait_items {

clippy_lints/src/trait_bounds.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds {
112112
// special handling for self trait bounds as these are not considered generics
113113
// ie. trait Foo: Display {}
114114
if let Item {
115-
kind: ItemKind::Trait(_, _, _, _, bounds, ..),
115+
kind: ItemKind::Trait(_, _, _, _, _, bounds, ..),
116116
..
117117
} = item
118118
{
@@ -133,7 +133,7 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds {
133133
..
134134
}) = segments.first()
135135
&& let Some(Node::Item(Item {
136-
kind: ItemKind::Trait(_, _, _, _, self_bounds, _),
136+
kind: ItemKind::Trait(_, _, _, _, _, self_bounds, _),
137137
..
138138
})) = cx.tcx.hir_get_if_local(*def_id)
139139
{

clippy_lints/src/upper_case_acronyms.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl LateLintPass<'_> for UpperCaseAcronyms {
131131
return;
132132
}
133133
match it.kind {
134-
ItemKind::TyAlias(ident, ..) | ItemKind::Struct(ident, ..) | ItemKind::Trait(_, _, ident, ..) => {
134+
ItemKind::TyAlias(ident, ..) | ItemKind::Struct(ident, ..) | ItemKind::Trait(_, _, _, ident, ..) => {
135135
check_ident(cx, &ident, it.hir_id(), self.upper_case_acronyms_aggressive);
136136
},
137137
ItemKind::Enum(ident, _, ref enumdef) => {

clippy_utils/src/ast_utils/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
444444
},
445445
(
446446
Trait(box ast::Trait {
447+
constness: lc,
447448
is_auto: la,
448449
safety: lu,
449450
ident: li,
@@ -452,6 +453,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
452453
items: lis,
453454
}),
454455
Trait(box ast::Trait {
456+
constness: rc,
455457
is_auto: ra,
456458
safety: ru,
457459
ident: ri,
@@ -460,7 +462,8 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
460462
items: ris,
461463
}),
462464
) => {
463-
la == ra
465+
matches!(lc, ast::Const::No) == matches!(rc, ast::Const::No)
466+
&& la == ra
464467
&& matches!(lu, Safety::Default) == matches!(ru, Safety::Default)
465468
&& eq_id(*li, *ri)
466469
&& eq_generics(lg, rg)

clippy_utils/src/check_proc_macro.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,11 @@ fn item_search_pat(item: &Item<'_>) -> (Pat, Pat) {
252252
ItemKind::Struct(_, _, VariantData::Struct { .. }) => (Pat::Str("struct"), Pat::Str("}")),
253253
ItemKind::Struct(..) => (Pat::Str("struct"), Pat::Str(";")),
254254
ItemKind::Union(..) => (Pat::Str("union"), Pat::Str("}")),
255-
ItemKind::Trait(_, Safety::Unsafe, ..)
255+
ItemKind::Trait(_, _, Safety::Unsafe, ..)
256256
| ItemKind::Impl(Impl {
257257
safety: Safety::Unsafe, ..
258258
}) => (Pat::Str("unsafe"), Pat::Str("}")),
259-
ItemKind::Trait(IsAuto::Yes, ..) => (Pat::Str("auto"), Pat::Str("}")),
259+
ItemKind::Trait(_, IsAuto::Yes, ..) => (Pat::Str("auto"), Pat::Str("}")),
260260
ItemKind::Trait(..) => (Pat::Str("trait"), Pat::Str("}")),
261261
ItemKind::Impl(_) => (Pat::Str("impl"), Pat::Str("}")),
262262
_ => return (Pat::Str(""), Pat::Str("")),

clippy_utils/src/lib.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ use std::sync::{Mutex, MutexGuard, OnceLock};
8989

9090
use itertools::Itertools;
9191
use rustc_abi::Integer;
92+
use rustc_ast::join_path_syms;
9293
use rustc_ast::ast::{self, LitKind, RangeLimits};
9394
use rustc_attr_data_structures::{AttributeKind, find_attr};
9495
use rustc_data_structures::fx::FxHashMap;
@@ -3245,8 +3246,8 @@ fn maybe_get_relative_path(from: &DefPath, to: &DefPath, max_super: usize) -> St
32453246
// a::b::c ::d::sym refers to
32463247
// e::f::sym:: ::
32473248
// result should be super::super::super::super::e::f
3248-
if let DefPathData::TypeNs(s) = l {
3249-
path.push(s.to_string());
3249+
if let DefPathData::TypeNs(sym) = l {
3250+
path.push(sym);
32503251
}
32513252
if let DefPathData::TypeNs(_) = r {
32523253
go_up_by += 1;
@@ -3256,7 +3257,7 @@ fn maybe_get_relative_path(from: &DefPath, to: &DefPath, max_super: usize) -> St
32563257
// a::b::sym:: :: refers to
32573258
// c::d::e ::f::sym
32583259
// when looking at `f`
3259-
Left(DefPathData::TypeNs(sym)) => path.push(sym.to_string()),
3260+
Left(DefPathData::TypeNs(sym)) => path.push(sym),
32603261
// consider:
32613262
// a::b::c ::d::sym refers to
32623263
// e::f::sym:: ::
@@ -3268,17 +3269,17 @@ fn maybe_get_relative_path(from: &DefPath, to: &DefPath, max_super: usize) -> St
32683269

32693270
if go_up_by > max_super {
32703271
// `super` chain would be too long, just use the absolute path instead
3271-
once(String::from("crate"))
3272-
.chain(to.data.iter().filter_map(|el| {
3272+
join_path_syms(
3273+
once(kw::Crate).chain(to.data.iter().filter_map(|el| {
32733274
if let DefPathData::TypeNs(sym) = el.data {
3274-
Some(sym.to_string())
3275+
Some(sym)
32753276
} else {
32763277
None
32773278
}
32783279
}))
3279-
.join("::")
3280+
)
32803281
} else {
3281-
repeat_n(String::from("super"), go_up_by).chain(path).join("::")
3282+
join_path_syms(repeat_n(kw::Super, go_up_by).chain(path))
32823283
}
32833284
}
32843285

0 commit comments

Comments
 (0)