summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-11-10 20:53:47 -0500
committerGitHub <noreply@github.com>2018-11-10 20:53:47 -0500
commit8489d42c47d46ed63f168cd0c913e5a65c6c942a (patch)
tree4f3d5398ee7ef47b39e6c5475221de26cbd60ce2 /src
parent2a07619ad0aaed985d401dbe9eac2da9d2f32de8 (diff)
parent5b741da6e9a4a0737df37cb04a8adee0d30224df (diff)
Auto merge of #1438 - ekse:item_name, r=emilio
Add item_name parse callback. Issue: #428
Diffstat (limited to 'src')
-rw-r--r--src/callbacks.rs5
-rw-r--r--src/ir/item.rs5
2 files changed, 10 insertions, 0 deletions
diff --git a/src/callbacks.rs b/src/callbacks.rs
index 71b98fc9..26f77338 100644
--- a/src/callbacks.rs
+++ b/src/callbacks.rs
@@ -55,4 +55,9 @@ pub trait ParseCallbacks: fmt::Debug + UnwindSafe {
) -> Option<String> {
None
}
+
+ /// Allows to rename an item, replacing `_original_item_name`.
+ fn item_name(&self, _original_item_name: &str) -> Option<String> {
+ None
+ }
}
diff --git a/src/ir/item.rs b/src/ir/item.rs
index 5f0ccc0b..a6ee4ff3 100644
--- a/src/ir/item.rs
+++ b/src/ir/item.rs
@@ -875,6 +875,11 @@ impl Item {
let name = names.join("_");
+ let name = ctx
+ .parse_callbacks()
+ .and_then(|callbacks| callbacks.item_name(&name))
+ .unwrap_or(name);
+
ctx.rust_mangle(&name).into_owned()
}