Skip to content

Commit ba5f101

Browse files
committed
librustc: Add export_name attribute to specify symbol name.
1 parent bb35e23 commit ba5f101

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/librustc/middle/trans/base.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2453,10 +2453,16 @@ pub fn item_path(ccx: &CrateContext, id: &ast::NodeId) -> path {
24532453
}
24542454

24552455
fn exported_name(ccx: @mut CrateContext, path: path, ty: ty::t, attrs: &[ast::Attribute]) -> ~str {
2456-
if attr::contains_name(attrs, "no_mangle") {
2457-
path_elt_to_str(*path.last(), token::get_ident_interner())
2458-
} else {
2459-
mangle_exported_name(ccx, path, ty)
2456+
match attr::first_attr_value_str_by_name(attrs, "export_name") {
2457+
// Use provided name
2458+
Some(name) => name.to_owned(),
2459+
2460+
// Don't mangle
2461+
_ if attr::contains_name(attrs, "no_mangle")
2462+
=> path_elt_to_str(*path.last(), token::get_ident_interner()),
2463+
2464+
// Usual name mangling
2465+
_ => mangle_exported_name(ccx, path, ty)
24602466
}
24612467
}
24622468

0 commit comments

Comments
 (0)