about summary refs log tree commit diff
path: root/src/test/debuginfo/function-names.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-02-02 12:37:28 +0000
committerbors <bors@rust-lang.org>2022-02-02 12:37:28 +0000
commitdca1e7aa5a8ac05ddaea731f4eab20de91acb46b (patch)
tree998630298a1ad039ae3be5f6fa34a80ddee06c15 /src/test/debuginfo/function-names.rs
parent250384edc5d78533e993f38c60d64e42b21684b2 (diff)
parentfd7557b7ee454058fff84b556892adbef89f7d52 (diff)
downloadrust-dca1e7aa5a8ac05ddaea731f4eab20de91acb46b.tar.gz
rust-dca1e7aa5a8ac05ddaea731f4eab20de91acb46b.zip
Auto merge of #93154 - michaelwoerister:fix-generic-closure-and-generator-debuginfo, r=wesleywiser
debuginfo: Make sure that type names for closure and generator environments are unique in debuginfo.

Before this change, closure/generator environments coming from different instantiations of the same generic function were all assigned the same name even though they were distinct types with potentially different data layout. Now we append the generic arguments of the originating function to the type name.

This commit also emits `{closure_env#0}` as the name of these types in order to disambiguate them from the accompanying closure function (which keeps being called `{closure#0}`). Previously both were assigned the same name.

NOTE: Changing debuginfo names like this can break pretty printers and other debugger plugins. I think it's OK in this particular case because the names we are changing were ambiguous anyway. In general though it would be great to have a process for doing changes like these.
Diffstat (limited to 'src/test/debuginfo/function-names.rs')
-rw-r--r--src/test/debuginfo/function-names.rs21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/test/debuginfo/function-names.rs b/src/test/debuginfo/function-names.rs
index 61d5fc93cd2..bb56d37cfe9 100644
--- a/src/test/debuginfo/function-names.rs
+++ b/src/test/debuginfo/function-names.rs
@@ -27,9 +27,9 @@
 
 // Closure
 // gdb-command:info functions -q function_names::.*::{closure.*
-// gdb-check:[...]static fn function_names::generic_func::{closure#0}<i32>(*mut function_names::generic_func::{closure#0});
-// gdb-check:[...]static fn function_names::main::{closure#0}(*mut function_names::main::{closure#0});
-// gdb-check:[...]static fn function_names::{impl#2}::impl_function::{closure#0}<i32, i32>(*mut function_names::{impl#2}::impl_function::{closure#0});
+// gdb-check:[...]static fn function_names::generic_func::{closure#0}<i32>(*mut function_names::generic_func::{closure_env#0}<i32>);
+// gdb-check:[...]static fn function_names::main::{closure#0}(*mut function_names::main::{closure_env#0});
+// gdb-check:[...]static fn function_names::{impl#2}::impl_function::{closure#0}<i32, i32>(*mut function_names::{impl#2}::impl_function::{closure_env#0}<i32, i32>);
 
 // Generator
 // Generators don't seem to appear in GDB's symbol table.
@@ -86,9 +86,9 @@
 #![feature(adt_const_params, generators, generator_trait)]
 #![allow(incomplete_features)]
 
-use Mod1::TestTrait2;
 use std::ops::Generator;
 use std::pin::Pin;
+use Mod1::TestTrait2;
 
 fn main() {
     // Implementations
@@ -107,16 +107,19 @@ fn main() {
     let _ = generic_func(42i32);
 
     // Closure
-    let closure = || { TestStruct1 };
+    let closure = || TestStruct1;
     closure();
 
     // Generator
-    let mut generator = || { yield; return; };
+    let mut generator = || {
+        yield;
+        return;
+    };
     Pin::new(&mut generator).resume(());
 
     // Const generic functions
     const_generic_fn_bool::<false>();
-    const_generic_fn_non_int::<{()}>();
+    const_generic_fn_non_int::<{ () }>();
     const_generic_fn_signed_int::<-7>();
     const_generic_fn_unsigned_int::<14>();
 }
@@ -158,7 +161,7 @@ struct GenericStruct<T1, T2>(std::marker::PhantomData<(T1, T2)>);
 impl<T1, T2> GenericStruct<T1, T2> {
     pub fn impl_function() {
         // Closure in a generic implementation
-        let closure = || { TestStruct1 };
+        let closure = || TestStruct1;
         closure();
     }
 }
@@ -190,7 +193,7 @@ impl<T, const N: usize> TestTrait1 for GenericStruct<[T; N], f32> {
 // Generic function
 fn generic_func<T>(value: T) -> T {
     // Closure in a generic function
-    let closure = || { TestStruct1 };
+    let closure = || TestStruct1;
     closure();
 
     value