From 5ee7d6bc5383de0e49d49051dfe23c85cb9fa0f3 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Tue, 30 May 2023 19:45:40 +0000 Subject: [PATCH] Allow building deprecated modules without deprecation warnings The compiler issues a deprecation warning only on a "non-deprecated" -> "deprecated" transition. As such, building or testing Dub packages which have deprecated modules when a dub_test_root.d file needs to be generated will cause deprecation warnings. This in turn makes it impossible to use `buildRequirements "disallowDeprecations"` in this situation. Fix this by simply making the auto-generated root module (dub_test_root) deprecated. As it is the compiler's entry point, the module itself will not cause a deprecation warning, and it importing deprecating modules will not cause deprecation warnings (as there is no longer a transition of deprecation state). --- source/dub/project.d | 1 + test/issue2650-deprecated-modules/.no_build | 0 test/issue2650-deprecated-modules/.no_run | 0 test/issue2650-deprecated-modules/dub.sdl | 3 +++ test/issue2650-deprecated-modules/source/test.d | 1 + 5 files changed, 5 insertions(+) create mode 100644 test/issue2650-deprecated-modules/.no_build create mode 100644 test/issue2650-deprecated-modules/.no_run create mode 100644 test/issue2650-deprecated-modules/dub.sdl create mode 100644 test/issue2650-deprecated-modules/source/test.d diff --git a/source/dub/project.d b/source/dub/project.d index 98d311e16..65c9192f3 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -1970,6 +1970,7 @@ public class SelectedVersions { /// The template code from which the test runner is generated private immutable TestRunnerTemplate = q{ +deprecated // allow silently using deprecated symbols module dub_test_root; import std.typetuple; diff --git a/test/issue2650-deprecated-modules/.no_build b/test/issue2650-deprecated-modules/.no_build new file mode 100644 index 000000000..e69de29bb diff --git a/test/issue2650-deprecated-modules/.no_run b/test/issue2650-deprecated-modules/.no_run new file mode 100644 index 000000000..e69de29bb diff --git a/test/issue2650-deprecated-modules/dub.sdl b/test/issue2650-deprecated-modules/dub.sdl new file mode 100644 index 000000000..4e1619859 --- /dev/null +++ b/test/issue2650-deprecated-modules/dub.sdl @@ -0,0 +1,3 @@ +name "issue2650" +targetType "sourceLibrary" +buildRequirements "disallowDeprecations" diff --git a/test/issue2650-deprecated-modules/source/test.d b/test/issue2650-deprecated-modules/source/test.d new file mode 100644 index 000000000..896365be8 --- /dev/null +++ b/test/issue2650-deprecated-modules/source/test.d @@ -0,0 +1 @@ +deprecated module test;