Skip to content

Commit 1293dad

Browse files
Rollup merge of #155442 - CoCo-Japan-pan:impl-restriction-reorder, r=Urgau,fmease,jhpratt
Change keyword order for `impl` restrictions Based on rust-lang/rust#155222, this PR reorders keywords in trait definitions to group restrictions with visibility. It changes the order from `pub(...) const unsafe auto impl(...) trait Foo {...}` to `pub(...) impl(...) const unsafe auto trait Foo {...}`. Tracking issue for restrictions: rust-lang/rust#105077 r? @Urgau cc @jhpratt
2 parents 22a4b16 + f1b1096 commit 1293dad

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

clippy_lints/src/arbitrary_source_item_ordering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,10 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
307307
}
308308
},
309309
ItemKind::Trait(
310+
_impl_restriction,
310311
_constness,
311312
is_auto,
312313
_safety,
313-
_impl_restriction,
314314
_ident,
315315
_generics,
316316
_generic_bounds,

clippy_lints/src/doc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ impl<'tcx> LateLintPass<'tcx> for Documentation {
769769
{
770770
missing_headers::check(cx, item.owner_id, sig, headers, Some(body), self.check_private_items);
771771
},
772-
ItemKind::Trait(_, _, unsafety, ..) => match (headers.safety, unsafety) {
772+
ItemKind::Trait(_, _, _, unsafety, ..) => match (headers.safety, unsafety) {
773773
(false, Safety::Unsafe) => span_lint(
774774
cx,
775775
MISSING_SAFETY_DOC,

clippy_utils/src/ast_utils/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,30 +448,30 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
448448
},
449449
(
450450
Trait(box ast::Trait {
451+
impl_restriction: liprt,
451452
constness: lc,
452453
is_auto: la,
453454
safety: lu,
454-
impl_restriction: liprt,
455455
ident: li,
456456
generics: lg,
457457
bounds: lb,
458458
items: lis,
459459
}),
460460
Trait(box ast::Trait {
461+
impl_restriction: riprt,
461462
constness: rc,
462463
is_auto: ra,
463464
safety: ru,
464-
impl_restriction: riprt,
465465
ident: ri,
466466
generics: rg,
467467
bounds: rb,
468468
items: ris,
469469
}),
470470
) => {
471-
matches!(lc, ast::Const::No) == matches!(rc, ast::Const::No)
471+
eq_impl_restriction(liprt, riprt)
472+
&& matches!(lc, ast::Const::No) == matches!(rc, ast::Const::No)
472473
&& la == ra
473474
&& matches!(lu, Safety::Default) == matches!(ru, Safety::Default)
474-
&& eq_impl_restriction(liprt, riprt)
475475
&& eq_id(*li, *ri)
476476
&& eq_generics(lg, rg)
477477
&& over(lb, rb, eq_generic_bound)

clippy_utils/src/check_proc_macro.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,14 @@ fn item_search_pat(item: &Item<'_>) -> (Pat, Pat) {
265265
ItemKind::Struct(_, _, VariantData::Struct { .. }) => (Pat::Str("struct"), Pat::Str("}")),
266266
ItemKind::Struct(..) => (Pat::Str("struct"), Pat::Str(";")),
267267
ItemKind::Union(..) => (Pat::Str("union"), Pat::Str("}")),
268-
ItemKind::Trait(_, _, Safety::Unsafe, ..)
268+
ItemKind::Trait(_, _, _, Safety::Unsafe, ..)
269269
| ItemKind::Impl(Impl {
270270
of_trait: Some(TraitImplHeader {
271271
safety: Safety::Unsafe, ..
272272
}),
273273
..
274274
}) => (Pat::Str("unsafe"), Pat::Str("}")),
275-
ItemKind::Trait(_, IsAuto::Yes, ..) => (Pat::Str("auto"), Pat::Str("}")),
275+
ItemKind::Trait(_, _, IsAuto::Yes, ..) => (Pat::Str("auto"), Pat::Str("}")),
276276
ItemKind::Trait(..) => (Pat::Str("trait"), Pat::Str("}")),
277277
ItemKind::Impl(_) => (Pat::Str("impl"), Pat::Str("}")),
278278
ItemKind::Mod(..) => (Pat::Str("mod"), Pat::Str("")),

0 commit comments

Comments
 (0)