//! virtually impossible. Thus, symbol hash generation exclusively relies on
//! DefPaths which are much more robust in the face of changes to the code base.
-use trans::{CrateContext, Instance};
+use trans::{CrateContext, Instance, gensym_name};
use util::sha2::{Digest, Sha256};
use rustc::middle::cstore;
-> String {
exported_name_with_opt_suffix(ccx, instance, Some(suffix))
}
+
+/// Only symbols that are invisible outside their compilation unit should use a
+/// name generated by this function.
+pub fn internal_name_from_type_and_suffix<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+ t: ty::Ty<'tcx>,
+ suffix: &str)
+ -> String {
+ let path = [token::intern(&t.to_string()).as_str(),
+ gensym_name(suffix).as_str()];
+ let hash = get_symbol_hash(ccx, &Vec::new(), cstore::LOCAL_CRATE, &[t]);
+ link::mangle(path.iter().cloned(), Some(&hash[..]))
+}
use std;
-use back::link;
+use back::symbol_names;
use llvm;
use llvm::{ValueRef, get_param};
use middle::lang_items::ExchangeFreeFnLangItem;
return llfn;
};
- let fn_nm = link::mangle_internal_name_by_type_and_seq(ccx, t, "drop");
+ let suffix = match g {
+ DropGlueKind::Ty(_) => "drop",
+ DropGlueKind::TyContents(_) => "drop_contents",
+ };
+
+ let fn_nm = symbol_names::internal_name_from_type_and_suffix(ccx, t, suffix);
assert!(declare::get_defined_value(ccx, &fn_nm).is_none());
let llfn = declare::declare_cfn(ccx, &fn_nm, llfnty);
ccx.available_drop_glues().borrow_mut().insert(g, fn_nm);