diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-03-13 16:24:46 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-03-13 16:24:46 -0700 |
| commit | a07149b138fc1ff19d8a8510cf703ecb811961fd (patch) | |
| tree | fbccad1f013a2d932dc488db7b58c99e672f2460 /src | |
| parent | 62989008956e284e6d0c61032ea8b67fbe735338 (diff) | |
| download | rust-a07149b138fc1ff19d8a8510cf703ecb811961fd.tar.gz rust-a07149b138fc1ff19d8a8510cf703ecb811961fd.zip | |
rustc: Prevent collisions in names of closures
This commit goes back to using `gensym` to generate unique tokens to put into the names of closures, allowing closures to be able to get demangled in backtraces. Closes #12400
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/middle/trans/common.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index e3a996e33d3..bfe5d5187d7 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -103,8 +103,13 @@ pub fn return_type_is_void(ccx: &CrateContext, ty: ty::t) -> bool { ty::type_is_nil(ty) || ty::type_is_bot(ty) || ty::type_is_empty(ccx.tcx, ty) } +/// Generates a unique symbol based off the name given. This is used to create +/// unique symbols for things like closures. pub fn gensym_name(name: &str) -> PathElem { - PathName(token::gensym(name)) + let num = token::gensym(name); + // use one colon which will get translated to a period by the mangler, and + // we're guaranteed that `num` is globally unique for this crate. + PathName(token::gensym(format!("{}:{}", name, num))) } pub struct tydesc_info { |
