diff --git a/pilota-build/src/lib.rs b/pilota-build/src/lib.rs index 76bf2c0..0326c8a 100644 --- a/pilota-build/src/lib.rs +++ b/pilota-build/src/lib.rs @@ -9,7 +9,7 @@ mod util; pub mod codegen; pub mod db; pub(crate) mod errors; -mod fmt; +pub mod fmt; mod index; mod ir; pub mod middle; diff --git a/pilota-build/src/middle/context.rs b/pilota-build/src/middle/context.rs index 28a16dd..bb26000 100644 --- a/pilota-build/src/middle/context.rs +++ b/pilota-build/src/middle/context.rs @@ -48,7 +48,7 @@ pub enum CollectMode { #[derive(Debug)] pub struct WorkspaceInfo { - pub(crate) dir: PathBuf, + pub dir: PathBuf, pub(crate) location_map: FxHashMap, } @@ -67,14 +67,14 @@ pub struct Context { pub(crate) codegen_items: Arc<[DefId]>, pub(crate) path_resolver: Arc, pub mode: Arc, - pub(crate) split: bool, + pub split: bool, pub(crate) keep_unknown_fields: Arc>, pub location_map: Arc>, pub entry_map: Arc>>, pub plugin_gen: Arc>, pub(crate) dedups: Vec, pub(crate) common_crate_name: FastStr, - pub names: FxHashSet, + pub names: FxHashMap, } impl Clone for Context { @@ -382,8 +382,9 @@ impl ContextBuilder { cx.names.extend( map.into_iter() .filter(|(_, v)| v.len() > 1) - .flat_map(|(_, v)| v) - .collect::>(), + .map(|(_, v)| v) + .flat_map(|v| v.into_iter().enumerate().map(|(i, def_id)| (def_id, i))) + .collect::>(), ); cx } @@ -834,7 +835,7 @@ impl Context { return name.0.into(); } - if !self.change_case || self.names.contains(&def_id) { + if !self.change_case || self.names.contains_key(&def_id) { return node.name(); }