Add support for macro expansion in rustdoc source code pages by GuillaumeGomez · Pull Request #137229 · rust-lang/rust (original) (raw)

Because it would force to duplicate all the common code. For example in:

func(arg, macro!(blabla), arg3);

Only macro!(blabla) will be different, so it's not interesting to duplicate all the rest. Instead, we put the original code in a span, the expanded one in another and then we can simply switch them based on the status of the checked property of the input. I'm also not a big fan of our current details approach as it requires more JS to be working fully as expected but it's a debate for another time.