@@ -30,6 +30,7 @@ struct StructuredFnName {
30
30
module_path : Vec < String > ,
31
31
type_parameters : Vec < String > ,
32
32
item : String ,
33
+ is_public : bool
33
34
}
34
35
35
36
fn split_by_double_colons ( s : & str ) -> Vec < String > {
@@ -140,7 +141,7 @@ mod tests {
140
141
}
141
142
}
142
143
143
- fn parse_fn_name ( raw_name : String ) -> StructuredFnName {
144
+ fn parse_fn_name ( raw_name : String , is_public : bool ) -> StructuredFnName {
144
145
let trait_impl_re = Regex :: new ( r"<(.+) as (.+)>" ) . unwrap ( ) ;
145
146
let brackets_re = Regex :: new ( r"<(.+)>" ) . unwrap ( ) ;
146
147
@@ -152,7 +153,8 @@ fn parse_fn_name(raw_name:String) -> StructuredFnName {
152
153
trait_impl : Some ( ( ti_captures[ 1 ] . to_string ( ) , ti_captures[ 2 ] . to_string ( ) ) ) ,
153
154
module_path : vec ! [ ] ,
154
155
type_parameters : vec ! [ ] ,
155
- item : parts[ 0 ] . to_string ( )
156
+ item : parts[ 0 ] . to_string ( ) ,
157
+ is_public : is_public
156
158
}
157
159
}
158
160
@@ -176,7 +178,8 @@ fn parse_fn_name(raw_name:String) -> StructuredFnName {
176
178
trait_impl : None ,
177
179
module_path : mp. into_iter ( ) . rev ( ) . collect ( ) ,
178
180
type_parameters : type_parameters. into_iter ( ) . map ( |x| x. to_string ( ) ) . collect ( ) ,
179
- item : item. to_string ( )
181
+ item : item. to_string ( ) ,
182
+ is_public : is_public
180
183
}
181
184
}
182
185
@@ -191,7 +194,7 @@ fn handle_file(path:&Path) -> Result<(), Box<dyn Error>> {
191
194
for result in rdr. deserialize ( ) {
192
195
let fn_stats: FnStats = result?;
193
196
if matches ! ( fn_stats. is_unsafe, Some ( true ) ) || matches ! ( fn_stats. has_unsafe_ops, Some ( true ) ) {
194
- let structured_fn_name = parse_fn_name ( fn_stats. name ) ;
197
+ let structured_fn_name = parse_fn_name ( fn_stats. name , fn_stats . is_public . is_some ( ) && fn_stats . is_public . unwrap ( ) ) ;
195
198
match fns_by_modules. get_mut ( & structured_fn_name. module_path ) {
196
199
Some ( fns) => fns. push ( structured_fn_name. clone ( ) ) ,
197
200
None => { fns_by_modules. insert ( structured_fn_name. module_path . clone ( ) , vec ! [ structured_fn_name. clone( ) ] ) ; }
@@ -203,7 +206,7 @@ fn handle_file(path:&Path) -> Result<(), Box<dyn Error>> {
203
206
println ! ( "modules {:?}" , mp) ;
204
207
if let Some ( fns) = fns_by_modules. get ( mp) {
205
208
for structured_fn_name in fns {
206
- println ! ( "--- unsafe-containing fn {}" , structured_fn_name. item) ;
209
+ println ! ( "--- unsafe-containing fn {} {} " , structured_fn_name. item, if structured_fn_name . is_public { "[pub]" } else { "" } ) ;
207
210
if let Some ( ti) = & structured_fn_name. trait_impl {
208
211
println ! ( " trait impl: type {} as trait {}" , ti. 0 , ti. 1 ) ;
209
212
} else { }
0 commit comments