E.g. Messages like this: /home/john/dlang/dmd-2.091.1/linux/bin64/../../src/phobos/std/range/primitives.d(175,38): Deprecation: alias byKeyValue this is deprecated - Iterate over .byKeyValue instead. with no further information How am I supposed to know where I am doing the wrong thing? Sure, I can use -de, but that has a fatal flaw: compilation stops after the first deprecation. So if I can't fix that one for some reason, I can never get to the rest.
In this case, the deprecation seems actually caused by a template-constraint Which should evaluate the symbol in a speculative context. We could keep track of context I guess ...
Example code: ``` import std.stdio; struct Foo { pure nothrow @nogc @safe: deprecated string toString() const { return "Hello"; } int value; } void main () { Foo f; writeln(f); } ``` Currently this prints: ``` std/format.d(3921): Deprecation: function foo.Foo.toString is deprecated std/format.d(4053): Deprecation: function foo.Foo.toString is deprecated ``` We would like it to print something similar to how template instantiation failures are printed, that is: ``` std/format.d(4053): Deprecation: function foo.Foo.toString is deprecated std/format.d(4430): instantiated from here: formatObject!(LockingTextWriter, Foo, char) std/format.d(1875): instantiated from here: formatValueImpl!(LockingTextWriter, Foo, char) std/format.d(576): instantiated from here: formatValue!(LockingTextWriter, Foo, char) std/stdio.d(1565): instantiated from here: formattedWrite!(LockingTextWriter, char, Foo) std/stdio.d(3927): instantiated from here: write!(Foo, char) foo.d(15): instantiated from here: writeln!(Foo) ```
@Geod24 created dlang/dmd pull request #11839 "Fix 20916 - Print trace for deprecations triggered inside templates" fixing this issue: - Fix 20916 - Print trace for deprecations triggered inside templates https://github.com/dlang/dmd/pull/11839
*** Issue 21176 has been marked as a duplicate of this issue. ***
dlang/dmd pull request #11839 "Fix 20916 - Print trace for deprecations triggered inside templates" was merged into master: - 5a86b8dcac2f2e483fbe4ce6264d1238ef6833e6 by Geod24: Fix 20916 - Print trace for deprecations triggered inside templates https://github.com/dlang/dmd/pull/11839