rustc_codegen_utils: don't ignore `Ctor` path components in symbols.

This commit is contained in:
Eduard-Mihai Burtescu 2019-02-04 09:03:31 +02:00
parent 2092963a18
commit 408bf9de34
2 changed files with 13 additions and 3 deletions

View File

@ -586,13 +586,11 @@ impl Printer<'tcx, 'tcx> for SymbolMangler<'_, 'tcx> {
disambiguated_data: &DisambiguatedDefPathData,
) -> Result<Self::Path, Self::Error> {
let ns = match disambiguated_data.data {
// Avoid putting the burden on demanglers to ignore this.
DefPathData::Ctor => return print_prefix(self),
// Uppercase categories are more stable than lowercase ones.
DefPathData::TypeNs(_) => 't',
DefPathData::ValueNs(_) => 'v',
DefPathData::ClosureExpr => 'C',
DefPathData::Ctor => 'c',
DefPathData::AnonConst => 'k',
DefPathData::ImplTrait => 'i',

View File

@ -0,0 +1,12 @@
fn size_of_val<T>(_: &T) -> usize {
std::mem::size_of::<T>()
}
struct Foo(i64);
// Test that the (symbol) mangling of `Foo` (the `struct` type) and that of
// `typeof Foo` (the function type of the `struct` constructor) don't collide.
fn main() {
size_of_val(&Foo(0));
size_of_val(&Foo);
}