Fix an ICE with unsized structs and optimised enums

close #18353 

r?