Any function that is going to be built-in must have a full source in the .di file. Any function that will be used in CTFE should not only have a full source in the .di file, but the full source of every function that it uses - directly or indirectly, must be available to the compiler. In addition, due to the way the templates work, their full source must also be in the .di file (which is the same as the templates should be in the C ++ header files). Thus, there are a number of cases where you need the material to be in the .di file.
In what circumstances the compiler decides to remove the material or not, I do not know (except that the templates automatically fall into the .di files completely, because they should). It may vary depending on the current implementation of the compiler and what kind of optimization it does. But, at a minimum, he will have to go to small functional organs if he is going to make any insertion. Large functional bodies and bodies of small virtual functions (which in any case cannot be built-in) are likely to be removed. But your example gives a little non-virtual function, so dmd probably left it so that it could inline any calls. If you want to see dmd highlight a lot of things when creating a .di file, then you probably have to have great functions and / or use classes.
source share