Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit d7b99e9

Browse files
wilzbachthewilsonator
authored andcommitted
Make deprecation warnings compile errors (#1982)
* Make deprecation warnings compile errors * Fix Issue 18530 - don't use the deprecated delete in the runtime * Mark deprecated FracSec unittests * Remove deprecated delete from core.sync.event * Add cast(int) to arraop to retain the deprecated int promotion behavior * Workaround Issue 19789: add a copy of _assertThrown
1 parent 7edd250 commit d7b99e9

5 files changed

Lines changed: 20 additions & 9 deletions

File tree

posix.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ ifeq (solaris,$(OS))
7777
endif
7878

7979
# Set DFLAGS
80-
UDFLAGS:=-conf= -Isrc -Iimport -w -dip1000 -preview=fieldwise $(MODEL_FLAG) $(PIC) $(OPTIONAL_COVERAGE)
80+
UDFLAGS:=-conf= -Isrc -Iimport -w -de -dip1000 -preview=fieldwise $(MODEL_FLAG) $(PIC) $(OPTIONAL_COVERAGE)
8181
ifeq ($(BUILD),debug)
8282
UDFLAGS += -g -debug
8383
DFLAGS:=$(UDFLAGS)

src/core/internal/arrayop.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ template typeCheck(bool fail, T, Args...)
141141
{
142142
alias UT = Args[idx - 1];
143143
enum op = Args[idx][1 .. $];
144-
static if (is(typeof((UT a) => mixin(op ~ " a")) RT == return))
144+
static if (is(typeof((UT a) => mixin(op ~ "cast(int) a")) RT == return))
145145
alias typeCheck = typeCheck!(fail, T, Args[0 .. idx - 1], RT, Args[idx + 1 .. $]);
146146
else static if (fail)
147147
static assert(0, "Unary `" ~ op ~ "` not supported for type `" ~ UT.stringof ~ "`.");
@@ -271,7 +271,7 @@ string scalarExp(Args...)()
271271
else static if (isUnaryOp(arg))
272272
{
273273
auto op = arg[0] == 'u' ? arg[1 .. $] : arg;
274-
stack[$ - 1] = op ~ stack[$ - 1];
274+
stack[$ - 1] = op ~ "cast(int)"~ stack[$ - 1];
275275
}
276276
else static if (arg == "=")
277277
{

src/core/sync/event.d

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ unittest
302302
{
303303
import core.thread, core.atomic;
304304

305-
auto event = new Event(true, false);
305+
scope event = new Event(true, false);
306306
int numThreads = 10;
307307
shared int numRunning = 0;
308308

@@ -326,6 +326,4 @@ unittest
326326
assert(numRunning == numThreads);
327327

328328
assert(MonoTime.currTime - start < 5.dur!"seconds");
329-
330-
delete event;
331329
}

src/core/time.d

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3615,12 +3615,25 @@ public:
36153615
return FracSec(hnsecs);
36163616
}
36173617

3618-
unittest
3618+
deprecated unittest
36193619
{
36203620
assert(FracSec.from!"msecs"(0) == FracSec(0));
36213621
assert(FracSec.from!"usecs"(0) == FracSec(0));
36223622
assert(FracSec.from!"hnsecs"(0) == FracSec(0));
36233623

3624+
// workaround for https://issues.dlang.org/show_bug.cgi?id=19789
3625+
void _assertThrown(T : Throwable = Exception, E)
3626+
(lazy E expression,
3627+
string msg = null)
3628+
{
3629+
bool thrown = false;
3630+
try
3631+
expression();
3632+
catch (T t)
3633+
thrown = true;
3634+
assert(thrown, "No exception was thrown.");
3635+
}
3636+
36243637
foreach (sign; [1, -1])
36253638
{
36263639
_assertThrown!TimeException(from!"msecs"(1000 * sign));

src/rt/lifetime.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ extern (C) void _d_delarray_t(void[]* p, const TypeInfo_Struct ti)
11801180
}
11811181
}
11821182

1183-
unittest
1183+
deprecated unittest
11841184
{
11851185
__gshared size_t countDtor = 0;
11861186
struct S
@@ -2567,7 +2567,7 @@ unittest
25672567

25682568
// test struct finalizers
25692569
debug(SENTINEL) {} else
2570-
unittest
2570+
deprecated unittest
25712571
{
25722572
__gshared int dtorCount;
25732573
static struct S1

0 commit comments

Comments
 (0)