Skip to content

Commit

Permalink
Allow building deprecated modules without deprecation warnings
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
CyberShadow authored and Geod24 committed Jan 11, 2024
1 parent ee0fe9c commit 5ee7d6b
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions source/dub/project.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions test/issue2650-deprecated-modules/dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name "issue2650"
targetType "sourceLibrary"
buildRequirements "disallowDeprecations"
1 change: 1 addition & 0 deletions test/issue2650-deprecated-modules/source/test.d
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deprecated module test;

0 comments on commit 5ee7d6b

Please sign in to comment.