@@ -247,15 +247,13 @@ impl<'ast> Visit<'ast> for DiscoveryVisitor<'_> {
247247
248248 /// Visit `mod foo { ... }` or `mod foo;`.
249249 fn visit_item_mod ( & mut self , node : & ' ast syn:: ItemMod ) {
250+ // TODO: Maybe while visiting the file we should only collect the
251+ // `mod` statements, and then find the files separately, to keep IO
252+ // effects away from parsing the file.
250253 let mod_name = & node. ident . unraw ( ) . to_string ( ) ;
251- let _span = trace_span ! (
252- "mod" ,
253- line = node. mod_token. span. start( ) . line,
254- name = mod_name
255- )
256- . entered ( ) ;
254+ let _span = trace_span ! ( "mod" , line = node. mod_token. span. start( ) . line, mod_name) . entered ( ) ;
257255 if attrs_excluded ( & node. attrs ) {
258- trace ! ( "mod {:?} excluded by attrs" , node . ident , ) ;
256+ trace ! ( "mod excluded by attrs" ) ;
259257 return ;
260258 }
261259 // If there's no content in braces, then this is a `mod foo;`
@@ -511,20 +509,19 @@ fn path_ends_with(path: &Path, ident: &str) -> bool {
511509/// If so, return the short name (like "Box") and the inner type.
512510fn known_container ( path : & Path ) -> Option < ( & Ident , & Type ) > {
513511 let last = path. segments . last ( ) ?;
514- if ! [ "Box" , "Cell" , "RefCell" , "Arc" , "Rc" , "Mutex" ]
512+ if [ "Box" , "Cell" , "RefCell" , "Arc" , "Rc" , "Mutex" ]
515513 . iter ( )
516514 . any ( |v| last. ident == v)
517515 {
518- return None ;
519- }
520- if let PathArguments :: AngleBracketed ( AngleBracketedGenericArguments { args, .. } ) =
521- & last. arguments
522- {
523- // TODO: Skip lifetime args.
524- // TODO: Return the path with args stripped out.
525- if args. len ( ) == 1 {
526- if let Some ( GenericArgument :: Type ( inner_type) ) = args. first ( ) {
527- return Some ( ( & last. ident , inner_type) ) ;
516+ if let PathArguments :: AngleBracketed ( AngleBracketedGenericArguments { args, .. } ) =
517+ & last. arguments
518+ {
519+ // TODO: Skip lifetime args.
520+ // TODO: Return the path with args stripped out.
521+ if args. len ( ) == 1 {
522+ if let Some ( GenericArgument :: Type ( inner_type) ) = args. first ( ) {
523+ return Some ( ( & last. ident , inner_type) ) ;
524+ }
528525 }
529526 }
530527 }
0 commit comments