@@ -94,7 +94,28 @@ impl<'a> ModuleVisitor<'a> {
94
94
}
95
95
}
96
96
97
+ impl < ' a , ' ast > Visit < ' ast > for ImplTraitForTypeVisitor < ' a , ' _ > {
98
+ fn visit_impl_item_const ( & mut self , _node : & ' ast syn:: ImplItemConst ) {
99
+ // not relevant
100
+ }
101
+
102
+ fn visit_impl_item_macro ( & mut self , node : & ' ast syn:: ImplItemMacro ) {
103
+ self . 0 . visit_impl_item_macro ( node)
104
+ }
105
+
106
+ fn visit_impl_item_method ( & mut self , _node : & ' ast syn:: ImplItemMethod ) {
107
+ // not relevant
108
+ }
109
+
110
+ fn visit_impl_item_type ( & mut self , node : & ' ast syn:: ImplItemType ) {
111
+ self . 0 . visit_impl_item_type ( node)
112
+ }
113
+ }
114
+
97
115
let is_unstable = self . feature . is_unstable ( & node. attrs , None ) ;
116
+
117
+ struct ImplTraitForTypeVisitor < ' a , ' b > ( & ' b mut FilteredUnstableItemVisitor < ' a , syn:: ImplItem > ) ;
118
+
98
119
let mut visitor = FilteredUnstableItemVisitor {
99
120
feature : Feature {
100
121
name : self . feature . name ,
@@ -104,7 +125,14 @@ impl<'a> ModuleVisitor<'a> {
104
125
// that stability
105
126
items : vec ! [ ] ,
106
127
} ;
107
- visitor. visit_item_impl ( node) ;
128
+
129
+ if node. trait_ . is_some ( ) {
130
+ // 'impl Trait for Type { .. }', where only types are relevant.
131
+ ImplTraitForTypeVisitor ( & mut visitor) . visit_item_impl ( node) ;
132
+ } else {
133
+ // 'impl Type { .. }', where all items are relevant.
134
+ visitor. visit_item_impl ( node) ;
135
+ }
108
136
109
137
// A stable trait impl will always be stable on a stable item but can contain unstable items
110
138
if visitor. is_unstable ( ) {
0 commit comments