Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dscanner.ini
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,11 @@ auto_ref_assignment_check="disabled" ; FIXME
incorrect_infinite_range_check="enabled"
; Checks for asserts that are always true
useless_assert_check="skip-unittest"
; Check for uses of the old-style alias syntax
alias_syntax_check="enabled"
; Checks for else if that should be else static if
static_if_else_check="enabled"
; Check for unclear lambda syntax
lambda_return_check="enabled"
; Check for auto function without return statement
auto_function_check = "disabled"
7 changes: 5 additions & 2 deletions circleci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -uexo pipefail

HOST_DMD_VER=2.068.2 # same as in dmd/src/posix.mak
DSCANNER_DMD_VER=2.071.2 # dscanner needs a more up-to-date version
CURL_USER_AGENT="CirleCI $(curl --version | head -n 1)"
N=2

Expand Down Expand Up @@ -75,8 +76,9 @@ setup_repos()
# verify style guide
style()
{
# load dmd to build dscanner
source "$(CURL_USER_AGENT=\"$CURL_USER_AGENT\" bash ~/dlang/install.sh dmd-$HOST_DMD_VER --activate)"
# dscanner needs a more up-to-date DMD version
source "$(CURL_USER_AGENT=\"$CURL_USER_AGENT\" bash ~/dlang/install.sh dmd-$DSCANNER_DMD_VER --activate)"

make -f posix.mak style
}

Expand All @@ -99,4 +101,5 @@ case $1 in
install-deps) install_deps ;;
coverage) coverage ;;
setup-repos) setup_repos ;;
style) style ;;
esac
4 changes: 2 additions & 2 deletions posix.mak
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ checkwhitespace: $(LIB)

../dscanner:
git clone https://github.com/Hackerpilot/Dscanner ../dscanner
git -C ../dscanner checkout tags/v0.4.0-alpha.8
git -C ../dscanner checkout tags/v0.4.0-beta.1
git -C ../dscanner submodule update --init --recursive

../dscanner/dsc: ../dscanner
Expand All @@ -510,7 +510,7 @@ style: ../dscanner/dsc

# at the moment libdparse has problems to parse some modules (->excludes)
@echo "Running DScanner"
../dscanner/dsc --config .dscanner.ini --styleCheck $$(find etc std -type f -name '*.d' | grep -vE 'std/traits.d|std/typecons.d|std/conv.d') -I.
../dscanner/dsc --config .dscanner.ini --styleCheck $$(find etc std -type f -name '*.d' | grep -vE 'std/traits.d|std/typecons.d') -I.

.PHONY : auto-tester-build
auto-tester-build: all checkwhitespace
Expand Down
2 changes: 1 addition & 1 deletion std/algorithm/iteration.d
Original file line number Diff line number Diff line change
Expand Up @@ -4586,7 +4586,7 @@ if (isInputRange!R && !isInfinite!R)
F[64] store = void;
size_t idx = 0;

auto collapseStore(T)(T k)
void collapseStore(T)(T k)
{
auto lastToKeep = idx - cast(uint)bsf(k+1);
while (idx > lastToKeep)
Expand Down
4 changes: 2 additions & 2 deletions std/algorithm/mutation.d
Original file line number Diff line number Diff line change
Expand Up @@ -737,13 +737,13 @@ void initializeAll(Range)(Range range)
{
for ( ; !range.empty ; range.popFront() )
{
static if(__traits(isStaticArray, T))
static if (__traits(isStaticArray, T))
{
// static array initializer only contains initialization
// for one element of the static array.
auto elemp = cast(void *)addressOf(range.front);
auto endp = elemp + T.sizeof;
while(elemp < endp)
while (elemp < endp)
{
memcpy(elemp, p.ptr, p.length);
elemp += p.length;
Expand Down
6 changes: 3 additions & 3 deletions std/algorithm/searching.d
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ if (isInputRange!InputRange &&
// If the haystack is a SortedRange we can use binary search to find the needle.
// Works only for the default find predicate and any SortedRange predicate.
// 8829 enhancement
import std.range: SortedRange;
import std.range : SortedRange;
static if (is(InputRange : SortedRange!TT, TT) && isDefaultPred)
{
auto lb = haystack.lowerBound(needle);
Expand Down Expand Up @@ -1822,8 +1822,8 @@ if (isRandomAccessRange!R1 && hasLength!R1 && hasSlicing!R1 && isBidirectionalRa
// of the first element of the needle in haystack.
// When it is found O(walklength(needle)) steps are performed.
// 8829 enhancement
import std.range;
import std.algorithm.comparison: mismatch;
import std.range : SortedRange;
import std.algorithm.comparison : mismatch;
static if (is(R1 == R2)
&& is(R1 : SortedRange!TT, TT)
&& pred == "a == b")
Expand Down
8 changes: 4 additions & 4 deletions std/algorithm/setops.d
Original file line number Diff line number Diff line change
Expand Up @@ -1298,8 +1298,8 @@ See_Also:
auto setUnion(alias less = "a < b", Rs...)
(Rs rs)
{
import std.algorithm.iteration: uniq;
import std.algorithm.sorting: merge;
import std.algorithm.iteration : uniq;
import std.algorithm.sorting : merge;
return merge!(less, Rs)(rs).uniq;
}

Expand Down Expand Up @@ -1330,7 +1330,7 @@ auto setUnion(alias less = "a < b", Rs...)
@safe unittest
{
// save
import std.range: dropOne;
import std.range : dropOne;
int[] a = [0, 1, 2];
int[] b = [0, 3];
auto arr = a.setUnion(b);
Expand All @@ -1353,7 +1353,7 @@ auto setUnion(alias less = "a < b", Rs...)
{
import std.algorithm.comparison : equal;
import std.internal.test.dummyrange;
import std.range: iota;
import std.range : iota;

auto dummyResult1 = [1, 1.5, 2, 3, 4, 5, 5.5, 6, 7, 8, 9, 10];
auto dummyResult2 = iota(1, 11);
Expand Down
9 changes: 5 additions & 4 deletions std/algorithm/sorting.d
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ if (isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range)
// Loop invariant
version(unittest)
{
import std.algorithm.searching;
import std.algorithm.searching : all;
assert(r[0 .. lo].all!(x => !lt(p, x)));
assert(r[hi + 1 .. r.length].all!(x => !lt(x, p)));
}
Expand Down Expand Up @@ -1216,7 +1216,7 @@ Merge!(less, Rs) merge(alias less = "a < b", Rs...)
@safe pure nothrow unittest
{
// save
import std.range: dropOne;
import std.range : dropOne;
int[] a = [1, 2];
int[] b = [0, 3];
auto arr = a.merge(b);
Expand Down Expand Up @@ -1506,7 +1506,8 @@ private void shortSort(alias less, Range)(Range r)
immutable maxJ = r.length - 2;
for (size_t i = r.length - 6; ; --i)
{
static if (is(typeof(() nothrow {
static if (is(typeof(() nothrow
{
auto t = r[0]; if (pred(t, r[0])) r[0] = r[0];
}))) // Can we afford to temporarily invalidate the array?
{
Expand Down Expand Up @@ -1562,7 +1563,7 @@ private void sort5(alias lt, Range)(Range r)
{
assert(r.length >= 5);

import std.algorithm : swapAt;
import std.algorithm.mutation : swapAt;

// 1. Sort first two pairs
if (lt(r[1], r[0])) r.swapAt(0, 1);
Expand Down
10 changes: 5 additions & 5 deletions std/array.d
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ if (isIterable!Range && !isNarrowString!Range && !isInfinite!Range)
struct Foo
{
int a;
auto opAssign(Foo foo)
void opAssign(Foo foo)
{
assert(0);
}
Expand Down Expand Up @@ -1055,7 +1055,7 @@ private template isInputRangeOrConvertible(E)
assert(test([1, 2, 3, 4], 2, 23, [1, 2, 23, 3, 4]));
assert(test([1, 2, 3, 4], 4, 24, [1, 2, 3, 4, 24]));

auto testStr(T, U)(string file = __FILE__, size_t line = __LINE__)
void testStr(T, U)(string file = __FILE__, size_t line = __LINE__)
{

auto l = to!T("hello");
Expand Down Expand Up @@ -2149,7 +2149,7 @@ T[] replace(T, Range)(T[] subject, size_t from, size_t to, Range stuff)
assert(replace(a, 2, 4, filter!"true"([5, 6, 7])) == [1, 2, 5, 6, 7]);
assert(a == [ 1, 2, 3, 4 ]);

auto testStr(T, U)(string file = __FILE__, size_t line = __LINE__)
void testStr(T, U)(string file = __FILE__, size_t line = __LINE__)
{

auto l = to!T("hello");
Expand Down Expand Up @@ -2370,7 +2370,7 @@ void replaceInPlace(T, Range)(ref T[] array, size_t from, size_t to, Range stuff
assert(test([1, 2, 3, 4], 0, 2, filter!"true"([5, 6, 7]), [5, 6, 7, 3, 4]));
assert(test([1, 2, 3, 4], 2, 4, filter!"true"([5, 6, 7]), [1, 2, 5, 6, 7]));

auto testStr(T, U)(string file = __FILE__, size_t line = __LINE__)
void testStr(T, U)(string file = __FILE__, size_t line = __LINE__)
{

auto l = to!T("hello");
Expand Down Expand Up @@ -3057,7 +3057,7 @@ if (isDynamicArray!A)
this.arr = arr;
}

auto opDispatch(string fn, Args...)(Args args) if (is(typeof(mixin("impl." ~ fn ~ "(args)"))))
void opDispatch(string fn, Args...)(Args args) if (is(typeof(mixin("impl." ~ fn ~ "(args)"))))
{
// we do it this way because we can't cache a void return
scope(exit) *this.arr = impl.data;
Expand Down
4 changes: 2 additions & 2 deletions std/conv.d
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ body
return cast(T)buffer[index .. $].dup;
}

import std.array;
import std.array : array;
switch (radix)
{
case 10:
Expand Down Expand Up @@ -5738,7 +5738,7 @@ if (hexData.isHexLiteral)
@safe nothrow pure
private auto hexStrImpl(String)(scope String hexData)
{
import std.ascii;
import std.ascii : isHexDigit;
alias C = Unqual!(ElementEncodingType!String);
C[] result;
result.length = hexData.length / 2;
Expand Down
2 changes: 1 addition & 1 deletion std/csv.d
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ auto csvReader(Contents = string,
return text.empty;
}

auto popFront()
void popFront()
{
text.popFront();
}
Expand Down
77 changes: 35 additions & 42 deletions std/datetime.d
Original file line number Diff line number Diff line change
Expand Up @@ -34052,17 +34052,15 @@ static int daysToDayOfWeek(DayOfWeek currDoW, DayOfWeek dow) @safe pure nothrow
}


version(StdDdoc)
{
/++
Function for starting to a stop watch time when the function is called
and stopping it when its return value goes out of scope and is destroyed.
/++
Function for starting to a stop watch time when the function is called
and stopping it when its return value goes out of scope and is destroyed.

When the value that is returned by this function is destroyed,
$(D func) will run. $(D func) is a unary function that takes a
$(REF TickDuration, core,time).
When the value that is returned by this function is destroyed,
$(D func) will run. $(D func) is a unary function that takes a
$(REF TickDuration, core,time).

Example:
Example:
--------------------
{
auto mt = measureTime!((TickDuration a)
Expand All @@ -34071,7 +34069,7 @@ version(StdDdoc)
}
--------------------

which is functionally equivalent to
which is functionally equivalent to

--------------------
{
Expand All @@ -34085,48 +34083,43 @@ version(StdDdoc)
}
--------------------

See_Also:
$(LREF benchmark)
+/
auto measureTime(alias func)();
}
else
See_Also:
$(LREF benchmark)
+/
@safe auto measureTime(alias func)()
if (isSafe!((){StopWatch sw; unaryFun!func(sw.peek());}))
{
@safe auto measureTime(alias func)()
if (isSafe!((){StopWatch sw; unaryFun!func(sw.peek());}))
struct Result
{
struct Result
private StopWatch _sw = void;
this(AutoStart as)
{
private StopWatch _sw = void;
this(AutoStart as)
{
_sw = StopWatch(as);
}
~this()
{
unaryFun!(func)(_sw.peek());
}
_sw = StopWatch(as);
}
~this()
{
unaryFun!(func)(_sw.peek());
}
return Result(Yes.autoStart);
}
return Result(Yes.autoStart);
}

auto measureTime(alias func)()
if (!isSafe!((){StopWatch sw; unaryFun!func(sw.peek());}))
auto measureTime(alias func)()
if (!isSafe!((){StopWatch sw; unaryFun!func(sw.peek());}))
{
struct Result
{
struct Result
private StopWatch _sw = void;
this(AutoStart as)
{
private StopWatch _sw = void;
this(AutoStart as)
{
_sw = StopWatch(as);
}
~this()
{
unaryFun!(func)(_sw.peek());
}
_sw = StopWatch(as);
}
~this()
{
unaryFun!(func)(_sw.peek());
}
return Result(Yes.autoStart);
}
return Result(Yes.autoStart);
}

// Verify Example.
Expand Down
4 changes: 2 additions & 2 deletions std/experimental/allocator/building_blocks/free_tree.d
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ unittest

unittest // issue 16506
{
import std.experimental.allocator.gc_allocator: GCAllocator;
import std.experimental.allocator.mallocator: Mallocator;
import std.experimental.allocator.gc_allocator : GCAllocator;
import std.experimental.allocator.mallocator : Mallocator;

static void f(ParentAllocator)(size_t sz)
{
Expand Down
4 changes: 2 additions & 2 deletions std/experimental/allocator/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ nothrow @safe @nogc unittest
import std.experimental.allocator.mallocator : Mallocator;
alias alloc = Mallocator.instance;

auto test(T, Args...)(auto ref Args args)
void test(T, Args...)(auto ref Args args)
{
auto k = alloc.make!T(args);
() @trusted { alloc.dispose(k); }();
Expand All @@ -607,7 +607,7 @@ nothrow @safe @nogc unittest

alias alloc = GCAllocator.instance;

auto test(T, Args...)(auto ref Args args)
void test(T, Args...)(auto ref Args args)
{
auto k = alloc.make!T(args);
(a) @trusted { a.dispose(k); }(alloc);
Expand Down
4 changes: 2 additions & 2 deletions std/experimental/ndslice/slice.d
Original file line number Diff line number Diff line change
Expand Up @@ -2195,7 +2195,7 @@ struct Slice(size_t _N, _Range)
$(BOLD Fully defined index)
+/
auto ref opIndex(size_t I)(size_t[I] _indexes...)
if(I && I <= N)
if (I && I <= N)
{
static if (I == PureN)
return _ptr[indexStride(_indexes)];
Expand Down Expand Up @@ -3080,7 +3080,7 @@ pure nothrow unittest
{
import std.experimental.ndslice.selection : iotaSlice;

auto fun(ref size_t x) { x *= 3; }
void fun(ref size_t x) { x *= 3; }

auto tensor = iotaSlice(8, 9, 10).slice;

Expand Down
Loading