diff --git a/src/ast.rs b/src/ast.rs index 743ba661..fafc4394 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -224,7 +224,11 @@ impl AST { /// Set the source. #[inline(always)] pub fn set_source>(&mut self, source: Option) { - self.source = source.map(|s| s.into()) + self.source = source.map(|s| s.into()); + + if let Some(module) = Shared::get_mut(&mut self.functions) { + module.set_id(self.source.clone()); + } } /// Get the statements. #[cfg(not(feature = "internals"))] diff --git a/src/module/mod.rs b/src/module/mod.rs index 97a3fada..14a2aaee 100644 --- a/src/module/mod.rs +++ b/src/module/mod.rs @@ -251,8 +251,8 @@ impl Module { self.id.as_ref().map(|s| s.as_str()) } - /// Get the ID of the [`Module`], if any. - pub(crate) fn id_raw(&self) -> &Option { + /// Get the ID of the [`Module`] as an [`ImmutableString`], if any. + pub fn id_raw(&self) -> &Option { &self.id }