Skip to content

Commit 408bf9d

Browse files
committed
rustc_codegen_utils: don't ignore Ctor path components in symbols.
1 parent 2092963 commit 408bf9d

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/librustc_codegen_utils/symbol_names/v0.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -586,13 +586,11 @@ impl Printer<'tcx, 'tcx> for SymbolMangler<'_, 'tcx> {
586586
disambiguated_data: &DisambiguatedDefPathData,
587587
) -> Result<Self::Path, Self::Error> {
588588
let ns = match disambiguated_data.data {
589-
// Avoid putting the burden on demanglers to ignore this.
590-
DefPathData::Ctor => return print_prefix(self),
591-
592589
// Uppercase categories are more stable than lowercase ones.
593590
DefPathData::TypeNs(_) => 't',
594591
DefPathData::ValueNs(_) => 'v',
595592
DefPathData::ClosureExpr => 'C',
593+
DefPathData::Ctor => 'c',
596594
DefPathData::AnonConst => 'k',
597595
DefPathData::ImplTrait => 'i',
598596

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fn size_of_val<T>(_: &T) -> usize {
2+
std::mem::size_of::<T>()
3+
}
4+
5+
struct Foo(i64);
6+
7+
// Test that the (symbol) mangling of `Foo` (the `struct` type) and that of
8+
// `typeof Foo` (the function type of the `struct` constructor) don't collide.
9+
fn main() {
10+
size_of_val(&Foo(0));
11+
size_of_val(&Foo);
12+
}

0 commit comments

Comments
 (0)