Commit d1d9893
authored
Rollup merge of rust-lang#127748 - scottmcm:option_len, r=joboet
Use Option's discriminant as its size hint
I was looking at this in MIR after a question on discord, and noticed that it ends up with a switch in MIR (<https://rust.godbolt.org/z/3q4cYnnb3>), which it doesn't need because (as `Option::as_slice` uses) the discriminant is already the length.1 file changed
+17
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
770 | 770 | | |
771 | 771 | | |
772 | 772 | | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
773 | 780 | | |
774 | 781 | | |
775 | 782 | | |
| |||
812 | 819 | | |
813 | 820 | | |
814 | 821 | | |
815 | | - | |
| 822 | + | |
816 | 823 | | |
817 | 824 | | |
818 | 825 | | |
| |||
869 | 876 | | |
870 | 877 | | |
871 | 878 | | |
872 | | - | |
| 879 | + | |
873 | 880 | | |
874 | 881 | | |
875 | 882 | | |
| |||
2242 | 2249 | | |
2243 | 2250 | | |
2244 | 2251 | | |
2245 | | - | |
2246 | | - | |
2247 | | - | |
2248 | | - | |
| 2252 | + | |
| 2253 | + | |
2249 | 2254 | | |
2250 | 2255 | | |
2251 | 2256 | | |
| |||
2256 | 2261 | | |
2257 | 2262 | | |
2258 | 2263 | | |
2259 | | - | |
| 2264 | + | |
| 2265 | + | |
| 2266 | + | |
| 2267 | + | |
| 2268 | + | |
| 2269 | + | |
2260 | 2270 | | |
2261 | 2271 | | |
2262 | 2272 | | |
| |||
0 commit comments