Commit 2eb9d5c
authored
# Objective
If you try to add an object to the hashmap that is not capable of
hashing, the program panics. For easier debugging, the type for that
object should be included in the error message.
Fixes #13646.
## Solution
initially i tried calling std::any::type_name_of_val. this had the
problem that it would print something like dyn Box<dyn Reflect>, not
helpful. But since these objects all implement Reflect, i used
Reflect::type_path() instead. Previously, the error message was part of
a constant called HASH_ERROR. i changed that to a macro called
hash_error to print the type of that object more easily
## Testing
i adapted the unit test reflect_map_no_hash to expect the type in that
panic aswell
since this is my first contribution, please let me know if i have done
everything properly
1 parent fb3a560 commit 2eb9d5c
2 files changed
+18
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
756 | 756 | | |
757 | 757 | | |
758 | 758 | | |
759 | | - | |
| 759 | + | |
760 | 760 | | |
761 | 761 | | |
762 | 762 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
198 | 207 | | |
199 | 208 | | |
200 | 209 | | |
| |||
233 | 242 | | |
234 | 243 | | |
235 | 244 | | |
236 | | - | |
| 245 | + | |
237 | 246 | | |
238 | 247 | | |
239 | 248 | | |
240 | 249 | | |
241 | 250 | | |
242 | | - | |
| 251 | + | |
243 | 252 | | |
244 | 253 | | |
245 | 254 | | |
| |||
285 | 294 | | |
286 | 295 | | |
287 | 296 | | |
288 | | - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
289 | 301 | | |
290 | 302 | | |
291 | 303 | | |
| |||
302 | 314 | | |
303 | 315 | | |
304 | 316 | | |
305 | | - | |
| 317 | + | |
306 | 318 | | |
307 | 319 | | |
308 | 320 | | |
| |||
0 commit comments