Skip to content

Commit fb16ce7

Browse files
authored
Rollup merge of rust-lang#154661 - CoCo-Japan-pan:impl-restriction-check, r=jhpratt,Urgau
Semantic checks of `impl` restrictions This PR implements semantic checks for `impl` restrictions proposed in the [Restrictions RFC](https://rust-lang.github.io/rfcs/3323-restrictions.html) (Tracking Issue rust-lang#105077), and linked to a [GSOC idea/proposal](https://github.com/rust-lang/google-summer-of-code/tree/142433eb3b104b2f32bae0b9dfafb78a0a2ac579?tab=readme-ov-file#implementing-impl-and-mut-restrictions). It lowers the resolved paths of `impl` restrictions from the AST to HIR and into `TraitDef`, and integrates the checks into the coherence phase by extending `check_impl`. As parsing (rust-lang#152943) and path resolution (rust-lang#153556) have already been implemented, this PR provides a working implementation of `impl` restrictions. r? @Urgau cc @jhpratt
2 parents c482441 + 232d064 commit fb16ce7

6 files changed

Lines changed: 7 additions & 7 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
@@ -306,7 +306,7 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
306306
cur_f = Some(field);
307307
}
308308
},
309-
ItemKind::Trait(_constness, is_auto, _safety, _ident, _generics, _generic_bounds, item_ref)
309+
ItemKind::Trait(_constness, is_auto, _safety, _impl_restriction, _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/item_name_repetitions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ impl LateLintPass<'_> for ItemNameRepetitions {
528528
| ItemKind::Fn { ident, .. }
529529
| ItemKind::Macro(ident, ..)
530530
| ItemKind::Static(_, ident, ..)
531-
| ItemKind::Trait(_, _, _, ident, ..)
531+
| ItemKind::Trait(_, _, _, _, ident, ..)
532532
| ItemKind::TraitAlias(_, ident, ..)
533533
| ItemKind::TyAlias(ident, ..)
534534
| ItemKind::Union(ident, ..)

clippy_lints/src/len_without_is_empty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ declare_lint_pass!(LenWithoutIsEmpty => [LEN_WITHOUT_IS_EMPTY]);
4444

4545
impl<'tcx> LateLintPass<'tcx> for LenWithoutIsEmpty {
4646
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
47-
if let ItemKind::Trait(_, _, _, ident, _, _, trait_items) = item.kind
47+
if let ItemKind::Trait(_, _, _, _, ident, _, _, trait_items) = item.kind
4848
&& !item.span.from_expansion()
4949
{
5050
check_trait_items(cx, item, ident, trait_items);

clippy_lints/src/missing_doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
159159
| ItemKind::Macro(ident, ..)
160160
| ItemKind::Static(_, ident, ..)
161161
| ItemKind::Struct(ident, ..)
162-
| ItemKind::Trait(_, _, _, ident, ..)
162+
| ItemKind::Trait(_, _, _, _, ident, ..)
163163
| ItemKind::TraitAlias(_, ident, ..)
164164
| ItemKind::TyAlias(ident, ..)
165165
| ItemKind::Union(ident, ..) => ident.span,

clippy_lints/src/trait_bounds.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds {
115115
// special handling for self trait bounds as these are not considered generics
116116
// i.e. trait Foo: Display {}
117117
if let Item {
118-
kind: ItemKind::Trait(_, _, _, _, _, bounds, ..),
118+
kind: ItemKind::Trait(_, _, _, _, _, _, bounds, ..),
119119
..
120120
} = item
121121
{
@@ -136,7 +136,7 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds {
136136
..
137137
}) = segments.first()
138138
&& let Some(Node::Item(Item {
139-
kind: ItemKind::Trait(_, _, _, _, _, self_bounds, _),
139+
kind: ItemKind::Trait(_, _, _, _, _, _, self_bounds, _),
140140
..
141141
})) = cx.tcx.hir_get_if_local(*def_id)
142142
{

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) => {

0 commit comments

Comments
 (0)