-fn walk_ast<'a>(in_dir: &str, path: &str, module: String, ast_storage: &'a FullLibraryAST, crate_types: &mut CrateTypes<'a>) {
- let syntax = if let Some(ast) = ast_storage.files.get(&module) { ast } else { return };
- assert_eq!(export_status(&syntax.attrs), ExportStatus::Export);
-
- for (path, new_mod, _) in file_iter(&syntax, in_dir, path, &module) {
- walk_ast(in_dir, &path, new_mod, ast_storage, crate_types);
- }
+fn walk_ast<'a>(ast_storage: &'a FullLibraryAST, crate_types: &mut CrateTypes<'a>) {
+ for (module, astmod) in ast_storage.modules.iter() {
+ let ASTModule { ref attrs, ref items, submods: _ } = astmod;
+ assert_eq!(export_status(&attrs), ExportStatus::Export);
+ let import_resolver = ImportResolver::new(module, items);
+
+ for item in items.iter() {
+ match item {
+ syn::Item::Struct(s) => {
+ if let syn::Visibility::Public(_) = s.vis {
+ match export_status(&s.attrs) {
+ ExportStatus::Export => {},
+ ExportStatus::NoExport|ExportStatus::TestOnly => continue,
+ }
+ let struct_path = format!("{}::{}", module, s.ident);
+ crate_types.opaques.insert(struct_path, &s.ident);
+ }
+ },
+ syn::Item::Trait(t) => {
+ if let syn::Visibility::Public(_) = t.vis {
+ match export_status(&t.attrs) {
+ ExportStatus::Export => {},
+ ExportStatus::NoExport|ExportStatus::TestOnly => continue,
+ }
+ let trait_path = format!("{}::{}", module, t.ident);
+ walk_supertraits!(t, None, (
+ ("Clone", _) => {
+ crate_types.clonable_types.insert("crate::".to_owned() + &trait_path);
+ },
+ (_, _) => {}
+ ) );
+ crate_types.traits.insert(trait_path, &t);
+ }
+ },
+ syn::Item::Type(t) => {
+ if let syn::Visibility::Public(_) = t.vis {
+ match export_status(&t.attrs) {
+ ExportStatus::Export => {},
+ ExportStatus::NoExport|ExportStatus::TestOnly => continue,
+ }
+ let type_path = format!("{}::{}", module, t.ident);
+ let mut process_alias = true;
+ for tok in t.generics.params.iter() {
+ if let syn::GenericParam::Lifetime(_) = tok {}
+ else { process_alias = false; }
+ }
+ if process_alias {
+ match &*t.ty {
+ syn::Type::Path(p) => {
+ // If its a path with no generics, assume we don't map the aliased type and map it opaque
+ let mut segments = syn::punctuated::Punctuated::new();
+ segments.push(syn::PathSegment {
+ ident: t.ident.clone(),
+ arguments: syn::PathArguments::None,
+ });
+ let path_obj = syn::Path { leading_colon: None, segments };
+ let args_obj = p.path.segments.last().unwrap().arguments.clone();
+ match crate_types.reverse_alias_map.entry(import_resolver.maybe_resolve_path(&p.path, None).unwrap()) {
+ hash_map::Entry::Occupied(mut e) => { e.get_mut().push((path_obj, args_obj)); },
+ hash_map::Entry::Vacant(e) => { e.insert(vec![(path_obj, args_obj)]); },
+ }