about summary refs log tree commit diff
path: root/src/test/debuginfo
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-03-15 17:15:52 +0100
committerGitHub <noreply@github.com>2022-03-15 17:15:52 +0100
commite755f2c7cdf8636f53243f2fdaffab2a87c5a3c5 (patch)
tree57e06d8637ffae44b89724db3f43a8aa871ebdd2 /src/test/debuginfo
parentbe52b4af5ec7e49572cb16519b7e144d6bcb051d (diff)
parent5cd8a2addaf4aae55c52fb9af5fdb36243295070 (diff)
downloadrust-e755f2c7cdf8636f53243f2fdaffab2a87c5a3c5.tar.gz
rust-e755f2c7cdf8636f53243f2fdaffab2a87c5a3c5.zip
Rollup merge of #94810 - michaelwoerister:fix-trait-pointer-debuginfo-names, r=wesleywiser
debuginfo: Fix bug in type name generation for dyn types with associated types but no other generic arguments.

For types like `&dyn Future<Output=bool>` the compiler currently emits invalid types names in debuginfo. This PR fixes this.

Before:
```txt
// DWARF
&dyn core::future::future::Future, Output=bool>

// CodeView
ref$<dyn$<core::future::future::Future,assoc$<Output,bool> > > >
```

After:
```txt
// DWARF
&dyn core::future::future::Future<Output=bool>

// CodeView
ref$<dyn$<core::future::future::Future<assoc$<Output,bool> > > >
```

These syntactically incorrect type names can cause downstream tools (e.g. debugger extensions) crash when trying to parse them.

r? `@wesleywiser`
Diffstat (limited to 'src/test/debuginfo')
-rw-r--r--src/test/debuginfo/type-names.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/debuginfo/type-names.rs b/src/test/debuginfo/type-names.rs
index 52841d50f64..b040a6e7494 100644
--- a/src/test/debuginfo/type-names.rs
+++ b/src/test/debuginfo/type-names.rs
@@ -122,6 +122,9 @@
 // gdb-command:whatis has_associated_type_trait
 // gdb-check:type = &(dyn type_names::Trait3<u32, AssocType=isize> + core::marker::Send)
 
+// gdb-command:whatis has_associated_type_but_no_generics_trait
+// gdb-check:type = &dyn type_names::TraitNoGenericsButWithAssocType<Output=isize>
+
 // BARE FUNCTIONS
 // gdb-command:whatis rust_fn
 // gdb-check:type = (fn(core::option::Option<isize>, core::option::Option<&type_names::mod1::Struct2>), usize)
@@ -228,6 +231,7 @@
 // cdb-check:struct ref_mut$<dyn$<type_names::Trait1> > mut_ref_trait = [...]
 // cdb-check:struct alloc::boxed::Box<dyn$<core::marker::Send,core::marker::Sync>,alloc::alloc::Global> no_principal_trait = [...]
 // cdb-check:struct ref$<dyn$<type_names::Trait3<u32,assoc$<AssocType,isize> >,core::marker::Send> > has_associated_type_trait = struct ref$<dyn$<type_names::Trait3<u32,assoc$<AssocType,isize> >,core::marker::Send> >
+// cdb-check:struct ref$<dyn$<type_names::TraitNoGenericsButWithAssocType<assoc$<Output,isize> > > > has_associated_type_but_no_generics_trait = struct ref$<dyn$<type_names::TraitNoGenericsButWithAssocType<assoc$<Output,isize> > > >
 
 // BARE FUNCTIONS
 // cdb-command:dv /t *_fn*
@@ -317,12 +321,22 @@ trait Trait3<T> {
         panic!()
     }
 }
+trait TraitNoGenericsButWithAssocType {
+    type Output;
+    fn foo(&self) -> Self::Output;
+}
 
 impl Trait1 for isize {}
 impl<T1, T2> Trait2<T1, T2> for isize {}
 impl<T> Trait3<T> for isize {
     type AssocType = isize;
 }
+impl TraitNoGenericsButWithAssocType for isize {
+    type Output = isize;
+    fn foo(&self) -> Self::Output {
+        *self
+    }
+}
 
 fn rust_fn(_: Option<isize>, _: Option<&mod1::Struct2>) {}
 extern "C" fn extern_c_fn(_: isize) {}
@@ -413,6 +427,8 @@ fn main() {
     let mut_ref_trait = (&mut mut_int1) as &mut dyn Trait1;
     let no_principal_trait = Box::new(0_isize) as Box<(dyn Send + Sync)>;
     let has_associated_type_trait = &0_isize as &(dyn Trait3<u32, AssocType = isize> + Send);
+    let has_associated_type_but_no_generics_trait =
+        &0_isize as &dyn TraitNoGenericsButWithAssocType<Output = isize>;
 
     let generic_box_trait = Box::new(0_isize) as Box<dyn Trait2<i32, mod1::Struct2>>;
     let generic_ref_trait = (&0_isize) as &dyn Trait2<Struct1, Struct1>;