mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 14:40:30 +03:00
Get rid of unused variables in std/algorithm
This commit is contained in:
parent
3d0d8188ca
commit
3a4f83577e
5 changed files with 38 additions and 21 deletions
|
@ -157,7 +157,7 @@ undocumented_declaration_check="-etc.c.curl,-etc.c.odbc.sql,-etc.c.odbc.sqlext,-
|
||||||
; Checks for unused labels
|
; Checks for unused labels
|
||||||
unused_label_check="-std.conv,-std.format,-std.internal.math.biguintx86,-std.regex.internal.thompson,-std.signals,-std.uni"
|
unused_label_check="-std.conv,-std.format,-std.internal.math.biguintx86,-std.regex.internal.thompson,-std.signals,-std.uni"
|
||||||
; Checks for unused variables and function parameters
|
; Checks for unused variables and function parameters
|
||||||
unused_variable_check="-std.algorithm.comparison,-std.algorithm.mutation,-std.algorithm.searching,-std.algorithm.setops,-std.algorithm.sorting,-std.array,-std.bigint,-std.bitmanip,-std.complex,-std.concurrency,-std.container,-std.container.array,-std.container.dlist,-std.container.rbtree,-std.container.slist,-std.conv,-std.csv,-std.datetime,-std.datetime.date,-std.datetime.interval,-std.datetime.stopwatch,-std.datetime.systime,-std.datetime.timezone,-std.digest.crc,-std.digest,-std.digest.md,-std.digest.murmurhash,-std.digest.ripemd,-std.digest.sha,-std.encoding,-std.exception,-std.experimental.allocator,-std.experimental.allocator.building_blocks.affix_allocator,-std.experimental.allocator.building_blocks.bitmapped_block,-std.experimental.allocator.building_blocks.bucketizer,-std.experimental.allocator.building_blocks.kernighan_ritchie,-std.experimental.allocator.building_blocks.stats_collector,-std.experimental.allocator.common,-std.experimental.allocator.gc_allocator,-std.experimental.allocator.mallocator,-std.experimental.allocator.typed,-std.experimental.checkedint,-std.experimental.logger.core,-std.experimental.typecons,-std.file,-std.format,-std.functional,-std.getopt,-std.internal.cstring,-std.internal.digest.sha_SSSE3,-std.internal.math.biguintcore,-std.internal.math.biguintx86,-std.internal.math.errorfunction,-std.internal.scopebuffer,-std.internal.test.dummyrange,-std.json,-std.math,-std.meta,-std.mmfile,-std.net.curl,-std.numeric,-std.parallelism,-std.process,-std.random,-std.range,-std.range.interfaces,-std.range.primitives,-std.regex.internal.backtracking,-std.regex.internal.tests,-std.regex.internal.thompson,-std.signals,-std.socket,-std.stdio,-std.string,-std.traits,-std.typecons,-std.uni,-std.uri,-std.utf,-std.uuid,-std.variant,-std.windows.registry,-std.xml,-std.zip,-std.zlib"
|
unused_variable_check="-std.algorithm.comparison,-std.array,-std.bigint,-std.bitmanip,-std.complex,-std.concurrency,-std.container,-std.container.array,-std.container.dlist,-std.container.rbtree,-std.container.slist,-std.conv,-std.csv,-std.datetime,-std.datetime.date,-std.datetime.interval,-std.datetime.stopwatch,-std.datetime.systime,-std.datetime.timezone,-std.digest.crc,-std.digest,-std.digest.md,-std.digest.murmurhash,-std.digest.ripemd,-std.digest.sha,-std.encoding,-std.exception,-std.experimental.allocator,-std.experimental.allocator.building_blocks.affix_allocator,-std.experimental.allocator.building_blocks.bitmapped_block,-std.experimental.allocator.building_blocks.bucketizer,-std.experimental.allocator.building_blocks.kernighan_ritchie,-std.experimental.allocator.building_blocks.stats_collector,-std.experimental.allocator.common,-std.experimental.allocator.gc_allocator,-std.experimental.allocator.mallocator,-std.experimental.allocator.typed,-std.experimental.checkedint,-std.experimental.logger.core,-std.experimental.typecons,-std.file,-std.format,-std.functional,-std.getopt,-std.internal.cstring,-std.internal.digest.sha_SSSE3,-std.internal.math.biguintcore,-std.internal.math.biguintx86,-std.internal.math.errorfunction,-std.internal.scopebuffer,-std.internal.test.dummyrange,-std.json,-std.math,-std.meta,-std.mmfile,-std.net.curl,-std.numeric,-std.parallelism,-std.process,-std.random,-std.range,-std.range.interfaces,-std.range.primitives,-std.regex.internal.backtracking,-std.regex.internal.tests,-std.regex.internal.thompson,-std.signals,-std.socket,-std.stdio,-std.string,-std.traits,-std.typecons,-std.uni,-std.uri,-std.utf,-std.uuid,-std.variant,-std.windows.registry,-std.xml,-std.zip,-std.zlib"
|
||||||
; Check for useless user defined initializers
|
; Check for useless user defined initializers
|
||||||
useless_initializer="+disabled"
|
useless_initializer="+disabled"
|
||||||
;useless_initializer="-etc.c.odbc.sqlext,-etc.c.zlib,-std.algorithm.iteration,-std.algorithm.mutation,-std.algorithm.searching,-std.algorithm.setops,-std.algorithm.sorting,-std.array,-std.bigint,-std.bitmanip,-std.compiler,-std.container.array,-std.container.dlist,-std.container.rbtree,-std.conv,-std.csv,-std.datetime.systime,-std.digest.md,-std.digest.murmurhash,-std.digest.ripemd,-std.encoding,-std.exception,-std.experimental.allocator,-std.experimental.allocator.building_blocks.bitmapped_block,-std.experimental.allocator.building_blocks.free_tree,-std.experimental.allocator.building_blocks.kernighan_ritchie,-std.experimental.allocator.common,-std.experimental.allocator.mallocator,-std.experimental.logger.core,-std.experimental.logger.multilogger,-std.file,-std.format,-std.functional,-std.getopt,-std.internal.cstring,-std.internal.digest.sha_SSSE3,-std.internal.math.biguintcore,-std.internal.math.biguintnoasm,-std.internal.math.biguintx86,-std.internal.math.gammafunction,-std.internal.test.dummyrange,-std.json,-std.math,-std.net.curl,-std.numeric,-std.parallelism,-std.path,-std.process,-std.random,-std.range,-std.range.interfaces,-std.range.primitives,-std.regex,-std.regex.internal.backtracking,-std.regex.internal.generator,-std.regex.internal.ir,-std.regex.internal.kickstart,-std.regex.internal.parser,-std.regex.internal.tests,-std.regex.internal.thompson,-std.signals,-std.socket,-std.stdio,-std.string,-std.uni,-std.uri,-std.utf,-std.uuid,-std.variant,-std.windows.registry,-std.windows.syserror,-std.xml,-std.zip,-std.zlib"
|
;useless_initializer="-etc.c.odbc.sqlext,-etc.c.zlib,-std.algorithm.iteration,-std.algorithm.mutation,-std.algorithm.searching,-std.algorithm.setops,-std.algorithm.sorting,-std.array,-std.bigint,-std.bitmanip,-std.compiler,-std.container.array,-std.container.dlist,-std.container.rbtree,-std.conv,-std.csv,-std.datetime.systime,-std.digest.md,-std.digest.murmurhash,-std.digest.ripemd,-std.encoding,-std.exception,-std.experimental.allocator,-std.experimental.allocator.building_blocks.bitmapped_block,-std.experimental.allocator.building_blocks.free_tree,-std.experimental.allocator.building_blocks.kernighan_ritchie,-std.experimental.allocator.common,-std.experimental.allocator.mallocator,-std.experimental.logger.core,-std.experimental.logger.multilogger,-std.file,-std.format,-std.functional,-std.getopt,-std.internal.cstring,-std.internal.digest.sha_SSSE3,-std.internal.math.biguintcore,-std.internal.math.biguintnoasm,-std.internal.math.biguintx86,-std.internal.math.gammafunction,-std.internal.test.dummyrange,-std.json,-std.math,-std.net.curl,-std.numeric,-std.parallelism,-std.path,-std.process,-std.random,-std.range,-std.range.interfaces,-std.range.primitives,-std.regex,-std.regex.internal.backtracking,-std.regex.internal.generator,-std.regex.internal.ir,-std.regex.internal.kickstart,-std.regex.internal.parser,-std.regex.internal.tests,-std.regex.internal.thompson,-std.signals,-std.socket,-std.stdio,-std.string,-std.uni,-std.uri,-std.utf,-std.uuid,-std.variant,-std.windows.registry,-std.windows.syserror,-std.xml,-std.zip,-std.zlib"
|
||||||
|
|
|
@ -520,6 +520,7 @@ $(HTTP sgi.com/tech/stl/copy_backward.html, STL's copy_backward'):
|
||||||
copy(arr1, arr2);
|
copy(arr1, arr2);
|
||||||
return 35;
|
return 35;
|
||||||
}();
|
}();
|
||||||
|
assert(v == 35);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,8 +606,10 @@ if ((isInputRange!Range && is(typeof(range.front = value)) ||
|
||||||
@nogc @safe unittest
|
@nogc @safe unittest
|
||||||
{
|
{
|
||||||
const(char)[] chars;
|
const(char)[] chars;
|
||||||
|
assert(chars.length == 0);
|
||||||
static assert(!__traits(compiles, fill(chars, 'c')));
|
static assert(!__traits(compiles, fill(chars, 'c')));
|
||||||
wstring wchars;
|
wstring wchars;
|
||||||
|
assert(wchars.length == 0);
|
||||||
static assert(!__traits(compiles, fill(wchars, wchar('c'))));
|
static assert(!__traits(compiles, fill(wchars, wchar('c'))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -929,6 +932,8 @@ if (is(Range == char[]) || is(Range == wchar[]))
|
||||||
assert(a[] == [char.init, char.init, char.init]);
|
assert(a[] == [char.init, char.init, char.init]);
|
||||||
string s;
|
string s;
|
||||||
assert(!__traits(compiles, s.initializeAll()));
|
assert(!__traits(compiles, s.initializeAll()));
|
||||||
|
assert(!__traits(compiles, s.initializeAll()));
|
||||||
|
assert(s.empty);
|
||||||
|
|
||||||
//Note: Cannot call uninitializedFill on narrow strings
|
//Note: Cannot call uninitializedFill on narrow strings
|
||||||
|
|
||||||
|
@ -1169,11 +1174,15 @@ pure nothrow @safe @nogc unittest
|
||||||
{
|
{
|
||||||
struct S
|
struct S
|
||||||
{
|
{
|
||||||
|
int a = 1;
|
||||||
@disable this(this);
|
@disable this(this);
|
||||||
~this() pure nothrow @safe @nogc {}
|
~this() pure nothrow @safe @nogc {}
|
||||||
}
|
}
|
||||||
S s1;
|
S s1;
|
||||||
|
s1.a = 2;
|
||||||
S s2 = move(s1);
|
S s2 = move(s1);
|
||||||
|
assert(s1.a == 1);
|
||||||
|
assert(s2.a == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void trustedMoveImpl(T)(ref T source, ref T target) @trusted
|
private void trustedMoveImpl(T)(ref T source, ref T target) @trusted
|
||||||
|
@ -1592,6 +1601,7 @@ pure nothrow @nogc @system unittest
|
||||||
Foo[3] dst = void;
|
Foo[3] dst = void;
|
||||||
|
|
||||||
auto res = moveEmplaceSome(src[], dst[]);
|
auto res = moveEmplaceSome(src[], dst[]);
|
||||||
|
assert(res.length == 2);
|
||||||
|
|
||||||
import std.algorithm.searching : all;
|
import std.algorithm.searching : all;
|
||||||
assert(src[0 .. 3].all!(e => e._ptr is null));
|
assert(src[0 .. 3].all!(e => e._ptr is null));
|
||||||
|
@ -2518,8 +2528,14 @@ if (isBlitAssignable!T && !is(typeof(lhs.proxySwap(rhs))))
|
||||||
assert(s2.y == [ 1, 2 ]);
|
assert(s2.y == [ 1, 2 ]);
|
||||||
|
|
||||||
// Immutables cannot be swapped:
|
// Immutables cannot be swapped:
|
||||||
immutable int imm1, imm2;
|
immutable int imm1 = 1, imm2 = 2;
|
||||||
static assert(!__traits(compiles, swap(imm1, imm2)));
|
static assert(!__traits(compiles, swap(imm1, imm2)));
|
||||||
|
|
||||||
|
int c = imm1 + 0;
|
||||||
|
int d = imm2 + 0;
|
||||||
|
swap(c, d);
|
||||||
|
assert(c == 2);
|
||||||
|
assert(d == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -2565,6 +2581,7 @@ if (isBlitAssignable!T && !is(typeof(lhs.proxySwap(rhs))))
|
||||||
|
|
||||||
// Const types cannot be swapped.
|
// Const types cannot be swapped.
|
||||||
const NoCopy const1, const2;
|
const NoCopy const1, const2;
|
||||||
|
assert(const1.n == 0 && const2.n == 0);
|
||||||
static assert(!__traits(compiles, swap(const1, const2)));
|
static assert(!__traits(compiles, swap(const1, const2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2598,9 +2615,14 @@ if (isBlitAssignable!T && !is(typeof(lhs.proxySwap(rhs))))
|
||||||
struct S
|
struct S
|
||||||
{
|
{
|
||||||
const int i;
|
const int i;
|
||||||
|
int i2 = 2;
|
||||||
|
int i3 = 3;
|
||||||
}
|
}
|
||||||
S s;
|
S s;
|
||||||
static assert(!__traits(compiles, swap(s, s)));
|
static assert(!__traits(compiles, swap(s, s)));
|
||||||
|
swap(s.i2, s.i3);
|
||||||
|
assert(s.i2 == 3);
|
||||||
|
assert(s.i3 == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@safe unittest
|
@safe unittest
|
||||||
|
@ -2616,6 +2638,7 @@ if (isBlitAssignable!T && !is(typeof(lhs.proxySwap(rhs))))
|
||||||
// 12024
|
// 12024
|
||||||
import std.datetime;
|
import std.datetime;
|
||||||
SysTime a, b;
|
SysTime a, b;
|
||||||
|
swap(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@system unittest // 9975
|
@system unittest // 9975
|
||||||
|
|
|
@ -1691,11 +1691,8 @@ if (isInputRange!InputRange &&
|
||||||
|
|
||||||
@safe pure nothrow unittest
|
@safe pure nothrow unittest
|
||||||
{
|
{
|
||||||
int[] a1 = [1, 2, 3];
|
|
||||||
assert(!find ([1, 2, 3], 2).empty);
|
assert(!find ([1, 2, 3], 2).empty);
|
||||||
assert(!find!((a,b)=>a == b)([1, 2, 3], 2).empty);
|
assert(!find!((a,b)=>a == b)([1, 2, 3], 2).empty);
|
||||||
ubyte[] a2 = [1, 2, 3];
|
|
||||||
ubyte b2 = 2;
|
|
||||||
assert(!find ([1, 2, 3], 2).empty);
|
assert(!find ([1, 2, 3], 2).empty);
|
||||||
assert(!find!((a,b)=>a == b)([1, 2, 3], 2).empty);
|
assert(!find!((a,b)=>a == b)([1, 2, 3], 2).empty);
|
||||||
}
|
}
|
||||||
|
@ -1707,21 +1704,13 @@ if (isInputRange!InputRange &&
|
||||||
{
|
{
|
||||||
foreach (E; AliasSeq!(char, wchar, dchar))
|
foreach (E; AliasSeq!(char, wchar, dchar))
|
||||||
{
|
{
|
||||||
R r1 = "hello world";
|
|
||||||
E e1 = 'w';
|
|
||||||
assert(find ("hello world", 'w') == "world");
|
assert(find ("hello world", 'w') == "world");
|
||||||
assert(find!((a,b)=>a == b)("hello world", 'w') == "world");
|
assert(find!((a,b)=>a == b)("hello world", 'w') == "world");
|
||||||
R r2 = "日c語";
|
|
||||||
E e2 = 'c';
|
|
||||||
assert(find ("日c語", 'c') == "c語");
|
assert(find ("日c語", 'c') == "c語");
|
||||||
assert(find!((a,b)=>a == b)("日c語", 'c') == "c語");
|
assert(find!((a,b)=>a == b)("日c語", 'c') == "c語");
|
||||||
R r3 = "0123456789";
|
|
||||||
E e3 = 'A';
|
|
||||||
assert(find ("0123456789", 'A').empty);
|
assert(find ("0123456789", 'A').empty);
|
||||||
static if (E.sizeof >= 2)
|
static if (E.sizeof >= 2)
|
||||||
{
|
{
|
||||||
R r4 = "hello world";
|
|
||||||
E e4 = 'w';
|
|
||||||
assert(find ("日本語", '本') == "本語");
|
assert(find ("日本語", '本') == "本語");
|
||||||
assert(find!((a,b)=>a == b)("日本語", '本') == "本語");
|
assert(find!((a,b)=>a == b)("日本語", '本') == "本語");
|
||||||
}
|
}
|
||||||
|
@ -1737,11 +1726,8 @@ if (isInputRange!InputRange &&
|
||||||
static assert(find("日本語", '本') == "本語");
|
static assert(find("日本語", '本') == "本語");
|
||||||
static assert(find([1, 2, 3], 2) == [2, 3]);
|
static assert(find([1, 2, 3], 2) == [2, 3]);
|
||||||
|
|
||||||
int[] a1 = [1, 2, 3];
|
|
||||||
static assert(find ([1, 2, 3], 2));
|
static assert(find ([1, 2, 3], 2));
|
||||||
static assert(find!((a,b)=>a == b)([1, 2, 3], 2));
|
static assert(find!((a,b)=>a == b)([1, 2, 3], 2));
|
||||||
ubyte[] a2 = [1, 2, 3];
|
|
||||||
ubyte b2 = 2;
|
|
||||||
static assert(find ([1, 2, 3], 2));
|
static assert(find ([1, 2, 3], 2));
|
||||||
static assert(find!((a,b)=>a == b)([1, 2, 3], 2));
|
static assert(find!((a,b)=>a == b)([1, 2, 3], 2));
|
||||||
}
|
}
|
||||||
|
@ -2145,6 +2131,7 @@ if (isForwardRange!R1 && isForwardRange!R2
|
||||||
|
|
||||||
@safe unittest
|
@safe unittest
|
||||||
{
|
{
|
||||||
|
import std.algorithm.comparison : equal;
|
||||||
// @@@BUG@@@ removing static below makes unittest fail
|
// @@@BUG@@@ removing static below makes unittest fail
|
||||||
static struct BiRange
|
static struct BiRange
|
||||||
{
|
{
|
||||||
|
@ -2157,6 +2144,7 @@ if (isForwardRange!R1 && isForwardRange!R2
|
||||||
void popBack() { return payload.popBack(); }
|
void popBack() { return payload.popBack(); }
|
||||||
}
|
}
|
||||||
auto r = BiRange([1, 2, 3, 10, 11, 4]);
|
auto r = BiRange([1, 2, 3, 10, 11, 4]);
|
||||||
|
assert(equal(find(r, [10, 11]), [10, 11, 4]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@safe unittest
|
@safe unittest
|
||||||
|
@ -2277,6 +2265,7 @@ private R1 simpleMindedFind(alias pred, R1, R2)(R1 haystack, scope R2 needle)
|
||||||
// If issue 7992 occurs, this will throw an exception from calling
|
// If issue 7992 occurs, this will throw an exception from calling
|
||||||
// popFront() on an empty range.
|
// popFront() on an empty range.
|
||||||
auto r = find(CustomString("a"), CustomString("b"));
|
auto r = find(CustomString("a"), CustomString("b"));
|
||||||
|
assert(r.empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4605,7 +4594,7 @@ if (isInputRange!Range)
|
||||||
|
|
||||||
@safe unittest // Issue 13124
|
@safe unittest // Issue 13124
|
||||||
{
|
{
|
||||||
import std.algorithm.comparison : among;
|
import std.algorithm.comparison : among, equal;
|
||||||
auto s = "hello how\nare you";
|
auto s = "hello how\nare you";
|
||||||
s.until!(c => c.among!('\n', '\r'));
|
assert(equal(s.until!(c => c.among!('\n', '\r')), "hello how"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1412,6 +1412,8 @@ setSymmetricDifference(alias less = "a < b", R1, R2)
|
||||||
|
|
||||||
@safe unittest // Issue 10460
|
@safe unittest // Issue 10460
|
||||||
{
|
{
|
||||||
|
import std.algorithm.comparison : equal;
|
||||||
|
|
||||||
int[] a = [1, 2];
|
int[] a = [1, 2];
|
||||||
double[] b = [2.0, 3.0];
|
double[] b = [2.0, 3.0];
|
||||||
int[] c = [2, 3];
|
int[] c = [2, 3];
|
||||||
|
@ -1423,6 +1425,9 @@ setSymmetricDifference(alias less = "a < b", R1, R2)
|
||||||
alias R2 = typeof(setSymmetricDifference(a, c));
|
alias R2 = typeof(setSymmetricDifference(a, c));
|
||||||
static assert(is(ElementType!R2 == int));
|
static assert(is(ElementType!R2 == int));
|
||||||
static assert(hasLvalueElements!R2);
|
static assert(hasLvalueElements!R2);
|
||||||
|
|
||||||
|
assert(equal(setSymmetricDifference(a, b), [1.0, 3.0]));
|
||||||
|
assert(equal(setSymmetricDifference(a, c), [1, 3]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/++
|
/++
|
||||||
|
|
|
@ -2823,6 +2823,7 @@ private template TimSortImpl(alias pred, R)
|
||||||
testSort(seed);
|
testSort(seed);
|
||||||
|
|
||||||
enum result = testSort(seed);
|
enum result = testSort(seed);
|
||||||
|
assert(result == true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@safe unittest
|
@safe unittest
|
||||||
|
@ -3118,11 +3119,10 @@ if (isRandomAccessRange!(Range) && hasLength!Range && hasSlicing!Range)
|
||||||
// Workaround for https://issues.dlang.org/show_bug.cgi?id=16528
|
// Workaround for https://issues.dlang.org/show_bug.cgi?id=16528
|
||||||
// Safety checks: enumerate all potentially unsafe generic primitives
|
// Safety checks: enumerate all potentially unsafe generic primitives
|
||||||
// then use a @trusted implementation.
|
// then use a @trusted implementation.
|
||||||
auto b = binaryFun!less(r[0], r[r.length - 1]);
|
binaryFun!less(r[0], r[r.length - 1]);
|
||||||
import std.algorithm.mutation : swapAt;
|
import std.algorithm.mutation : swapAt;
|
||||||
r.swapAt(size_t(0), size_t(0));
|
r.swapAt(size_t(0), size_t(0));
|
||||||
auto len = r.length;
|
static assert(is(typeof(r.length) == size_t));
|
||||||
static assert(is(typeof(len) == size_t));
|
|
||||||
pivotPartition!less(r, 0);
|
pivotPartition!less(r, 0);
|
||||||
}
|
}
|
||||||
bool useSampling = true;
|
bool useSampling = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue