rustdoc: use smaller number of colors to distinguish items by jsha · Pull Request #91480 · rust-lang/rust (original) (raw)
Good point about macros, particularly that not all macros are function-like, so styling as functions doesn't necessarily make sense. I've restored macros to having their own color. It was nice having just four colors, but since the primary motivation here is to make method signatures less distracting, and macros don't contribute to that problem, I think that's okay.
I think we should only have different colors for things that could be confused in the search page.
I think we rely too much on colors in the search page to distinguish types. If distinguishing types is important (and I think it is), we should put the type as text in the search results. That way it's accessible to colorblind people, and also understandable to people who haven't figured out what the colors mean (and it helps learn what the colors mean). But that's a change for another day. :-)
Since the only things that can have the same name must be in different namespaces, that suggests that we should have one color per namespace (value namespace, type ns, macro ns).
I like in theory the idea of mapping color distinctions onto a language concept (namespaces). This PR actually is pretty close to that. One difference: We still distinguish traits vs (enums, structs, unions), even though traits are also in the type namespace. I think the distinction between traits and other types is valuable and I'd like to keep it. Is there a specific change you'd like to make so colors align better with namespaces?