Make dscanner happy again

This commit is contained in:
Matthias Klumpp 2019-06-07 22:08:34 +02:00
parent f5ca60b086
commit 56173c9358
4 changed files with 26 additions and 23 deletions

View File

@ -92,6 +92,9 @@ if ( !UseToHashMethod!T )
hash_t toHash() const @safe {
return 0;
}
bool opEquals(const A1 other) const @safe {
return other.toHash() == toHash();
}
}
assert(UseToHashMethod!A1);
@ -100,6 +103,9 @@ if ( !UseToHashMethod!T )
override hash_t toHash() const @safe {
return 0;
}
bool opEquals(const C0 other) const @safe {
return other.toHash() == toHash();
}
}
assert(UseToHashMethod!C0);
C0 c0 = new C0();

View File

@ -122,6 +122,10 @@ private bool keyEquals(K)(K a, K b)
{
return c == other.c;
}
override size_t toHash() const nothrow @safe
{
return c;
}
}
C a = new C(0);
C b = new C(1);
@ -845,7 +849,7 @@ struct HashMap(K, V, Allocator = Mallocator, bool GCRangesAllowed = true) {
assert("world" !in counter);
assert(counter["hello"] == 1);
assert(counter["should"] == 2);
assert(counter.length == words.length - 1);
assert(counter.length == cast(int)(words.length) - 1);
// clear counter
counter.clear;
assert(counter.length == 0);
@ -865,7 +869,7 @@ struct HashMap(K, V, Allocator = Mallocator, bool GCRangesAllowed = true) {
assert("world" !in counter);
assert(counter["hello"] == 1);
assert(counter["should"] == 2);
assert(counter.length == words.length - 1);
assert(counter.length == cast(int)(words.length) - 1);
// iterators
assert(counter.byKey.count == counter.byValue.count);
assert(words.all!(w => w in counter)); // all words are in table
@ -1262,7 +1266,6 @@ struct HashMap(K, V, Allocator = Mallocator, bool GCRangesAllowed = true) {
assert(v);
assert(*v == 1);
K k1 = new c(1);
V v1 = 1;
h.put(k0, v0);
assert(!keyEquals(k0, k1));
}
@ -1532,10 +1535,6 @@ struct HashMap(K, V, Allocator = Mallocator, bool GCRangesAllowed = true) {
{
return 2;
};
F three = function()
{
return 3;
};
F four = function()
{
return 4;
@ -1647,12 +1646,12 @@ unittest {
class C
{
int s;
bool opEquals(const C other) @safe @nogc
bool opEquals(const C other) const @safe @nogc
{
return s == other.s;
}
override hash_t toHash() @safe @nogc
override hash_t toHash() const @safe @nogc
{
return hash_function(s);
}
@ -1762,12 +1761,12 @@ unittest {
class C
{
int s;
bool opEquals(const C other) @nogc
bool opEquals(const C other) const @nogc
{
return s == other.s;
}
override hash_t toHash() @nogc
override hash_t toHash() const @nogc
{
return hash_function(s);
}
@ -1800,12 +1799,12 @@ unittest {
class C
{
int s;
bool opEquals(const C other) @safe
bool opEquals(const C other) const @safe
{
return s == other.s;
}
override hash_t toHash() @safe
override hash_t toHash() const @safe
{
return hash_function(s);
}

View File

@ -752,7 +752,7 @@ struct SList(T, Allocator = Mallocator, bool GCRangesAllowed = true) {
private {
_Node!T *current;
}
auto front() pure nothrow @safe @nogc @property {
auto front() inout pure nothrow @safe @nogc @property {
return &current.v;
}
void popFront() @safe @nogc nothrow {
@ -882,13 +882,13 @@ struct SList(T, Allocator = Mallocator, bool GCRangesAllowed = true) {
assert(!removed);
assert(l.length()==0);
auto l1 = SList!int();
foreach(i;0..10000) {
foreach(i;0..10_000) {
l1.insertBack(i);
}
while(l1.length) {
l1.popFront();
}
foreach(i;0..10000) {
foreach(i;0..10_000) {
l1.insertFront(i);
}
while(l1.length) {
@ -905,7 +905,7 @@ struct SList(T, Allocator = Mallocator, bool GCRangesAllowed = true) {
}
}
SList!C l2;
foreach(i;0..10000) {
foreach(i;0..10_000) {
l2.insertBack(new C(i));
}
while(l2.length) {
@ -933,7 +933,7 @@ struct SList(T, Allocator = Mallocator, bool GCRangesAllowed = true) {
assert(dlist.length == 0);
n1 = dlist.insert_first(1);
auto n2 = dlist.insert_last(2);
dlist.insert_last(2);
assert(dlist.length == 2);
dlist.move_to_tail(n1);
assert(dlist.head.payload == 2);
@ -1553,7 +1553,7 @@ struct CompressedList(T, Allocator = Mallocator, bool GCRangesAllowed = true)
assert(list.front == 99);
assert(list.back == 100);
auto p98 = list.insertFront(98);
auto p101 = list.insertBack(101);
list.insertBack(101);
() @trusted // * and remove for poiners is unsafe
{
assert(*p98 == 98);
@ -1585,7 +1585,7 @@ struct CompressedList(T, Allocator = Mallocator, bool GCRangesAllowed = true)
auto r = list.range();
while(!r.empty)
{
int v = r.front;
r.front;
r.popFront();
}
assert(list.empty);

View File

@ -29,9 +29,7 @@ def find_include_dirs(source_root):
incdirs = find_local_include_dirs(source_root)
incdirs.append(os.path.join(source_root, 'src'))
extra_inc = ['containers',
'stdx-allocator',
'glibd-2']
extra_inc = ['glibd-2']
for d in extra_inc:
for inc_root in ['/usr/include/d/', '/usr/local/include/d/']: