From acbf5d8723ad11187a3279c873deab849add1ec5 Mon Sep 17 00:00:00 2001 From: Ilya Lakhin Date: Sun, 3 Jan 2021 09:03:41 +0700 Subject: [PATCH 1/2] AST::set_source affects internal module id --- src/ast.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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"))] From 85ec781a3524087e5f5f8fe31641fd2e455d3d51 Mon Sep 17 00:00:00 2001 From: Ilya Lakhin Date: Sun, 3 Jan 2021 09:08:22 +0700 Subject: [PATCH 2/2] Module::id_raw became crate-public --- src/module/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 }