Skip to content

Commit 12f7bb5

Browse files
authored
specialize show of : to make reshape trimmable (#59598)
I also noticed that the standard Base.show_type_name appears to be trimmable so we don't need the override. We might still want it for code size, but probably not a big deal.
1 parent bb51d56 commit 12f7bb5

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

base/essentials.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,10 @@ struct Colon <: Function
10541054
end
10551055
const (:) = Colon()
10561056

1057+
function show(io::IO, ::Colon)
1058+
show_type_name(io, Colon.name)
1059+
print(io, "()")
1060+
end
10571061

10581062
"""
10591063
Val(c)

contrib/juliac/juliac-trim-base.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ end
7777
print(io, T.var.name)
7878
end
7979
end
80-
show_type_name(io::IO, tn::Core.TypeName) = print(io, tn.name)
8180
# this function is not `--trim`-compatible if it resolves to a Varargs{...} specialization
8281
# and since it only has 1-argument methods this happens too often by default (just 2-3 args)
8382
setfield!(typeof(throw_eachindex_mismatch_indices).name, :max_args, Int32(5), :monotonic)

test/trimming/trimmability.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,7 @@ function @main(args::Vector{String})::Cint
4848
catch
4949
end
5050

51+
Base.donotdelete(reshape([1,2,3],:,1,1))
52+
5153
return 0
5254
end

0 commit comments

Comments
 (0)