From df2e72d113e9dccef9f90c69b045cba37c0739a0 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Tue, 11 Oct 2016 11:40:43 +0200 Subject: [PATCH 01/13] Style fix: add whitespace after if/while --- std/algorithm/mutation.d | 4 ++-- std/experimental/ndslice/slice.d | 2 +- std/typecons.d | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/std/algorithm/mutation.d b/std/algorithm/mutation.d index a7193005c8c..9fd60d9b00c 100644 --- a/std/algorithm/mutation.d +++ b/std/algorithm/mutation.d @@ -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; diff --git a/std/experimental/ndslice/slice.d b/std/experimental/ndslice/slice.d index da69c3cdc25..d6bcc75afe8 100644 --- a/std/experimental/ndslice/slice.d +++ b/std/experimental/ndslice/slice.d @@ -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)]; diff --git a/std/typecons.d b/std/typecons.d index 06e47c6389e..809f85cc5bc 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -860,9 +860,9 @@ template Tuple(Specs...) { import std.array : empty; auto names = [fieldNames]; - foreach(ref n; names) + foreach (ref n; names) if (!n.empty) - if(auto p = n in translate) + if (auto p = n in translate) n = *p; return names; }())); @@ -881,7 +881,7 @@ template Tuple(Specs...) return this.rename!(aliasSeqOf!( { auto names = [fieldNames]; - foreach(k, v; translate) + foreach (k, v; translate) names[k] = v; return names; }())); From c5ba7c7d0bd90a6c55c213fe69c3d05f5e18dfd8 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Tue, 11 Oct 2016 11:43:03 +0200 Subject: [PATCH 02/13] Style fix: Add whitespace between import colon --- std/algorithm/setops.d | 8 ++++---- std/algorithm/sorting.d | 2 +- std/experimental/allocator/building_blocks/free_tree.d | 4 ++-- std/typecons.d | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/std/algorithm/setops.d b/std/algorithm/setops.d index 0d855925e7d..016d93104dd 100644 --- a/std/algorithm/setops.d +++ b/std/algorithm/setops.d @@ -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; } @@ -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); @@ -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); diff --git a/std/algorithm/sorting.d b/std/algorithm/sorting.d index 4b845854581..95375bc722e 100644 --- a/std/algorithm/sorting.d +++ b/std/algorithm/sorting.d @@ -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); diff --git a/std/experimental/allocator/building_blocks/free_tree.d b/std/experimental/allocator/building_blocks/free_tree.d index 3e17a516378..aa5d0150016 100644 --- a/std/experimental/allocator/building_blocks/free_tree.d +++ b/std/experimental/allocator/building_blocks/free_tree.d @@ -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) { diff --git a/std/typecons.d b/std/typecons.d index 809f85cc5bc..8764754a5ad 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -843,7 +843,7 @@ template Tuple(Specs...) if (is(typeof(translate) : V[K], V, K) && isSomeString!V && (isSomeString!K || is(K : size_t))) { - import std.range: ElementType; + import std.range : ElementType; static if (isSomeString!(ElementType!(typeof(translate.keys)))) { { From 1ca4d31e21fa4c4e7aebbee64fa1fee86f4a20a8 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Tue, 11 Oct 2016 11:45:41 +0200 Subject: [PATCH 03/13] Style fix: package wide std.algorithm imports --- std/algorithm/sorting.d | 2 +- unittest.d | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/std/algorithm/sorting.d b/std/algorithm/sorting.d index 95375bc722e..ceeb2c2755b 100644 --- a/std/algorithm/sorting.d +++ b/std/algorithm/sorting.d @@ -1562,7 +1562,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); diff --git a/unittest.d b/unittest.d index 8b129df5be1..cfd69a0f6df 100644 --- a/unittest.d +++ b/unittest.d @@ -70,7 +70,8 @@ int main(string[] args) uint ranseed = std.random.unpredictableSeed; thisTid; int[] a; - import std.algorithm : sort, reverse; + import std.algorithm.sorting : sort; + import std.algorithm.mutation : reverse; reverse(a); // adi sort(a); // qsort Clock.currTime(); // datetime From 6f1690f6b1ffd3520c0bb9b95bba34842b44ab84 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Tue, 11 Oct 2016 11:47:54 +0200 Subject: [PATCH 04/13] Style fix: enforce allman style --- std/algorithm/sorting.d | 3 ++- std/regex/internal/tests2.d | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/std/algorithm/sorting.d b/std/algorithm/sorting.d index ceeb2c2755b..5348254a872 100644 --- a/std/algorithm/sorting.d +++ b/std/algorithm/sorting.d @@ -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? { diff --git a/std/regex/internal/tests2.d b/std/regex/internal/tests2.d index 5aaa360e185..3a09083522a 100644 --- a/std/regex/internal/tests2.d +++ b/std/regex/internal/tests2.d @@ -147,7 +147,8 @@ unittest //issue 4574 //empty successful match still advances the input string[] pres, posts, hits; - foreach (m; matchFn("abcabc", regex("","g"))) { + foreach (m; matchFn("abcabc", regex("","g"))) + { pres ~= m.pre; posts ~= m.post; assert(m.hit.empty); @@ -248,7 +249,8 @@ unittest auto w2 = ["", "abc", "de", "fg", "hi"]; uint cnt; - foreach (e; sp2) { + foreach (e; sp2) + { assert(w2[cnt++] == e); } assert(equal(sp2, w2)); From 64217c89652856158a85ed55a20935b82314741c Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Tue, 11 Oct 2016 11:53:57 +0200 Subject: [PATCH 05/13] Style fix: specify/remove local imports --- std/algorithm/sorting.d | 2 +- std/regex/internal/backtracking.d | 1 - std/regex/internal/bitnfa.d | 12 ++++++------ std/regex/internal/ir.d | 1 - 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/std/algorithm/sorting.d b/std/algorithm/sorting.d index 5348254a872..d04d8d032f3 100644 --- a/std/algorithm/sorting.d +++ b/std/algorithm/sorting.d @@ -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))); } diff --git a/std/regex/internal/backtracking.d b/std/regex/internal/backtracking.d index fb3b357ec67..767662a3c2b 100644 --- a/std/regex/internal/backtracking.d +++ b/std/regex/internal/backtracking.d @@ -259,7 +259,6 @@ template BacktrackingMatcher(bool CTregex) return val; else { - import std.stdio; if (atEnd) break; search(); diff --git a/std/regex/internal/bitnfa.d b/std/regex/internal/bitnfa.d index abc83090219..3cbc2be0a7d 100644 --- a/std/regex/internal/bitnfa.d +++ b/std/regex/internal/bitnfa.d @@ -673,8 +673,8 @@ version(unittest) { private void check(T)(string input, T re, size_t idx=uint.max, int line=__LINE__) { - import std.regex, std.conv; - import std.stdio; + import std.regex : regex; + import std.conv : text, to; auto rex = regex(re, "s"); auto m = make(rex); auto s = Input!char(input); @@ -688,8 +688,8 @@ version(unittest) { private void checkFail(T)(string input, T re, size_t idx=uint.max, int line=__LINE__) { - import std.regex, std.conv; - import std.stdio; + import std.regex : regex; + import std.conv : text, to; auto rex = regex(re, "s"); auto m = make(rex); auto s = Input!char(input); @@ -700,8 +700,8 @@ version(unittest) private void checkEmpty(T)(T re) { - import std.regex, std.conv; - import std.stdio; + import std.regex : regex; + import std.conv : to; auto rex = regex(re); auto m = BitNfa(rex); assert(m.empty, "Should be empty "~to!string(re)); diff --git a/std/regex/internal/ir.d b/std/regex/internal/ir.d index 7de14079189..3badf895c26 100644 --- a/std/regex/internal/ir.d +++ b/std/regex/internal/ir.d @@ -490,7 +490,6 @@ pure: @trusted void reverseBytecode()(Bytecode[] code) pure { - import std.typecons; Bytecode[] rev = new Bytecode[code.length]; uint revPc = cast(uint)rev.length; Stack!(Tuple!(uint, uint, uint)) stack; From 813be1fd1da7b9871a67cd7646d3f3ce20c5baa4 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Tue, 11 Oct 2016 11:54:30 +0200 Subject: [PATCH 06/13] Fix CircleCi: correctly enable style target --- circleci.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/circleci.sh b/circleci.sh index b793b3d3bc7..5023652b4f0 100755 --- a/circleci.sh +++ b/circleci.sh @@ -99,4 +99,5 @@ case $1 in install-deps) install_deps ;; coverage) coverage ;; setup-repos) setup_repos ;; + style) style ;; esac From 964c1e5e4784e69ee4ea102f36def5d481e1e86b Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Fri, 14 Oct 2016 08:57:33 +0200 Subject: [PATCH 07/13] Update Dscanner to v0.4.0-beta.1 --- posix.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posix.mak b/posix.mak index d275981692b..35c5b6ece60 100644 --- a/posix.mak +++ b/posix.mak @@ -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 From 5985eac870f5c39c59a110e83fd4cebd2cdd0772 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Fri, 21 Oct 2016 15:47:12 +0200 Subject: [PATCH 08/13] Fix DScanner version to a specific DMD release --- circleci.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/circleci.sh b/circleci.sh index 5023652b4f0..11021f2f8b7 100755 --- a/circleci.sh +++ b/circleci.sh @@ -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 @@ -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 } From 2c8166318b0f03d179d1ce50e7336e5c62e368f8 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Tue, 22 Nov 2016 21:11:30 +0100 Subject: [PATCH 09/13] Follow-up style fixes for November --- std/random.d | 11 ++++++----- std/regex/internal/parser.d | 2 +- std/signals.d | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/std/random.d b/std/random.d index 4651599e20a..6722d38e806 100644 --- a/std/random.d +++ b/std/random.d @@ -1834,7 +1834,7 @@ auto ref choice(Range, RandomGen = Random)(auto ref Range range, /// @safe unittest { - import std.algorithm : canFind; + import std.algorithm.searching : canFind; auto array = [1, 2, 3, 4, 5]; auto elem = choice(array); @@ -1851,7 +1851,7 @@ auto ref choice(Range, RandomGen = Random)(auto ref Range range, @safe unittest { - import std.algorithm : canFind; + import std.algorithm.searching : canFind; class MyTestClass { @@ -1864,7 +1864,7 @@ auto ref choice(Range, RandomGen = Random)(auto ref Range range, } MyTestClass[] testClass; - foreach(i; 0 .. 5) + foreach (i; 0 .. 5) { testClass ~= new MyTestClass(i); } @@ -1877,7 +1877,8 @@ auto ref choice(Range, RandomGen = Random)(auto ref Range range, unittest { - import std.algorithm : canFind, map; + import std.algorithm.searching : canFind; + import std.algorith.iteration : map; auto array = [1, 2, 3, 4, 5]; auto elemAddr = &choice(array); @@ -1914,7 +1915,7 @@ void randomShuffle(Range)(Range r) @safe unittest { - import std.algorithm; + import std.algorithm.sorting : sort; foreach (RandomGen; PseudoRngTypes) { // Also tests partialShuffle indirectly. diff --git a/std/regex/internal/parser.d b/std/regex/internal/parser.d index c81d7bf3181..fb9e440c907 100644 --- a/std/regex/internal/parser.d +++ b/std/regex/internal/parser.d @@ -1506,7 +1506,7 @@ pure: kickstart = new ShiftOr!Char(zis); if (kickstart.empty) { - if(!__ctfe) + if (!__ctfe) kickstart = new BitMatcher!Char(zis); if (kickstart.empty) kickstart = null; diff --git a/std/signals.d b/std/signals.d index ebf4f239d65..95c0bc97485 100644 --- a/std/signals.d +++ b/std/signals.d @@ -193,7 +193,8 @@ mixin template Signal(T1...) } } } - else { + else + { for (size_t i = 0; i < slots_idx; ) { if (slots[i].ptr == slot.ptr && From b82ae35fd75795face95c6456957238abf43e7e5 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Tue, 22 Nov 2016 21:53:16 +0100 Subject: [PATCH 10/13] Use void for auto function without return statement --- std/algorithm/iteration.d | 2 +- std/array.d | 10 ++-- std/csv.d | 2 +- std/datetime.d | 77 +++++++++++++--------------- std/experimental/allocator/package.d | 4 +- std/experimental/ndslice/slice.d | 2 +- std/range/package.d | 26 +++++----- std/regex/internal/shiftor.d | 2 +- std/uni.d | 6 +-- 9 files changed, 62 insertions(+), 69 deletions(-) diff --git a/std/algorithm/iteration.d b/std/algorithm/iteration.d index 58298117cdb..95620a63dbe 100644 --- a/std/algorithm/iteration.d +++ b/std/algorithm/iteration.d @@ -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) diff --git a/std/array.d b/std/array.d index 21b4148f774..f495532807b 100644 --- a/std/array.d +++ b/std/array.d @@ -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); } @@ -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"); @@ -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"); @@ -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"); @@ -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; diff --git a/std/csv.d b/std/csv.d index 335d9a0f8b4..4958d089c90 100644 --- a/std/csv.d +++ b/std/csv.d @@ -732,7 +732,7 @@ auto csvReader(Contents = string, return text.empty; } - auto popFront() + void popFront() { text.popFront(); } diff --git a/std/datetime.d b/std/datetime.d index 2191f80b498..29211bf3030 100644 --- a/std/datetime.d +++ b/std/datetime.d @@ -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) @@ -34071,7 +34069,7 @@ version(StdDdoc) } -------------------- - which is functionally equivalent to + which is functionally equivalent to -------------------- { @@ -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. diff --git a/std/experimental/allocator/package.d b/std/experimental/allocator/package.d index 992f4869509..03123733334 100644 --- a/std/experimental/allocator/package.d +++ b/std/experimental/allocator/package.d @@ -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); }(); @@ -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); diff --git a/std/experimental/ndslice/slice.d b/std/experimental/ndslice/slice.d index d6bcc75afe8..2b6957c3706 100644 --- a/std/experimental/ndslice/slice.d +++ b/std/experimental/ndslice/slice.d @@ -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; diff --git a/std/range/package.d b/std/range/package.d index 36335649eb4..730db8bc69f 100644 --- a/std/range/package.d +++ b/std/range/package.d @@ -262,12 +262,12 @@ if (isBidirectionalRange!(Unqual!Range)) static if (hasAssignableElements!R) { - @property auto front(ElementType!R val) + @property void front(ElementType!R val) { source.back = val; } - @property auto back(ElementType!R val) + @property void back(ElementType!R val) { source.front = val; } @@ -539,7 +539,7 @@ body static if (hasAssignableElements!R) { - @property auto front(ElementType!R val) + @property void front(ElementType!R val) { source.front = val; } @@ -574,7 +574,7 @@ body static if (hasAssignableElements!R) { - @property auto back(ElementType!R val) + @property void back(ElementType!R val) { eliminateSlackElements(); source.back = val; @@ -1911,7 +1911,7 @@ if (isInputRange!(Unqual!Range) && static if (hasAssignableElements!R) /// ditto - @property auto front(ElementType!R v) + @property void front(ElementType!R v) { assert(!empty, "Attempting to assign to the front of an empty " @@ -1999,7 +1999,7 @@ if (isInputRange!(Unqual!Range) && static if (hasAssignableElements!R) { /// ditto - @property auto back(ElementType!R v) + @property void back(ElementType!R v) { // This has to return auto instead of void because of Bug 4706. assert(!empty, @@ -3364,7 +3364,7 @@ struct Cycle(R) static if (hasAssignableElements!R) { /// ditto - @property auto front(ElementType!R val) + @property void front(ElementType!R val) { _original[_index] = val; } @@ -3400,7 +3400,7 @@ struct Cycle(R) static if (hasAssignableElements!R) { /// ditto - auto opIndexAssign(ElementType!R val, size_t n) + void opIndexAssign(ElementType!R val, size_t n) { _original[(n + _index) % _original.length] = val; } @@ -5811,7 +5811,7 @@ struct FrontTransversal(Ror, static if (hasAssignableElements!RangeType) { - @property auto front(ElementType val) + @property void front(ElementType val) { _input.front.front = val; } @@ -5868,7 +5868,7 @@ struct FrontTransversal(Ror, static if (hasAssignableElements!RangeType) { - @property auto back(ElementType val) + @property void back(ElementType val) { _input.back.front = val; } @@ -6127,7 +6127,7 @@ struct Transversal(Ror, /// Ditto static if (hasAssignableElements!InnerRange) { - @property auto front(E val) + @property void front(E val) { _input.front[_n] = val; } @@ -6185,7 +6185,7 @@ struct Transversal(Ror, /// Ditto static if (hasAssignableElements!InnerRange) { - @property auto back(E val) + @property void back(E val) { _input.back[_n] = val; } @@ -8851,7 +8851,7 @@ public: } /++ +/ - auto opAssign(typeof(null) rhs) + void opAssign(typeof(null) rhs) { _range = null; } diff --git a/std/regex/internal/shiftor.d b/std/regex/internal/shiftor.d index 48bfebfebe8..0a549f49911 100644 --- a/std/regex/internal/shiftor.d +++ b/std/regex/internal/shiftor.d @@ -531,7 +531,7 @@ unittest assert(kick.length == length, text(C.stringof, " == ", kick.length)); return kick; } - auto searches(C)(const (C)[] source, ShiftOr!C kick, uint[] results...) + void searches(C)(const (C)[] source, ShiftOr!C kick, uint[] results...) { auto inp = Input!C(source); foreach (r; results) diff --git a/std/uni.d b/std/uni.d index dadd0f9454f..20d1c94b3f7 100644 --- a/std/uni.d +++ b/std/uni.d @@ -2701,7 +2701,7 @@ private: //may break sorted property - but we need std.sort to access it //hence package protection attribute - package @property auto front(CodepointInterval val) + package @property void front(CodepointInterval val) { slice[start] = val.a; slice[start+1] = val.b; @@ -2715,7 +2715,7 @@ private: } //ditto about package - package @property auto back(CodepointInterval val) + package @property void back(CodepointInterval val) { slice[end-2] = val.a; slice[end-1] = val.b; @@ -2739,7 +2739,7 @@ private: } //ditto about package - package auto opIndexAssign(CodepointInterval val, size_t idx) + package void opIndexAssign(CodepointInterval val, size_t idx) { slice[start+idx*2] = val.a; slice[start+idx*2+1] = val.b; From 55898ead31a439a05c10e720c6cd6cfb545f3fce Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Tue, 22 Nov 2016 21:53:36 +0100 Subject: [PATCH 11/13] Disable check for auto functions without return statement --- .dscanner.ini | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.dscanner.ini b/.dscanner.ini index 6df94523d36..a443acc00c9 100644 --- a/.dscanner.ini +++ b/.dscanner.ini @@ -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" From f0c5a9fad63b693e489cd9024d501c0be5a391b4 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Thu, 8 Dec 2016 01:56:01 +0100 Subject: [PATCH 12/13] Follow-up style fixes for December --- std/algorithm/searching.d | 6 +++--- std/parallelism.d | 4 ++-- std/random.d | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/std/algorithm/searching.d b/std/algorithm/searching.d index 62a7d3ddf1b..4926334bcee 100644 --- a/std/algorithm/searching.d +++ b/std/algorithm/searching.d @@ -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); @@ -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") diff --git a/std/parallelism.d b/std/parallelism.d index ae268a0ef7a..24e56d2dca2 100644 --- a/std/parallelism.d +++ b/std/parallelism.d @@ -43,13 +43,13 @@ module std.parallelism; /// unittest { - import std.algorithm : map; + import std.algorithm.iteration : map; import std.range : iota; import std.math : approxEqual; import std.parallelism : taskPool; // Parallel reduce can be combined with - // std.algorithm.map to interesting effect. + // std.algorithm.iteration.map to interesting effect. // The following example (thanks to Russel Winder) // calculates pi by quadrature using // std.algorithm.map and TaskPool.reduce. diff --git a/std/random.d b/std/random.d index 6722d38e806..6f6d414d7b0 100644 --- a/std/random.d +++ b/std/random.d @@ -1878,7 +1878,7 @@ auto ref choice(Range, RandomGen = Random)(auto ref Range range, unittest { import std.algorithm.searching : canFind; - import std.algorith.iteration : map; + import std.algorithm.iteration : map; auto array = [1, 2, 3, 4, 5]; auto elemAddr = &choice(array); From 0e9f16ebe936a6daa31b0f2c36e9043744ec6f1f Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Thu, 8 Dec 2016 13:05:54 +0100 Subject: [PATCH 13/13] Reenable style checking of std/conv.d --- posix.mak | 2 +- std/conv.d | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/posix.mak b/posix.mak index 35c5b6ece60..a3b1705e8b2 100644 --- a/posix.mak +++ b/posix.mak @@ -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 diff --git a/std/conv.d b/std/conv.d index 069723f77fd..4a3449a0773 100644 --- a/std/conv.d +++ b/std/conv.d @@ -1262,7 +1262,7 @@ body return cast(T)buffer[index .. $].dup; } - import std.array; + import std.array : array; switch (radix) { case 10: @@ -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;