Commit 2730c6e
authored
Remove panic from code gen of an enum's FromReflect derive. (#24068)
# Objective
- I noticed this while reviewing #24048. Our current FromReflect derive
macro adds a panic for cases when a PartialReflect-ed enum includes a
variant we weren't expecting. This can happen for a few reasons, e.g., a
variant of the enum has been removed. In any case, **crashing the
program** is not the correct answer, since we already have an
appropriate response to a failed conversion: just return None!
## Solution
- Return None instead of panicking.
I also checked if there are any other panics, and it looks like none in
the codegen. The only remaining panics have to do with some auto
registration file stuff, which seems appropriate to panic on.
## Testing
- Added a unit test.1 parent 4b77775 commit 2730c6e
2 files changed
Lines changed: 24 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1720 | 1720 | | |
1721 | 1721 | | |
1722 | 1722 | | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
1723 | 1746 | | |
1724 | 1747 | | |
1725 | 1748 | | |
| |||
0 commit comments