The problem is not at the tokenizing and parsing level, where the overhead of including comments is modest.
The problem is that comments can be anywhere whitespace is allowed, so use of the parse tree has to constantly look for and ignore comments while trying to find what it really wants to find. That would be a continual sand in the gears. Since doc comments show up in only specific places, and container doc comments in only one place, keeps a slot for them when present and always ignoring that slot is not going to pose the same problems.
So rendering (I’m looking at this code for the first time, but presumably for document generation? Edit: zig fmt
looks like) needs to find whitespace which is comments, to put the comments back.
These are almost certainly the right tradeoffs. It also makes life more difficult for someone who wants to do ‘magic string’ things using the Zig parser, and while that’s a mixed bag, magic strings in comments is not a good habit to get into. I do hope Zig gets some annotation capability which isn’t magic string comments at some point, because well, magic string comments are the alternative, and they’re Bad, actually.