about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/librustc_codegen_utils/symbol_names/v0.rs4
-rw-r--r--src/test/run-pass/struct-ctor-mangling.rs12
2 files changed, 13 insertions, 3 deletions
diff --git a/src/librustc_codegen_utils/symbol_names/v0.rs b/src/librustc_codegen_utils/symbol_names/v0.rs
index 6d37d4cafc3..dc985c8126c 100644
--- a/src/librustc_codegen_utils/symbol_names/v0.rs
+++ b/src/librustc_codegen_utils/symbol_names/v0.rs
@@ -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',
 
diff --git a/src/test/run-pass/struct-ctor-mangling.rs b/src/test/run-pass/struct-ctor-mangling.rs
new file mode 100644
index 00000000000..5f5ee7cfe44
--- /dev/null
+++ b/src/test/run-pass/struct-ctor-mangling.rs
@@ -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);
+}