@@ -27,6 +27,7 @@ struct FnStats {
27
27
28
28
#[ derive( Clone ) ]
29
29
struct StructuredFnName {
30
+ trait_impl : Option < ( String , String ) > ,
30
31
krate : String ,
31
32
module_path : Vec < String > ,
32
33
type_parameters : Vec < String > ,
@@ -148,9 +149,22 @@ mod tests {
148
149
}
149
150
150
151
fn parse_fn_name ( raw_name : String ) -> StructuredFnName {
152
+ let trait_impl_re = Regex :: new ( r"<(.+) as (.+)>" ) . unwrap ( ) ;
151
153
let brackets_re = Regex :: new ( r"<(.+)>" ) . unwrap ( ) ;
152
154
153
155
let parts: Vec < String > = split_by_double_colons ( & raw_name) . into_iter ( ) . rev ( ) . collect ( ) ;
156
+
157
+ if parts. len ( ) == 2 && trait_impl_re. is_match ( & parts[ 1 ] ) {
158
+ let ti_captures = trait_impl_re. captures ( & parts[ 1 ] ) . unwrap ( ) ;
159
+ return StructuredFnName {
160
+ trait_impl : Some ( ( ti_captures[ 1 ] . to_string ( ) , ti_captures[ 2 ] . to_string ( ) ) ) ,
161
+ krate : "" . to_string ( ) ,
162
+ module_path : vec ! [ ] ,
163
+ type_parameters : vec ! [ ] ,
164
+ item : parts[ 0 ] . to_string ( )
165
+ }
166
+ }
167
+
154
168
let mut parts_index = 0 ;
155
169
let item = & parts[ parts_index] ; parts_index += 1 ;
156
170
let tp = & parts[ parts_index] . as_str ( ) ;
@@ -172,10 +186,11 @@ fn parse_fn_name(raw_name:String) -> StructuredFnName {
172
186
} ;
173
187
174
188
StructuredFnName {
175
- krate : kr,
176
- module_path : mp. into_iter ( ) . rev ( ) . collect ( ) ,
177
- type_parameters : type_parameters. into_iter ( ) . map ( |x| x. to_string ( ) ) . collect ( ) ,
178
- item : item. to_string ( )
189
+ trait_impl : None ,
190
+ krate : kr,
191
+ module_path : mp. into_iter ( ) . rev ( ) . collect ( ) ,
192
+ type_parameters : type_parameters. into_iter ( ) . map ( |x| x. to_string ( ) ) . collect ( ) ,
193
+ item : item. to_string ( )
179
194
}
180
195
}
181
196
@@ -189,7 +204,7 @@ fn handle_file(path:&Path) -> Result<(), Box<dyn Error>> {
189
204
190
205
for result in rdr. deserialize ( ) {
191
206
let fn_stats: FnStats = result?;
192
- if matches ! ( fn_stats. is_unsafe, Some ( true ) ) {
207
+ if matches ! ( fn_stats. is_unsafe, Some ( true ) ) || matches ! ( fn_stats . has_unsafe_ops , Some ( true ) ) {
193
208
let structured_fn_name = parse_fn_name ( fn_stats. name ) ;
194
209
let krate_and_module_path = CrateAndModules {
195
210
krate : structured_fn_name. krate . clone ( ) ,
@@ -207,6 +222,9 @@ fn handle_file(path:&Path) -> Result<(), Box<dyn Error>> {
207
222
if let Some ( fns) = fns_by_crate_and_modules. get ( krm) {
208
223
for structured_fn_name in fns {
209
224
println ! ( "--- unsafe-containing fn {}" , structured_fn_name. item) ;
225
+ if let Some ( ti) = & structured_fn_name. trait_impl {
226
+ println ! ( " trait {} as {}" , ti. 0 , ti. 1 ) ;
227
+ } else { }
210
228
if !structured_fn_name. type_parameters . is_empty ( ) {
211
229
println ! ( " type parameters {:?}" , structured_fn_name. type_parameters) ;
212
230
}
0 commit comments