inference: fix the ptrfree field check (#60214)
This should address the `# TODO` item in
https://github.com/JuliaLang/julia/pull/57550.
Unconditionally indexing `DataTypeFieldDesc(dt::DataType)[fidx]` will
error when `dt` has no layout because we define
```julia
struct DataTypeFieldDesc
dt::DataType
function DataTypeFieldDesc(dt::DataType)
dt.layout == C_NULL && throw(UndefRefError())
new(dt)
end
end
```
For all the `DataType`s I could find, they only had `dt.layout ==
C_NULL` if `!isconcretetype(dt)`, so maybe it would be preferable to
check if they're `!isconcretetype` rather than checking if `dt.layout ==
C_NULL`, but I figured it'd be safer to just mimic the validation logic
in `DataTypeFieldDesc` instead.
---------
Co-authored-by: Shuhei Kadowaki <aviatesk@gmail.com>
Co-authored-by: James Wrigley <JamesWrigley@users.noreply.github.com>