aboutsummaryrefslogtreecommitdiff
path: root/mingling_pathf/src/module_pathf.rs
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_pathf/src/module_pathf.rs')
-rw-r--r--mingling_pathf/src/module_pathf.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/mingling_pathf/src/module_pathf.rs b/mingling_pathf/src/module_pathf.rs
index d06be9b..f0a06d1 100644
--- a/mingling_pathf/src/module_pathf.rs
+++ b/mingling_pathf/src/module_pathf.rs
@@ -1,3 +1,9 @@
+//! A module for mapping Rust module paths to source files.
+//!
+//! This module provides functionality to analyze the module structure of a Rust crate
+//! and determine the effective module path for each source file, taking into account
+//! `pub use` re-exports that can cause modules to be hoisted to parent paths.
+
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use syn::{Item, UseTree};
@@ -10,7 +16,6 @@ use crate::error::MinglingPathfinderError;
/// effective module path (e.g., `crate::foo::bar`).
#[derive(Debug, Clone)]
pub struct MappingItem {
-
/// The path of the source file (relative to the crate root, with `./` prefix).
file_path: PathBuf,
@@ -349,11 +354,7 @@ fn propagate_children(parent_file: &Path, ctx: &mut Context) {
.cloned()
.unwrap_or_else(|| "crate".to_string());
- let reexported = ctx
- .reexports
- .get(parent_file)
- .cloned()
- .unwrap_or_default();
+ let reexported = ctx.reexports.get(parent_file).cloned().unwrap_or_default();
let Some(children) = ctx.children.get(parent_file).cloned() else {
return;
@@ -367,8 +368,7 @@ fn propagate_children(parent_file: &Path, ctx: &mut Context) {
format!("{}::{}", parent_effective, child.name)
};
- ctx.effective_paths
- .insert(child.file.clone(), effective);
+ ctx.effective_paths.insert(child.file.clone(), effective);
propagate_children(&child.file, ctx);
}
}