1 // Function names are formatted differently in old versions of GDB
2 // min-gdb-version: 10.1
6 // === GDB TESTS ===================================================================================
9 // gdb-command:info functions -q function_names::main
10 // gdb-check:[...]static fn function_names::main();
11 // gdb-command:info functions -q function_names::generic_func<*
12 // gdb-check:[...]static fn function_names::generic_func<i32>(i32) -> i32;
15 // gdb-command:info functions -q function_names::.*::impl_function.*
16 // gdb-check:[...]static fn function_names::GenericStruct<i32, i32>::impl_function<i32, i32>();
17 // gdb-check:[...]static fn function_names::Mod1::TestStruct2::impl_function();
18 // gdb-check:[...]static fn function_names::TestStruct1::impl_function();
20 // Trait implementations
21 // gdb-command:info functions -q function_names::.*::trait_function.*
22 // gdb-check:[...]static fn function_names::Mod1::{impl#1}::trait_function();
23 // gdb-check:[...]static fn function_names::{impl#1}::trait_function();
24 // gdb-check:[...]static fn function_names::{impl#3}::trait_function<i32>();
25 // gdb-check:[...]static fn function_names::{impl#5}::trait_function3<function_names::TestStruct1>();
26 // gdb-check:[...]static fn function_names::{impl#6}::trait_function<i32, 1>();
29 // gdb-command:info functions -q function_names::.*::{closure.*
30 // gdb-check:[...]static fn function_names::generic_func::{closure#0}<i32>(*mut function_names::generic_func::{closure#0});
31 // gdb-check:[...]static fn function_names::main::{closure#0}(*mut function_names::main::{closure#0});
32 // gdb-check:[...]static fn function_names::{impl#2}::impl_function::{closure#0}<i32, i32>(*mut function_names::{impl#2}::impl_function::{closure#0});
35 // Generators don't seem to appear in GDB's symbol table.
37 // Const generic parameter
38 // gdb-command:info functions -q function_names::const_generic_fn.*
39 // gdb-check:[...]static fn function_names::const_generic_fn_bool<false>();
40 // gdb-check:[...]static fn function_names::const_generic_fn_non_int<{CONST#3fcd7c34c1555be6}>();
41 // gdb-check:[...]static fn function_names::const_generic_fn_signed_int<-7>();
42 // gdb-check:[...]static fn function_names::const_generic_fn_unsigned_int<14>();
44 // === CDB TESTS ===================================================================================
47 // cdb-command:x a!function_names::main
48 // cdb-check:[...] a!function_names::main (void)
49 // cdb-command:x a!function_names::generic_func<*
50 // cdb-check:[...] a!function_names::generic_func<i32> (int)
53 // cdb-command:x a!function_names::*::impl_function*
54 // cdb-check:[...] a!function_names::Mod1::TestStruct2::impl_function (void)
55 // cdb-check:[...] a!function_names::TestStruct1::impl_function (void)
56 // cdb-check:[...] a!function_names::GenericStruct<i32,i32>::impl_function<i32,i32> (void)
58 // Trait implementations
59 // cdb-command:x a!function_names::*::trait_function*
60 // cdb-check:[...] a!function_names::impl$3::trait_function<i32> (void)
61 // cdb-check:[...] a!function_names::impl$6::trait_function<i32,1> (void)
62 // cdb-check:[...] a!function_names::impl$1::trait_function (void)
63 // cdb-check:[...] a!function_names::impl$5::trait_function3<function_names::TestStruct1> (void)
64 // cdb-check:[...] a!function_names::Mod1::impl$1::trait_function (void)
67 // cdb-command:x a!function_names::*::closure*
68 // cdb-check:[...] a!function_names::impl$2::impl_function::closure$0<i32,i32> (void)
69 // cdb-check:[...] a!function_names::main::closure$0 (void)
70 // cdb-check:[...] a!function_names::generic_func::closure$0<i32> (void)
73 // cdb-command:x a!function_names::*::generator*
74 // cdb-check:[...] a!function_names::main::generator$1 (void)
76 // Const generic parameter
77 // cdb-command:x a!function_names::const_generic_fn*
78 // cdb-check:[...] a!function_names::const_generic_fn_bool<false> (void)
79 // cdb-check:[...] a!function_names::const_generic_fn_non_int<CONST$3fcd7c34c1555be6> (void)
80 // cdb-check:[...] a!function_names::const_generic_fn_unsigned_int<14> (void)
81 // cdb-check:[...] a!function_names::const_generic_fn_signed_int<-7> (void)
83 #![allow(unused_variables)]
84 #![feature(omit_gdb_pretty_printer_section)]
85 #![omit_gdb_pretty_printer_section]
86 #![feature(adt_const_params, generators, generator_trait)]
87 #![allow(incomplete_features)]
90 use std::ops::Generator;
95 TestStruct1::impl_function();
96 Mod1::TestStruct2::impl_function();
97 GenericStruct::<i32, i32>::impl_function();
99 // Trait implementations
100 TestStruct1::trait_function();
101 Mod1::TestStruct2::trait_function();
102 GenericStruct::<i32, i32>::trait_function();
103 GenericStruct::<[i32; 1], f32>::trait_function();
104 GenericStruct::<TestStruct1, usize>::trait_function3();
107 let _ = generic_func(42i32);
110 let closure = || { TestStruct1 };
114 let mut generator = || { yield; return; };
115 Pin::new(&mut generator).resume(());
117 // Const generic functions
118 const_generic_fn_bool::<false>();
119 const_generic_fn_non_int::<{()}>();
120 const_generic_fn_signed_int::<-7>();
121 const_generic_fn_unsigned_int::<14>();
131 pub fn impl_function() {}
134 // Implementation for a trait
135 impl TestTrait1 for TestStruct1 {
136 fn trait_function() {}
139 // Implementation and implementation within a mod
141 pub struct TestStruct2;
142 pub trait TestTrait2 {
147 pub fn impl_function() {}
150 impl TestTrait2 for TestStruct2 {
151 fn trait_function() {}
155 struct GenericStruct<T1, T2>(std::marker::PhantomData<(T1, T2)>);
157 // Generic implementation
158 impl<T1, T2> GenericStruct<T1, T2> {
159 pub fn impl_function() {
160 // Closure in a generic implementation
161 let closure = || { TestStruct1 };
166 // Generic trait implementation
167 impl<T> TestTrait1 for GenericStruct<T, i32> {
168 fn trait_function() {}
171 // Implementation based on associated type
174 fn trait_function3();
176 impl TestTrait3 for TestStruct1 {
177 type AssocType = usize;
178 fn trait_function3() {}
180 impl<T: TestTrait3> TestTrait3 for GenericStruct<T, T::AssocType> {
181 type AssocType = T::AssocType;
182 fn trait_function3() {}
185 // Generic trait implementation with const generics
186 impl<T, const N: usize> TestTrait1 for GenericStruct<[T; N], f32> {
187 fn trait_function() {}
191 fn generic_func<T>(value: T) -> T {
192 // Closure in a generic function
193 let closure = || { TestStruct1 };
199 fn const_generic_fn_bool<const C: bool>() {}
200 fn const_generic_fn_non_int<const C: ()>() {}
201 fn const_generic_fn_signed_int<const C: i64>() {}
202 fn const_generic_fn_unsigned_int<const C: u32>() {}