Skip to content

Commit 08437c6

Browse files
authored
Merge pull request #6922 from WalterBright/rbtree-dip1000
std.container.rbtree: compile with -dip1000
2 parents 5fdc1aa + fc84e14 commit 08437c6

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

dip1000.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ aa[std.container.array]=-dip1000
9494
aa[std.container.binaryheap]=-dip1000
9595
aa[std.container.dlist]=-dip1000
9696
aa[std.container.package]=-dip1000
97-
aa[std.container.rbtree]=-dip25 # DROP
97+
aa[std.container.rbtree]=-dip25
9898
aa[std.container.slist]=-dip1000
9999
aa[std.container.util]=-dip25 # depends on rbtree and slist = -dip1000
100100

std/container/rbtree.d

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -879,15 +879,16 @@ if (is(typeof(binaryFun!less(T.init, T.init))))
879879
* Returns:
880880
* true if node was added
881881
*/
882-
private bool _add(Elem n)
882+
private bool _add(return Elem n)
883883
{
884884
Node result;
885885
static if (!allowDuplicates)
886886
bool added = true;
887887

888888
if (!_end.left)
889889
{
890-
_end.left = _begin = result = allocate(n);
890+
result = allocate(n);
891+
(() @trusted { _end.left = _begin = result; }) ();
891892
}
892893
else
893894
{
@@ -903,7 +904,8 @@ if (is(typeof(binaryFun!less(T.init, T.init))))
903904
//
904905
// add to right of new parent
905906
//
906-
newParent.left = result = allocate(n);
907+
result = allocate(n);
908+
(() @trusted { newParent.left = result; }) ();
907909
break;
908910
}
909911
}
@@ -924,7 +926,8 @@ if (is(typeof(binaryFun!less(T.init, T.init))))
924926
//
925927
// add to right of new parent
926928
//
927-
newParent.right = result = allocate(n);
929+
result = allocate(n);
930+
(() @trusted { newParent.right = result; }) ();
928931
break;
929932
}
930933
}
@@ -933,7 +936,6 @@ if (is(typeof(binaryFun!less(T.init, T.init))))
933936
if (_begin.left)
934937
_begin = _begin.left;
935938
}
936-
937939
static if (allowDuplicates)
938940
{
939941
result.setColor(_end);
@@ -944,8 +946,6 @@ if (is(typeof(binaryFun!less(T.init, T.init))))
944946
}
945947
else
946948
{
947-
import std.typecons : Tuple;
948-
949949
if (added)
950950
{
951951
++_length;
@@ -1144,12 +1144,14 @@ if (is(typeof(binaryFun!less(T.init, T.init))))
11441144
{
11451145
int x;
11461146

1147+
@safe:
1148+
11471149
this(int init_x)
11481150
{
11491151
x = init_x;
11501152
}
11511153

1152-
size_t toHash() const @safe nothrow
1154+
size_t toHash() const nothrow
11531155
{
11541156
return typeid(x).getHash(&x) ^ 0xF0F0_F0F0;
11551157
}
@@ -1272,7 +1274,9 @@ if (is(typeof(binaryFun!less(T.init, T.init))))
12721274
*
12731275
* Complexity: $(BIGOH m * log(n))
12741276
*/
1275-
size_t stableInsert(Stuff)(Stuff stuff) if (isInputRange!Stuff && isImplicitlyConvertible!(ElementType!Stuff, Elem))
1277+
size_t stableInsert(Stuff)(scope Stuff stuff)
1278+
if (isInputRange!Stuff &&
1279+
isImplicitlyConvertible!(ElementType!Stuff, Elem))
12761280
{
12771281
size_t result = 0;
12781282
static if (allowDuplicates)
@@ -1529,7 +1533,7 @@ assert(equal(rbt[], [5]));
15291533
}
15301534

15311535
/++ Ditto +/
1532-
size_t removeKey(U)(U[] elems)
1536+
size_t removeKey(U)(scope U[] elems)
15331537
if (isImplicitlyConvertible!(U, Elem))
15341538
{
15351539
immutable lenBefore = length;
@@ -1777,7 +1781,7 @@ assert(equal(rbt[], [5]));
17771781
* Check the tree for validity. This is called after every add or remove.
17781782
* This should only be enabled to debug the implementation of the RB Tree.
17791783
*/
1780-
void check()
1784+
void check() @trusted
17811785
{
17821786
//
17831787
// check implementation of the tree

0 commit comments

Comments
 (0)