Fix printing of GenericMemory

This makes it no longer error, a cleverer display can be worked out in
the future.
This commit is contained in:
TEC 2024-04-12 16:36:25 +08:00
parent 7dbce9529e
commit 1305239f01
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
2 changed files with 3 additions and 1 deletions

View File

@ -87,6 +87,7 @@ function supertypeinfo(io::IO, type::Type)
end
function memorylayout(io::IO, type::DataType)
hassizeof(type) || return
si = structinfo(type)
!isempty(si) || return
memstep = memstep = gcd((getfield.(si, :size), getfield.(si, :contentsize)) |>
@ -95,7 +96,7 @@ function memorylayout(io::IO, type::DataType)
bars = AnnotatedString[]
descs = AnnotatedString[]
for (; i, size, contentsize, ispointer) in si
size == 0 && continue
size <= 0 && continue
color = FACE_CYCLE[i % length(FACE_CYCLE) + 1]
width = max(2, memscale * size÷memstep)
fsize, funits = humansize(size)

View File

@ -12,6 +12,7 @@ end
function hassizeof(type::Type)
!isconcretetype(type) && return false
type <: GenericMemory && return false
type in (Symbol, String, Core.SimpleVector) && return false
true
end