diff --git a/etc/c/curl.d b/etc/c/curl.d index 7ac597c9fc0..f5c709f0c07 100644 --- a/etc/c/curl.d +++ b/etc/c/curl.d @@ -35,8 +35,8 @@ module etc.c.curl; -import core.stdc.time; import core.stdc.config; +import core.stdc.time; import std.socket; // linux diff --git a/std/algorithm/comparison.d b/std/algorithm/comparison.d index 4642c86f810..13901b554c1 100644 --- a/std/algorithm/comparison.d +++ b/std/algorithm/comparison.d @@ -63,8 +63,8 @@ import std.functional; // : unaryFun, binaryFun; import std.range.primitives; import std.traits; // FIXME -import std.typecons; // : tuple, Tuple, Flag, Yes; import std.meta : allSatisfy; +import std.typecons; // : Flag, Tuple, tuple, Yes; /** Find $(D value) _among $(D values), returning the 1-based index @@ -825,8 +825,8 @@ template equal(alias pred = "a == b") /// @safe unittest { - import std.math : approxEqual; import std.algorithm.comparison : equal; + import std.math : approxEqual; int[] a = [ 1, 2, 4, 3 ]; assert(!equal(a, a[1..$])); @@ -851,8 +851,8 @@ range of range (of range...) comparisons. +/ @safe unittest { - import std.range : iota, chunks; import std.algorithm.comparison : equal; + import std.range : chunks, iota; assert(equal!(equal!equal)( [[[0, 1], [2, 3]], [[4, 5], [6, 7]]], iota(0, 8).chunks(2).chunks(2) @@ -862,9 +862,9 @@ range of range (of range...) comparisons. @safe unittest { import std.algorithm.iteration : map; - import std.math : approxEqual; import std.internal.test.dummyrange : ReferenceForwardRange, ReferenceInputRange, ReferenceInfiniteForwardRange; + import std.math : approxEqual; // various strings assert(equal("æøå", "æøå")); //UTF8 vs UTF8 @@ -925,7 +925,7 @@ range of range (of range...) comparisons. @safe pure unittest { - import std.utf : byChar, byWchar, byDchar; + import std.utf : byChar, byDchar, byWchar; assert(equal("æøå".byChar, "æøå")); assert(equal("æøå", "æøå".byChar)); @@ -1069,8 +1069,8 @@ private: cols = c; if (_matrix.length < rc) { - import core.stdc.stdlib : realloc; import core.exception : onOutOfMemoryError; + import core.stdc.stdlib : realloc; const nbytes = mulu(rc, _matrix[0].sizeof, overflow); if (overflow) assert(0); auto m = cast(CostType *) realloc(_matrix.ptr, nbytes); diff --git a/std/algorithm/internal.d b/std/algorithm/internal.d index 35ba503e3cc..5e0cfd68bcb 100644 --- a/std/algorithm/internal.d +++ b/std/algorithm/internal.d @@ -21,7 +21,7 @@ version(unittest) package string[] rndstuff(T : string)() { - import std.random : Random, unpredictableSeed, uniform; + import std.random : Random, uniform, unpredictableSeed; static Random rnd; static bool first = true; @@ -46,7 +46,7 @@ version(unittest) package int[] rndstuff(T : int)() { - import std.random : Random, unpredictableSeed, uniform; + import std.random : Random, uniform, unpredictableSeed; static Random rnd; static bool first = true; diff --git a/std/algorithm/iteration.d b/std/algorithm/iteration.d index 46284815e6b..2c4402ade51 100644 --- a/std/algorithm/iteration.d +++ b/std/algorithm/iteration.d @@ -165,7 +165,7 @@ if (isBidirectionalRange!Range) @safe unittest { import std.algorithm.comparison : equal; - import std.stdio, std.range; + import std.range, std.stdio; import std.typecons : tuple; ulong counter = 0; @@ -682,8 +682,8 @@ private struct MapResult(alias fun, Range) @safe unittest { import std.algorithm.comparison : equal; - import std.internal.test.dummyrange; import std.ascii : toUpper; + import std.internal.test.dummyrange; import std.range; import std.typecons : tuple; @@ -1959,8 +1959,8 @@ version(none) // this example requires support for non-equivalence relations /* FIXME: pure @safe nothrow*/ @system unittest { import std.algorithm.comparison : equal; - import std.typecons : tuple; import std.range.primitives; + import std.typecons : tuple; // Grouping by particular attribute of each element: auto range = @@ -2296,8 +2296,8 @@ if (isInputRange!RoR && isInputRange!(ElementType!RoR) @system unittest { import std.algorithm.comparison : equal; - import std.range.primitives; import std.range.interfaces; + import std.range.primitives; // joiner() should work for non-forward ranges too. auto r = inputRangeObject(["abc", "def"]); assert(equal(joiner(r, "xyz"), "abcxyzdef")); @@ -2607,8 +2607,8 @@ if (isInputRange!RoR && isInputRange!(ElementType!RoR)) @safe unittest { - import std.algorithm.internal : algoFormat; import std.algorithm.comparison : equal; + import std.algorithm.internal : algoFormat; struct TransientRange { @@ -2657,8 +2657,8 @@ if (isInputRange!RoR && isInputRange!(ElementType!RoR)) // Issue 8061 @system unittest { - import std.range.interfaces; import std.conv : to; + import std.range.interfaces; auto r = joiner([inputRangeObject("ab"), inputRangeObject("cd")]); assert(isForwardRange!(typeof(r))); @@ -2748,7 +2748,7 @@ if (fun.length >= 1) alias binfuns = staticMap!(binaryFun, fun); static if (fun.length > 1) - import std.typecons : tuple, isTuple; + import std.typecons : isTuple, tuple; /++ No-seed version. The first element of $(D r) is used as the seed's value. @@ -3219,7 +3219,7 @@ if (fun.length >= 1) // Sum all elements with explicit seed assert(arr.fold!((a, b) => a + b)(6) == 21); - import std.algorithm.comparison : min, max; + import std.algorithm.comparison : max, min; import std.typecons : tuple; // Compute minimum and maximum at the same time @@ -3848,9 +3848,9 @@ if (is(typeof(binaryFun!pred(r.front, s)) : bool) @safe unittest { - import std.internal.test.dummyrange; import std.algorithm; import std.array : array; + import std.internal.test.dummyrange; import std.range : retro; assert(equal(splitter("hello world", ' '), [ "hello", "", "world" ])); @@ -4095,8 +4095,8 @@ if (is(typeof(binaryFun!pred(r.front, s.front)) : bool) @safe unittest { import std.algorithm.comparison : equal; - import std.conv : text; import std.array : split; + import std.conv : text; auto s = ",abc, de, fg,hi,"; auto sp0 = splitter(s, ','); @@ -4360,8 +4360,8 @@ private struct SplitterResult(alias isTerminator, Range) @safe unittest { - import std.algorithm.internal : algoFormat; import std.algorithm.comparison : equal; + import std.algorithm.internal : algoFormat; import std.internal.test.dummyrange; void compare(string sentence, string[] witness) @@ -4395,8 +4395,8 @@ private struct SplitterResult(alias isTerminator, Range) @safe unittest { - import std.algorithm.internal : algoFormat; import std.algorithm.comparison : equal; + import std.algorithm.internal : algoFormat; import std.range; struct Entry @@ -4560,10 +4560,10 @@ if (isSomeChar!C) @safe unittest { - import std.algorithm.internal : algoFormat; import std.algorithm.comparison : equal; - import std.conv : text; + import std.algorithm.internal : algoFormat; import std.array : split; + import std.conv : text; // Check consistency: // All flavors of split should produce the same results @@ -4953,8 +4953,8 @@ if (isInputRange!Range && is(typeof(binaryFun!pred(r.front, r.front)) == bool)) /// @safe unittest { - import std.algorithm.mutation : copy; import std.algorithm.comparison : equal; + import std.algorithm.mutation : copy; int[] arr = [ 1, 2, 2, 2, 2, 3, 4, 4, 4, 5 ]; assert(equal(uniq(arr), [ 1, 2, 3, 4, 5 ][])); @@ -5125,8 +5125,8 @@ if (isRandomAccessRange!Range && hasLength!Range) /// this(Range r) { - import std.range : iota; import std.array : array; + import std.range : iota; this._r = r; _state = r.length ? new size_t[r.length-1] : null; diff --git a/std/algorithm/mutation.d b/std/algorithm/mutation.d index f1aa9ee4769..23923242122 100644 --- a/std/algorithm/mutation.d +++ b/std/algorithm/mutation.d @@ -78,7 +78,7 @@ T2=$(TR $(TDNW $(LREF $1)) $(TD $+)) module std.algorithm.mutation; import std.range.primitives; -import std.traits : isArray, isBlitAssignable, isNarrowString, Unqual, isSomeChar; +import std.traits : isArray, isBlitAssignable, isNarrowString, isSomeChar, Unqual; // FIXME import std.typecons; // : tuple, Tuple; @@ -148,8 +148,8 @@ if (isInputRange!InputRange && isForwardRange!ForwardRange) private size_t bringToFrontImpl(InputRange, ForwardRange)(InputRange front, ForwardRange back) if (isInputRange!InputRange && isForwardRange!ForwardRange) { - import std.range : take, Take; import std.array : sameHead; + import std.range : take, Take; enum bool sameHeadExists = is(typeof(front.sameHead(back))); size_t result; @@ -279,7 +279,7 @@ Unicode integrity is not preserved: { import std.algorithm.comparison : equal; import std.conv : text; - import std.random : Random, unpredictableSeed, uniform; + import std.random : Random, uniform, unpredictableSeed; // a more elaborate test { @@ -845,7 +845,7 @@ See_Also: void initializeAll(Range)(Range range) if (isInputRange!Range && hasLvalueElements!Range && hasAssignableElements!Range) { - import core.stdc.string : memset, memcpy; + import core.stdc.string : memcpy, memset; import std.traits : hasElaborateAssign, isDynamicArray; alias T = ElementType!Range; @@ -901,7 +901,7 @@ if (is(Range == char[]) || is(Range == wchar[])) /// @system unittest { - import core.stdc.stdlib : malloc, free; + import core.stdc.stdlib : free, malloc; struct S { @@ -1095,8 +1095,8 @@ pure nothrow @safe @nogc unittest @safe unittest { - import std.traits; import std.exception : assertCTFEable; + import std.traits; assertCTFEable!((){ Object obj1 = new Object; @@ -1209,8 +1209,8 @@ private T moveImpl(T)(ref T source) @safe unittest { - import std.traits; import std.exception : assertCTFEable; + import std.traits; assertCTFEable!((){ Object obj1 = new Object; @@ -2835,7 +2835,7 @@ if (isInputRange!Range && hasLvalueElements!Range && is(typeof(range.front = val /// nothrow @system unittest { - import core.stdc.stdlib : malloc, free; + import core.stdc.stdlib : free, malloc; auto s = (cast(int*) malloc(5 * int.sizeof))[0 .. 5]; uninitializedFill(s, 42); diff --git a/std/algorithm/package.d b/std/algorithm/package.d index fab759773df..d357a4f0ef2 100644 --- a/std/algorithm/package.d +++ b/std/algorithm/package.d @@ -190,8 +190,8 @@ module std.algorithm; public import std.algorithm.comparison; public import std.algorithm.iteration; public import std.algorithm.mutation; -public import std.algorithm.setops; public import std.algorithm.searching; +public import std.algorithm.setops; public import std.algorithm.sorting; static import std.functional; diff --git a/std/algorithm/searching.d b/std/algorithm/searching.d index 79f79597ab1..72a6f341d39 100644 --- a/std/algorithm/searching.d +++ b/std/algorithm/searching.d @@ -1164,8 +1164,8 @@ if (isInputRange!R && @safe unittest { import std.algorithm.iteration : filterBidirectional; - import std.meta : AliasSeq; import std.conv : to; + import std.meta : AliasSeq; foreach (S; AliasSeq!(char[], wchar[], dchar[], string, wstring, dstring)) { @@ -1631,8 +1631,8 @@ if (isInputRange!InputRange && { import std.algorithm.comparison : equal; import std.container : SList; - import std.range.primitives : empty; import std.range; + import std.range.primitives : empty; auto arr = assumeSorted!"a < b"([1, 2, 4, 4, 4, 4, 5, 6, 9]); assert(find(arr, 4) == assumeSorted!"a < b"([4, 4, 4, 4, 5, 6, 9])); @@ -1956,8 +1956,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 : SortedRange; import std.algorithm.comparison : mismatch; + import std.range : SortedRange; static if (is(R1 == R2) && is(R1 : SortedRange!TT, TT) && pred == "a == b") @@ -2383,8 +2383,8 @@ if (Ranges.length > 1 && is(typeof(startsWith!pred(haystack, needles)))) @safe unittest { - import std.algorithm.internal : rndstuff; import std.algorithm.comparison : equal; + import std.algorithm.internal : rndstuff; import std.meta : AliasSeq; import std.range : retro; diff --git a/std/algorithm/setops.d b/std/algorithm/setops.d index 4b23446d4e3..b9e384b3764 100644 --- a/std/algorithm/setops.d +++ b/std/algorithm/setops.d @@ -41,10 +41,10 @@ module std.algorithm.setops; import std.range.primitives; // FIXME -import std.functional; // : unaryFun, binaryFun; +import std.functional; // : binaryFun, unaryFun; import std.traits; // FIXME -import std.meta; // : AliasSeq, staticMap, allSatisfy, anySatisfy; +import std.meta; // : AliasSeq, allSatisfy, anySatisfy, staticMap; import std.algorithm.sorting; // : Merge; import std.typecons : No; @@ -82,13 +82,13 @@ auto cartesianProduct(R1, R2)(R1 range1, R2 range2) if (!allSatisfy!(isForwardRange, R1, R2) || anySatisfy!(isInfinite, R1, R2)) { - import std.algorithm.iteration : map, joiner; + import std.algorithm.iteration : joiner, map; static if (isInfinite!R1 && isInfinite!R2) { static if (isForwardRange!R1 && isForwardRange!R2) { - import std.range : zip, repeat, take, chain, sequence; + import std.range : chain, repeat, sequence, take, zip; // This algorithm traverses the cartesian product by alternately // covering the right and bottom edges of an increasing square area @@ -107,13 +107,13 @@ if (!allSatisfy!(isForwardRange, R1, R2) || } else static if (isInputRange!R1 && isForwardRange!R2 && !isInfinite!R2) { - import std.range : zip, repeat; + import std.range : repeat, zip; return joiner(map!((ElementType!R1 a) => zip(repeat(a), range2.save)) (range1)); } else static if (isInputRange!R2 && isForwardRange!R1 && !isInfinite!R1) { - import std.range : zip, repeat; + import std.range : repeat, zip; return joiner(map!((ElementType!R2 a) => zip(range1.save, repeat(a))) (range2)); } @@ -247,9 +247,9 @@ if (!allSatisfy!(isForwardRange, R1, R2) || @safe unittest { - import std.algorithm.searching : canFind; import std.algorithm.comparison : equal; import std.algorithm.iteration : map; + import std.algorithm.searching : canFind; import std.typecons : tuple; import std.range; diff --git a/std/algorithm/sorting.d b/std/algorithm/sorting.d index 384a9c00ec8..7cf9e5c41b4 100644 --- a/std/algorithm/sorting.d +++ b/std/algorithm/sorting.d @@ -75,14 +75,14 @@ T2=$(TR $(TDNW $(LREF $1)) $(TD $+)) */ module std.algorithm.sorting; -import std.typecons : Flag; import std.algorithm.mutation : SwapStrategy; import std.functional; // : unaryFun, binaryFun; import std.range.primitives; +import std.typecons : Flag; // FIXME +import std.meta; // : allSatisfy; import std.range; // : SortedRange; import std.traits; -import std.meta; // : allSatisfy; /** Specifies whether the output of certain algorithm is desired in sorted @@ -116,7 +116,7 @@ void completeSort(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable, if (hasLength!(RandomAccessRange2) && hasSlicing!(RandomAccessRange2)) { import std.algorithm.mutation : bringToFront; - import std.range : chain, assumeSorted; + import std.range : assumeSorted, chain; // Probably this algorithm can be optimized by using in-place // merge auto lhsOriginal = lhs.release(); @@ -518,10 +518,10 @@ if (ss != SwapStrategy.stable && isInputRange!Range && hasSwappableElements!Rang /// @safe unittest { + import std.algorithm.mutation : SwapStrategy; import std.algorithm.searching : count, find; import std.conv : text; import std.range.primitives : empty; - import std.algorithm.mutation : SwapStrategy; auto Arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; auto arr = Arr.dup; @@ -619,7 +619,7 @@ if (isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range) { assert(pivot < r.length || r.length == 0 && pivot == 0); if (r.length <= 1) return 0; - import std.algorithm.mutation : swapAt, move; + import std.algorithm.mutation : move, swapAt; alias lt = binaryFun!less; // Pivot at the front @@ -746,8 +746,8 @@ if (isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range) assert(pivot == 0 || pivot == 1); assert(a == [ 42, 42 ]); - import std.random; import std.algorithm.iteration : map; + import std.random; import std.stdio; auto s = unpredictableSeed; auto g = Random(s); @@ -830,8 +830,8 @@ if (ss == SwapStrategy.unstable && isRandomAccessRange!Range // The algorithm is described in "Engineering a sort function" by // Jon Bentley et al, pp 1257. - import std.algorithm.mutation : swap, swapAt, swapRanges; import std.algorithm.comparison : min; + import std.algorithm.mutation : swap, swapAt, swapRanges; import std.typecons : tuple; alias lessFun = binaryFun!less; @@ -986,8 +986,8 @@ if (isRandomAccessRange!Range && !isInfinite!Range && isRandomAccessRange!RangeIndex && !isInfinite!RangeIndex && isIntegral!(ElementType!RangeIndex)) { - import std.exception : enforce; import std.conv : to; + import std.exception : enforce; alias IndexType = Unqual!(ElementType!RangeIndex); enforce(r.length == index.length, @@ -1443,8 +1443,8 @@ template multiSort(less...) //if (less.length > 1) auto multiSort(Range)(Range r) if (validPredicates!(ElementType!Range, less)) { - import std.range : assumeSorted; import std.meta : AliasSeq; + import std.range : assumeSorted; static if (is(typeof(less[$ - 1]) == SwapStrategy)) { enum ss = less[$ - 1]; @@ -1899,8 +1899,8 @@ if (((ss == SwapStrategy.unstable && (hasSwappableElements!Range || // Sorting floating-point numbers in presence of NaN double[] numbers = [-0.0, 3.0, -2.0, double.nan, 0.0, -double.nan]; - import std.math : cmp, isIdentical; import std.algorithm.comparison : equal; + import std.math : cmp, isIdentical; sort!((a, b) => cmp(a, b) < 0)(numbers); @@ -1911,7 +1911,7 @@ if (((ss == SwapStrategy.unstable && (hasSwappableElements!Range || @safe unittest { // Simple regression benchmark - import std.random, std.algorithm.iteration, std.algorithm.mutation; + import std.algorithm.iteration, std.algorithm.mutation, std.random; Random rng; int[] a = iota(20148).map!(_ => uniform(-1000, 1000, rng)).array; static uint comps; @@ -1939,7 +1939,7 @@ if (((ss == SwapStrategy.unstable && (hasSwappableElements!Range || { import std.algorithm.internal : rndstuff; import std.algorithm.mutation : swapRanges; - import std.random : Random, unpredictableSeed, uniform; + import std.random : Random, uniform, unpredictableSeed; import std.uni : toUpper; // sort using delegate @@ -2038,8 +2038,8 @@ if (((ss == SwapStrategy.unstable && (hasSwappableElements!Range || private void quickSortImpl(alias less, Range)(Range r, size_t depth) { + import std.algorithm.comparison : max, min; import std.algorithm.mutation : swap, swapAt; - import std.algorithm.comparison : min, max; alias Elem = ElementType!(Range); enum size_t shortSortGetsBetter = max(32, 1024 / Elem.sizeof); @@ -2736,7 +2736,7 @@ private template TimSortImpl(alias pred, R) @safe unittest { - import std.random : Random, uniform, randomShuffle; + import std.random : Random, randomShuffle, uniform; // Element type with two fields static struct E @@ -2833,7 +2833,7 @@ private template TimSortImpl(alias pred, R) @safe unittest { // Issue 14223 - import std.range, std.array; + import std.array, std.range; auto arr = chain(iota(0, 384), iota(0, 256), iota(0, 80), iota(0, 64), iota(0, 96)).array; sort!("a < b", SwapStrategy.stable)(arr); } @@ -2893,14 +2893,14 @@ schwartzSort(alias transform, alias less = "a < b", if (isRandomAccessRange!R && hasLength!R) { import std.conv : emplace; + import std.range : SortedRange, zip; import std.string : representation; - import std.range : zip, SortedRange; alias T = typeof(unaryFun!transform(r.front)); static trustedMalloc(size_t len) @trusted { - import core.stdc.stdlib : malloc; import core.checkedint : mulu; + import core.stdc.stdlib : malloc; bool overflow; const nbytes = mulu(len, T.sizeof, overflow); if (overflow) assert(0); @@ -3436,8 +3436,8 @@ private T[] randomArray(Flag!"exactSize" flag = No.exactSize, T = int)( size_t maxSize = 1000, T minValue = 0, T maxValue = 255) { - import std.random : unpredictableSeed, Random, uniform; import std.algorithm.iteration : map; + import std.random : Random, uniform, unpredictableSeed; auto size = flag == Yes.exactSize ? maxSize : uniform(1, maxSize); return iota(0, size).map!(_ => uniform(minValue, maxValue)).array; } @@ -3698,7 +3698,7 @@ if (isInputRange!(SRange) && isRandomAccessRange!(TRange) @system unittest { - import std.random : Random, unpredictableSeed, uniform, randomShuffle; + import std.random : Random, randomShuffle, uniform, unpredictableSeed; import std.typecons : Yes; auto r = Random(unpredictableSeed); diff --git a/std/array.d b/std/array.d index 4d923776be4..efbed4606fa 100644 --- a/std/array.d +++ b/std/array.d @@ -76,13 +76,13 @@ Source: $(PHOBOSSRC std/_array.d) */ module std.array; +static import std.algorithm.iteration; // FIXME, remove with alias of splitter +import std.functional; import std.meta; import std.traits; -import std.functional; -static import std.algorithm.iteration; // FIXME, remove with alias of splitter import std.range.primitives; -public import std.range.primitives : save, empty, popFront, popBack, front, back; +public import std.range.primitives : back, empty, front, popBack, popFront, save; /** * Allocates an array and initializes it with copies of the elements @@ -316,8 +316,8 @@ if (isNarrowString!String) // Bugzilla 10220 @safe unittest { - import std.exception; import std.algorithm.comparison : equal; + import std.exception; import std.range : repeat; static struct S @@ -418,8 +418,8 @@ of Tuple's of key and value pairs from the given associative array. */ auto byPair(Key, Value)(Value[Key] aa) { - import std.typecons : tuple; import std.algorithm.iteration : map; + import std.typecons : tuple; return aa.byKeyValue.map!(pair => tuple(pair.key, pair.value)); } @@ -427,8 +427,8 @@ auto byPair(Key, Value)(Value[Key] aa) /// @system unittest { - import std.typecons : tuple, Tuple; import std.algorithm.sorting : sort; + import std.typecons : tuple, Tuple; auto aa = ["a": 1, "b": 2, "c": 3]; Tuple!(string, int)[] pairs; @@ -641,8 +641,8 @@ private auto arrayAllocImpl(bool minimallyInitialized, T, I...)(I sizes) nothrow } else { - import core.stdc.string : memset; import core.memory : GC; + import core.stdc.string : memset; import core.checkedint : mulu; bool overflow; @@ -744,7 +744,7 @@ slice, returns that slice. Otherwise, returns the null slice. auto overlap(T, U)(T[] r1, U[] r2) @trusted pure nothrow if (is(typeof(r1.ptr < r2.ptr) == bool)) { - import std.algorithm.comparison : min, max; + import std.algorithm.comparison : max, min; auto b = max(r1.ptr, r2.ptr); auto e = min(r1.ptr + r1.length, r2.ptr + r2.length); return b < e ? b[0 .. e - b] : null; @@ -1031,9 +1031,9 @@ private template isInputRangeOrConvertible(E) @system unittest { // @system due to insertInPlace + import core.exception; import std.algorithm.comparison : equal; import std.algorithm.iteration : filter; - import core.exception; import std.conv : to; import std.exception; @@ -1511,8 +1511,8 @@ if (isForwardRange!Range && is(typeof(unaryFun!isTerminator(range.front)))) @safe unittest { - import std.conv; import std.algorithm.comparison : cmp; + import std.conv; debug(std_array) printf("array.split\n"); foreach (S; AliasSeq!(string, wstring, dstring, @@ -1841,8 +1841,8 @@ if (isInputRange!RoR && @system unittest { - import std.conv : to; import std.algorithm; + import std.conv : to; import std.range; debug(std_array) printf("array.join.unittest\n"); @@ -2065,8 +2065,8 @@ if (isOutputRange!(Sink, E) && isDynamicArray!(E[]) @safe unittest { - import std.conv : to; import std.algorithm.comparison : cmp; + import std.conv : to; debug(std_array) printf("array.replace.unittest\n"); @@ -2098,8 +2098,8 @@ if (isOutputRange!(Sink, E) && isDynamicArray!(E[]) @safe unittest { - import std.conv : to; import std.algorithm.searching : skipOver; + import std.conv : to; struct CheckOutput(C) { @@ -2172,9 +2172,9 @@ if (isInputRange!Range && @system unittest { import core.exception; + import std.algorithm.iteration : filter; import std.conv : to; import std.exception; - import std.algorithm.iteration : filter; auto a = [ 1, 2, 3, 4 ]; @@ -2333,8 +2333,8 @@ if (is(typeof(replace(array, from, to, stuff)))) void testStringReplaceInPlace(T, U)() { - import std.conv; import std.algorithm.comparison : equal; + import std.conv; auto a = unicoded.to!(U[]); auto b = unicodedLong.to!(U[]); @@ -2376,9 +2376,9 @@ if (is(typeof(replace(array, from, to, stuff)))) @system unittest { + import core.exception; import std.algorithm.comparison : equal; import std.algorithm.iteration : filter; - import core.exception; import std.conv : to; import std.exception; @@ -2509,8 +2509,8 @@ if (isDynamicArray!(E[]) && @safe unittest { - import std.conv : to; import std.algorithm.comparison : cmp; + import std.conv : to; debug(std_array) printf("array.replaceFirst.unittest\n"); @@ -2624,8 +2624,8 @@ if (isDynamicArray!(E[]) && @safe unittest { - import std.conv : to; import std.algorithm.comparison : cmp; + import std.conv : to; debug(std_array) printf("array.replaceLast.unittest\n"); @@ -3359,8 +3359,8 @@ Appender!(E[]) appender(A : E[], E)(auto ref A array) @safe unittest { - import std.typecons; import std.algorithm; + import std.typecons; //10690 [tuple(1)].filter!(t => true).array; // No error [tuple("A")].filter!(t => true).array; // error @@ -3489,8 +3489,8 @@ Appender!(E[]) appender(A : E[], E)(auto ref A array) @safe unittest //Test large allocations (for GC.extend) { - import std.range; import std.algorithm.comparison : equal; + import std.range; Appender!(char[]) app; app.reserve(1); //cover reserve on non-initialized foreach (_; 0 .. 100_000) diff --git a/std/base64.d b/std/base64.d index 63c00a6ed09..59c941e27b4 100644 --- a/std/base64.d +++ b/std/base64.d @@ -1737,8 +1737,8 @@ class Base64Exception : Exception @system unittest { - import std.algorithm.sorting : sort; import std.algorithm.comparison : equal; + import std.algorithm.sorting : sort; import std.conv; import std.file; import std.stdio; diff --git a/std/bigint.d b/std/bigint.d index 35bb2e993d0..b24ad5668f5 100644 --- a/std/bigint.d +++ b/std/bigint.d @@ -27,10 +27,10 @@ module std.bigint; import std.conv : ConvException; +private import std.format : FormatException, FormatSpec; private import std.internal.math.biguintcore; -private import std.format : FormatSpec, FormatException; -private import std.traits; private import std.range.primitives; +private import std.traits; /** A struct representing an arbitrary precision integer. * @@ -69,9 +69,9 @@ public: { import std.algorithm.iteration : filterBidirectional; import std.algorithm.searching : startsWith; - import std.utf : byChar; - import std.exception : enforce; import std.conv : ConvException; + import std.exception : enforce; + import std.utf : byChar; enforce!ConvException(!s.empty, "Can't initialize BigInt with an empty range"); @@ -125,8 +125,8 @@ public: @system unittest { // system because of the dummy ranges eventually call std.array!string - import std.internal.test.dummyrange; import std.exception : assertThrown; + import std.internal.test.dummyrange; auto r1 = new ReferenceBidirectionalRange!dchar("101"); auto big1 = BigInt(r1); @@ -674,7 +674,7 @@ public: /// @system unittest { - import std.conv : to, ConvOverflowException; + import std.conv : ConvOverflowException, to; import std.exception : assertThrown; assert(BigInt("0").to!int == 0); @@ -687,7 +687,7 @@ public: @system unittest { - import std.conv : to, ConvOverflowException; + import std.conv : ConvOverflowException, to; import std.exception : assertThrown; assert(BigInt("-1").to!byte == -1); @@ -1503,8 +1503,8 @@ unittest assert(__traits(compiles, foo(cbi))); assert(__traits(compiles, foo(ibi))); - import std.meta : AliasSeq; import std.conv : to; + import std.meta : AliasSeq; foreach (T1; AliasSeq!(BigInt, const(BigInt), immutable(BigInt))) { diff --git a/std/bitmanip.d b/std/bitmanip.d index b2e4be33b8a..4bd4f13d645 100644 --- a/std/bitmanip.d +++ b/std/bitmanip.d @@ -632,9 +632,9 @@ unittest // Issue 12477 @system unittest { + import core.exception : AssertError; import std.algorithm.searching : canFind; import std.bitmanip : bitfields; - import core.exception : AssertError; static struct S { @@ -772,8 +772,8 @@ struct BitArray { private: + import core.bitop : bsf, bt, btr, bts; import std.format : FormatSpec; - import core.bitop : bts, btr, bsf, bt; size_t _len; size_t* _ptr; @@ -2052,7 +2052,7 @@ public: */ @property auto bitsSet() const nothrow { - import std.algorithm.iteration : filter, map, joiner; + import std.algorithm.iteration : filter, joiner, map; import std.range : iota; return iota(dim). @@ -3779,8 +3779,8 @@ if (canSwapEndianness!T && isOutputRange!(R, ubyte)) @system unittest { - import std.format : format; import std.array; + import std.format : format; import std.meta; foreach (endianness; AliasSeq!(Endian.bigEndian, Endian.littleEndian)) { diff --git a/std/c/freebsd/socket.d b/std/c/freebsd/socket.d index 5a73d47572c..dca4f520f63 100644 --- a/std/c/freebsd/socket.d +++ b/std/c/freebsd/socket.d @@ -11,7 +11,7 @@ module std.c.freebsd.socket; version (FreeBSD): public import core.sys.posix.netdb; -public import core.sys.posix.sys.socket : AF_APPLETALK, AF_IPX, SOCK_RDM, MSG_NOSIGNAL; public import core.sys.posix.netinet.in_ : IPPROTO_IGMP, IPPROTO_GGP, IPPROTO_PUP, IPPROTO_IDP, IPPROTO_ND, IPPROTO_MAX, INADDR_LOOPBACK, INADDR_NONE; +public import core.sys.posix.sys.socket : AF_APPLETALK, AF_IPX, MSG_NOSIGNAL, SOCK_RDM; diff --git a/std/c/linux/linux.d b/std/c/linux/linux.d index 165068a1034..a11c474eabd 100644 --- a/std/c/linux/linux.d +++ b/std/c/linux/linux.d @@ -60,11 +60,11 @@ public import core.sys.posix.dirent; public import core.sys.posix.dlfcn; public import core.sys.posix.fcntl; public import core.sys.posix.pwd; -public import core.sys.posix.time; -public import core.sys.posix.unistd; -public import core.sys.posix.utime; public import core.sys.posix.sys.mman; public import core.sys.posix.sys.stat; public import core.sys.posix.sys.time; public import core.sys.posix.sys.types; public import core.sys.posix.sys.wait; +public import core.sys.posix.time; +public import core.sys.posix.unistd; +public import core.sys.posix.utime; diff --git a/std/c/linux/socket.d b/std/c/linux/socket.d index 59c85c1c470..fcc577d1cd2 100644 --- a/std/c/linux/socket.d +++ b/std/c/linux/socket.d @@ -16,8 +16,8 @@ version (linux): private import core.stdc.stdint; public import core.sys.posix.arpa.inet; public import core.sys.posix.netdb; -public import core.sys.posix.netinet.tcp; public import core.sys.posix.netinet.in_; +public import core.sys.posix.netinet.tcp; public import core.sys.posix.sys.select; public import core.sys.posix.sys.socket; diff --git a/std/c/osx/socket.d b/std/c/osx/socket.d index 835ed276cd2..167af36a88e 100644 --- a/std/c/osx/socket.d +++ b/std/c/osx/socket.d @@ -16,8 +16,8 @@ version (OSX): private import core.stdc.stdint; public import core.sys.posix.arpa.inet; public import core.sys.posix.netdb; -public import core.sys.posix.netinet.tcp; public import core.sys.posix.netinet.in_; +public import core.sys.posix.netinet.tcp; public import core.sys.posix.sys.select; public import core.sys.posix.sys.socket; diff --git a/std/c/process.d b/std/c/process.d index 14fc729c6c7..8fcc1929340 100644 --- a/std/c/process.d +++ b/std/c/process.d @@ -13,7 +13,7 @@ deprecated("Import core.stdc.stdlib or the appropriate core.sys.posix.* modules module std.c.process; private import core.stdc.stddef; -public import core.stdc.stdlib : exit, abort, system; +public import core.stdc.stdlib : abort, exit, system; extern (C): diff --git a/std/complex.d b/std/complex.d index 225e0d48755..e9ad5eb98e7 100644 --- a/std/complex.d +++ b/std/complex.d @@ -150,8 +150,8 @@ if (isFloatingPoint!T) FormatSpec!Char formatSpec) const if (isOutputRange!(Writer, const(Char)[])) { - import std.math : signbit; import std.format : formatValue; + import std.math : signbit; import std.range.primitives : put; formatValue(w, re, formatSpec); if (signbit(im) == 0) @@ -298,7 +298,7 @@ if (isFloatingPoint!T) Complex!(CommonType!(T, R)) opBinaryRight(string op, R)(R lhs) const if (op == "^^" && isNumeric!R) { - import std.math : cos, exp, log, sin, PI; + import std.math : cos, exp, log, PI, sin; Unqual!(CommonType!(T, R)) ab = void, ar = void; if (lhs >= 0) @@ -370,7 +370,7 @@ if (isFloatingPoint!T) ref Complex opOpAssign(string op, C)(C z) if (op == "^^" && is(C R == Complex!R)) { - import std.math : exp, log, cos, sin; + import std.math : cos, exp, log, sin; immutable r = abs(this); immutable t = arg(this); immutable ab = r^^z.re * exp(-t*z.im); @@ -440,8 +440,8 @@ if (isFloatingPoint!T) @safe pure nothrow unittest { - import std.math; import std.complex; + import std.math; enum EPS = double.epsilon; auto c1 = complex(1.0, 1.0); @@ -799,7 +799,7 @@ Complex!T conj(T)(Complex!T z) @safe pure nothrow @nogc Complex!(CommonType!(T, U)) fromPolar(T, U)(T modulus, U argument) @safe pure nothrow @nogc { - import std.math : sin, cos; + import std.math : cos, sin; return Complex!(CommonType!(T,U)) (modulus*cos(argument), modulus*sin(argument)); } @@ -822,7 +822,7 @@ Complex!(CommonType!(T, U)) fromPolar(T, U)(T modulus, U argument) */ Complex!T sin(T)(Complex!T z) @safe pure nothrow @nogc { - import std.math : expi, coshisinh; + import std.math : coshisinh, expi; auto cs = expi(z.re); auto csh = coshisinh(z.im); return typeof(return)(cs.im * csh.re, cs.re * csh.im); @@ -840,7 +840,7 @@ Complex!T sin(T)(Complex!T z) @safe pure nothrow @nogc /// ditto Complex!T cos(T)(Complex!T z) @safe pure nothrow @nogc { - import std.math : expi, coshisinh; + import std.math : coshisinh, expi; auto cs = expi(z.re); auto csh = coshisinh(z.im); return typeof(return)(cs.re * csh.re, - cs.im * csh.im); @@ -849,8 +849,8 @@ Complex!T cos(T)(Complex!T z) @safe pure nothrow @nogc /// @safe pure nothrow unittest { - import std.math; import std.complex; + import std.math; assert(cos(complex(0.0)) == 1.0); assert(cos(complex(1.3L)) == std.math.cos(1.3L)); assert(cos(complex(0, 5.2L)) == cosh(5.2L)); diff --git a/std/concurrency.d b/std/concurrency.d index 44b9d8f8285..b54614208d0 100644 --- a/std/concurrency.d +++ b/std/concurrency.d @@ -975,8 +975,8 @@ bool register(string name, Tid tid) */ bool unregister(string name) { - import std.algorithm.searching : countUntil; import std.algorithm.mutation : remove, SwapStrategy; + import std.algorithm.searching : countUntil; synchronized (registryLock) { @@ -2269,7 +2269,7 @@ private version (unittest) { import std.stdio; - import std.typecons : tuple, Tuple; + import std.typecons : Tuple, tuple; void testfn(Tid tid) { @@ -2410,7 +2410,7 @@ auto ref initOnce(alias var)(lazy typeof(var) init, Mutex mutex) // check that var is global, can't take address of a TLS variable static assert(is(typeof({ __gshared p = &var; })), "var must be 'static shared' or '__gshared'."); - import core.atomic : atomicLoad, MemoryOrder, atomicStore; + import core.atomic : atomicLoad, atomicStore, MemoryOrder; static shared bool flag; if (!atomicLoad!(MemoryOrder.acq)(flag)) diff --git a/std/container/array.d b/std/container/array.d index b92a9c3e36b..0cc572389d0 100644 --- a/std/container/array.d +++ b/std/container/array.d @@ -18,9 +18,9 @@ */ module std.container.array; +import core.exception : RangeError; import std.range.primitives; import std.traits; -import core.exception : RangeError; public import std.container.util; @@ -251,7 +251,7 @@ private struct RangeT(A) struct Array(T) if (!is(Unqual!T == bool)) { - import core.stdc.stdlib : malloc, realloc, free; + import core.stdc.stdlib : free, malloc, realloc; import core.stdc.string : memcpy, memmove, memset; import core.memory : GC; @@ -419,8 +419,8 @@ if (!is(Unqual!T == bool)) this(U)(U[] values...) if (isImplicitlyConvertible!(U, T)) { - import std.conv : emplace; import core.checkedint : mulu; + import std.conv : emplace; bool overflow; const nbytes = mulu(values.length, T.sizeof, overflow); if (overflow) assert(0); diff --git a/std/container/binaryheap.d b/std/container/binaryheap.d index 4ce3953ab0d..4adf6045436 100644 --- a/std/container/binaryheap.d +++ b/std/container/binaryheap.d @@ -65,11 +65,11 @@ container. struct BinaryHeap(Store, alias less = "a < b") if (isRandomAccessRange!(Store) || isRandomAccessRange!(typeof(Store.init[]))) { - import std.functional : binaryFun; - import std.exception : enforce; import std.algorithm.comparison : min; import std.algorithm.mutation : move, swapAt; import std.algorithm.sorting : HeapOps; + import std.exception : enforce; + import std.functional : binaryFun; import std.typecons : RefCounted, RefCountedAutoInitialize; static if (isRandomAccessRange!Store) @@ -565,8 +565,8 @@ BinaryHeap!(Store, less) heapify(alias less = "a < b", Store)(Store s, @system unittest { - import std.internal.test.dummyrange; import std.algorithm.comparison : equal; + import std.internal.test.dummyrange; alias RefRange = DummyRange!(ReturnBy.Reference, Length.Yes, RangeType.Random); diff --git a/std/container/dlist.d b/std/container/dlist.d index d2e90782794..a1865741c62 100644 --- a/std/container/dlist.d +++ b/std/container/dlist.d @@ -21,8 +21,8 @@ module std.container.dlist; /// @safe unittest { - import std.container : DList; import std.algorithm.comparison : equal; + import std.container : DList; auto s = DList!int(1, 2, 3); assert(equal(s[], [1, 2, 3])); @@ -39,7 +39,7 @@ module std.container.dlist; // If you want to apply range operations, simply slice it. import std.algorithm.searching : countUntil; - import std.range : popFrontN, popBackN, walkLength; + import std.range : popBackN, popFrontN, walkLength; auto sl = DList!int([1, 2, 3, 4, 5]); assert(countUntil(sl[], 2) == 1); diff --git a/std/container/rbtree.d b/std/container/rbtree.d index 524282e1764..3be1871486e 100644 --- a/std/container/rbtree.d +++ b/std/container/rbtree.d @@ -19,8 +19,8 @@ module std.container.rbtree; /// @safe pure unittest { - import std.container.rbtree; import std.algorithm.comparison : equal; + import std.container.rbtree; auto rbt = redBlackTree(3, 1, 4, 2, 5); assert(rbt.front == 1); @@ -56,8 +56,8 @@ module std.container.rbtree; assert(equal(ubt[], [0, 0, 1, 1])); } -import std.functional : binaryFun; import std.format; +import std.functional : binaryFun; public import std.container.util; @@ -740,9 +740,9 @@ final class RedBlackTree(T, alias less = "a < b", bool allowDuplicates = false) if (is(typeof(binaryFun!less(T.init, T.init)))) { import std.meta : allSatisfy; - import std.range.primitives : isInputRange, walkLength; import std.range : Take; - import std.traits : isIntegral, isDynamicArray, isImplicitlyConvertible; + import std.range.primitives : isInputRange, walkLength; + import std.traits : isDynamicArray, isImplicitlyConvertible, isIntegral; alias _less = binaryFun!less; @@ -1820,7 +1820,7 @@ assert(equal(rbt[], [5])); test!byte(); } -import std.range.primitives : isInputRange, isSomeString, ElementType; +import std.range.primitives : ElementType, isInputRange, isSomeString; import std.traits : isArray; /++ diff --git a/std/container/slist.d b/std/container/slist.d index 3cd67a81ff1..b36584e3b55 100644 --- a/std/container/slist.d +++ b/std/container/slist.d @@ -21,8 +21,8 @@ module std.container.slist; /// @safe unittest { - import std.container : SList; import std.algorithm.comparison : equal; + import std.container : SList; auto s = SList!int(1, 2, 3); assert(equal(s[], [1, 2, 3])); @@ -57,7 +57,7 @@ struct SList(T) { import std.exception : enforce; import std.range : Take; - import std.range.primitives : isInputRange, isForwardRange, ElementType; + import std.range.primitives : ElementType, isForwardRange, isInputRange; import std.traits : isImplicitlyConvertible; private struct Node diff --git a/std/container/util.d b/std/container/util.d index aed1f1aa680..1f7aeb3464a 100644 --- a/std/container/util.d +++ b/std/container/util.d @@ -54,8 +54,8 @@ if (is(T == struct) || is(T == class)) /// @system unittest { - import std.container; import std.algorithm.comparison : equal; + import std.container; auto arr = make!(Array!int)([4, 2, 3, 1]); assert(equal(arr[], [4, 2, 3, 1])); @@ -70,8 +70,8 @@ if (is(T == struct) || is(T == class)) @system unittest { - import std.container; import std.algorithm.comparison : equal; + import std.container; auto arr1 = make!(Array!dchar)(); assert(arr1.empty); @@ -87,8 +87,8 @@ if (is(T == struct) || is(T == class)) // Issue 8895 @safe unittest { - import std.container; import std.algorithm.comparison : equal; + import std.container; auto a = make!(DList!int)(1,2,3,4); auto b = make!(DList!int)(1,2,3,4); @@ -105,7 +105,7 @@ if (is(T == struct) || is(T == class)) template make(alias Container, Args...) if (!is(Container)) { - import std.range : isInputRange, isInfinite; + import std.range : isInfinite, isInputRange; import std.traits : isDynamicArray; auto make(Range)(Range range) @@ -135,9 +135,9 @@ if (!is(Container)) /// @system unittest { + import std.algorithm.comparison : equal; import std.container.array, std.container.rbtree, std.container.slist; import std.range : iota; - import std.algorithm.comparison : equal; auto arr = make!Array(iota(5)); assert(equal(arr[], [0, 1, 2, 3, 4])); @@ -155,8 +155,8 @@ if (!is(Container)) @safe unittest { - import std.container.rbtree; import std.algorithm.comparison : equal; + import std.container.rbtree; auto rbtmin = make!(RedBlackTree, "a < b", false)(3, 2, 2, 1); assert(equal(rbtmin[], [1, 2, 3])); diff --git a/std/conv.d b/std/conv.d index 4a3e458357e..1db8faf1744 100644 --- a/std/conv.d +++ b/std/conv.d @@ -129,8 +129,8 @@ private } else { - import std.format : FormatSpec, formatValue; import std.array : appender; + import std.format : FormatSpec, formatValue; auto w = appender!T(); FormatSpec!(ElementEncodingType!T) f; @@ -957,8 +957,8 @@ if (!(isImplicitlyConvertible!(S, T) && } } - import std.format : FormatSpec, formatValue; import std.array : appender; + import std.format : FormatSpec, formatValue; //Default case, delegate to format //Note: we don't call toStr directly, to avoid duplicate work. @@ -1019,8 +1019,8 @@ if (!(isImplicitlyConvertible!(S, T) && !isEnumStrToStr!(S, T) && !isNullToStr!(S, T)) && !isInfinite!S && isExactSomeString!T && !isCopyable!S) { - import std.format : FormatSpec, formatValue; import std.array : appender; + import std.format : FormatSpec, formatValue; auto w = appender!T(); FormatSpec!(ElementEncodingType!T) f; @@ -1851,7 +1851,7 @@ if (isInputRange!S && !isInfinite!S && isSomeChar!(ElementEncodingType!S) && // bugzilla 15800 @safe unittest { - import std.utf : byCodeUnit, byChar, byWchar, byDchar; + import std.utf : byChar, byCodeUnit, byDchar, byWchar; assert(to!int(byCodeUnit("10")) == 10); assert(to!int(byCodeUnit("10"), 10) == 10); @@ -2021,8 +2021,8 @@ Lerr: @safe unittest { - import std.exception; import std.algorithm.comparison : equal; + import std.exception; struct InputString { string _s; @@ -2439,7 +2439,7 @@ in } body { - import core.checkedint : mulu, addu; + import core.checkedint : addu, mulu; import std.exception : enforce; if (radix == 10) @@ -2637,9 +2637,9 @@ Target parse(Target, Source)(ref Source source) if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum) && isFloatingPoint!Target && !is(Target == enum)) { - import std.ascii : isDigit, isAlpha, toLower, toUpper, isHexDigit; - import std.exception : enforce; import core.stdc.math : HUGE_VAL; + import std.ascii : isAlpha, isDigit, isHexDigit, toLower, toUpper; + import std.exception : enforce; static if (isNarrowString!Source) { @@ -3065,7 +3065,7 @@ if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum @safe unittest { import std.exception; - import std.math : isNaN, fabs; + import std.math : fabs, isNaN; // Compare reals with given precision bool feq(in real rx, in real ry, in real precision = 0.000001L) @@ -5251,8 +5251,8 @@ version(unittest) @safe unittest //@@@9559@@@ { import std.algorithm.iteration : map; - import std.typecons : Nullable; import std.array : array; + import std.typecons : Nullable; alias I = Nullable!int; auto ints = [0, 1, 2].map!(i => i & 1 ? I.init : I(i))(); auto asArray = array(ints); @@ -5814,7 +5814,7 @@ an even number of hexadecimal digits (regardless of the case). private bool isHexLiteral(String)(scope const String hexData) { import std.ascii : isHexDigit; - import std.uni : lineSep, paraSep, nelSep; + import std.uni : lineSep, nelSep, paraSep; size_t i; foreach (const dchar c; hexData) { diff --git a/std/csv.d b/std/csv.d index be286c9a7e7..a896159b5b0 100644 --- a/std/csv.d +++ b/std/csv.d @@ -92,9 +92,9 @@ module std.csv; import std.conv; +import std.exception; // basicExceptionCtors import std.range.primitives; import std.traits; -import std.exception; // basicExceptionCtors /** * Exception containing the row and column for when an exception was thrown. diff --git a/std/datetime/date.d b/std/datetime/date.d index a7d33830128..184bc4a058e 100644 --- a/std/datetime/date.d +++ b/std/datetime/date.d @@ -7281,7 +7281,7 @@ public: if (isSomeString!S) { import std.algorithm.searching : startsWith; - import std.conv : to, text, ConvException; + import std.conv : ConvException, text, to; import std.exception : enforce; import std.string : strip; @@ -8797,7 +8797,7 @@ public: static TimeOfDay fromISOString(S)(in S isoString) @safe pure if (isSomeString!S) { - import std.conv : to, text, ConvException; + import std.conv : ConvException, text, to; import std.exception : enforce; import std.string : strip; diff --git a/std/datetime/interval.d b/std/datetime/interval.d index 302b4c28e99..cf097fd46ac 100644 --- a/std/datetime/interval.d +++ b/std/datetime/interval.d @@ -7,7 +7,7 @@ +/ module std.datetime.interval; -import core.time : Duration, dur; +import core.time : dur, Duration; import std.datetime.date : AllowDayOverflow, DateTimeException, daysToDayOfWeek, DayOfWeek, isTimePoint, Month; import std.exception : enforce; diff --git a/std/datetime/package.d b/std/datetime/package.d index 9395590a002..11f8a61502e 100644 --- a/std/datetime/package.d +++ b/std/datetime/package.d @@ -116,9 +116,9 @@ public import std.datetime.systime; public import std.datetime.timezone; import core.exception : AssertError; -import std.typecons : Flag, Yes, No; import std.functional : unaryFun; import std.traits; +import std.typecons : Flag, No, Yes; // Verify module example. diff --git a/std/datetime/systime.d b/std/datetime/systime.d index 7ef14b44f60..4a91f419def 100644 --- a/std/datetime/systime.d +++ b/std/datetime/systime.d @@ -10,8 +10,8 @@ module std.datetime.systime; import core.time; import std.datetime.date; import std.datetime.timezone; -import std.format : format; import std.exception : enforce; +import std.format : format; import std.range.primitives; import std.traits : isIntegral, isSigned, isSomeString, Unqual; @@ -1758,7 +1758,7 @@ public: /// @safe unittest { - import core.time : msecs, usecs, hnsecs, nsecs; + import core.time : hnsecs, msecs, nsecs, usecs; import std.datetime.date : DateTime; auto dt = DateTime(1982, 4, 1, 20, 59, 22); @@ -1846,7 +1846,7 @@ public: /// @safe unittest { - import core.time : Duration, msecs, hnsecs, nsecs; + import core.time : Duration, hnsecs, msecs, nsecs; import std.datetime.date : DateTime; auto st = SysTime(DateTime(1982, 4, 1, 20, 59, 22)); @@ -4564,7 +4564,7 @@ public: /// @safe unittest { - import core.time : msecs, hnsecs; + import core.time : hnsecs, msecs; import std.datetime.date : DateTime; auto st1 = SysTime(DateTime(2010, 1, 1, 11, 23, 12)); @@ -7383,7 +7383,7 @@ public: /// @safe unittest { - import core.time : msecs, usecs, hnsecs; + import core.time : hnsecs, msecs, usecs; import std.datetime.date : DateTime; assert(SysTime(DateTime(1999, 1, 6, 0, 0, 0)).endOfMonth == @@ -7834,7 +7834,7 @@ public: /// @safe unittest { - import core.time : msecs, hnsecs; + import core.time : hnsecs, msecs; import std.datetime.date : DateTime; assert(SysTime(DateTime(2010, 7, 4, 7, 6, 12)).toISOString() == @@ -7966,7 +7966,7 @@ public: /// @safe unittest { - import core.time : msecs, hnsecs; + import core.time : hnsecs, msecs; import std.datetime.date : DateTime; assert(SysTime(DateTime(2010, 7, 4, 7, 6, 12)).toISOExtString() == @@ -8102,7 +8102,7 @@ public: /// @safe unittest { - import core.time : msecs, hnsecs; + import core.time : hnsecs, msecs; import std.datetime.date : DateTime; assert(SysTime(DateTime(2010, 7, 4, 7, 6, 12)).toSimpleString() == @@ -8247,7 +8247,7 @@ public: static SysTime fromISOString(S)(in S isoString, immutable TimeZone tz = null) @safe if (isSomeString!S) { - import std.algorithm.searching : startsWith, find; + import std.algorithm.searching : find, startsWith; import std.conv : to; import std.string : strip; @@ -8310,7 +8310,7 @@ public: /// @safe unittest { - import core.time : hours, msecs, usecs, hnsecs; + import core.time : hnsecs, hours, msecs, usecs; import std.datetime.date : DateTime; import std.datetime.timezone : SimpleTimeZone, UTC; @@ -8559,7 +8559,7 @@ public: /// @safe unittest { - import core.time : hours, msecs, usecs, hnsecs; + import core.time : hnsecs, hours, msecs, usecs; import std.datetime.date : DateTime; import std.datetime.timezone : SimpleTimeZone, UTC; @@ -8785,7 +8785,7 @@ public: /// @safe unittest { - import core.time : hours, msecs, usecs, hnsecs; + import core.time : hnsecs, hours, msecs, usecs; import std.datetime.date : DateTime; import std.datetime.timezone : SimpleTimeZone, UTC; @@ -9582,8 +9582,8 @@ SysTime parseRFC822DateTime(R)(R value) @safe if (isRandomAccessRange!R && hasSlicing!R && hasLength!R && (is(Unqual!(ElementType!R) == char) || is(Unqual!(ElementType!R) == ubyte))) { - import std.algorithm.searching : find, all; - import std.ascii : isDigit, isAlpha, isPrintable; + import std.algorithm.searching : all, find; + import std.ascii : isAlpha, isDigit, isPrintable; import std.conv : to; import std.functional : not; import std.string : capitalize, format; diff --git a/std/datetime/timezone.d b/std/datetime/timezone.d index 17841bbb2f3..a9c7a225a33 100644 --- a/std/datetime/timezone.d +++ b/std/datetime/timezone.d @@ -1199,7 +1199,7 @@ private: { long tm_gmtoff(long stdTime) @trusted const nothrow { - import core.stdc.time : localtime, gmtime, tm; + import core.stdc.time : gmtime, localtime, tm; time_t unixTime = stdTimeToUnixTime(stdTime); tm* buf = localtime(&unixTime); @@ -1595,7 +1595,7 @@ package: static immutable(SimpleTimeZone) fromISOString(S)(S isoString) @safe pure if (isSomeString!S) { - import std.algorithm.searching : startsWith, countUntil, all; + import std.algorithm.searching : all, countUntil, startsWith; import std.ascii : isDigit; import std.conv : to; import std.format : format; @@ -1739,7 +1739,7 @@ package: static immutable(SimpleTimeZone) fromISOExtString(S)(S isoExtString) @safe pure if (isSomeString!S) { - import std.algorithm.searching : startsWith, countUntil, all; + import std.algorithm.searching : all, countUntil, startsWith; import std.ascii : isDigit; import std.conv : to; import std.format : format; @@ -1914,11 +1914,11 @@ private: +/ final class PosixTimeZone : TimeZone { - import std.algorithm.searching : countUntil, canFind, startsWith; - import std.file : isDir, isFile, exists, dirEntries, SpanMode, DirEntry; + import std.algorithm.searching : canFind, countUntil, startsWith; + import std.file : dirEntries, DirEntry, exists, isDir, isFile, SpanMode; import std.path : extension; import std.stdio : File; - import std.string : strip, representation; + import std.string : representation, strip; import std.traits : isArray, isSomeChar; public: @@ -2081,10 +2081,10 @@ public: static immutable(PosixTimeZone) getTimeZone(string name, string tzDatabaseDir = defaultTZDatabaseDir) @trusted { import std.algorithm.sorting : sort; - import std.range : retro; + import std.conv : to; import std.format : format; import std.path : asNormalizedPath, chainPath; - import std.conv : to; + import std.range : retro; name = strip(name); diff --git a/std/digest/digest.d b/std/digest/digest.d index 48cbe35da43..00acb9710d7 100644 --- a/std/digest/digest.d +++ b/std/digest/digest.d @@ -63,10 +63,10 @@ $(TR $(TDNW Implementation helpers) $(TD $(MYREF digestLength) $(MYREF WrapperDi */ module std.digest.digest; +public import std.ascii : LetterCase; import std.meta : allSatisfy; -import std.traits; import std.range.primitives; -public import std.ascii : LetterCase; +import std.traits; /// @@ -89,7 +89,7 @@ public import std.ascii : LetterCase; @system unittest { //Generating the hashes of a file, idiomatic D way - import std.digest.crc, std.digest.sha, std.digest.md; + import std.digest.crc, std.digest.md, std.digest.sha; import std.stdio; // Digests a file and prints the result. @@ -115,7 +115,7 @@ public import std.ascii : LetterCase; @system unittest { //Generating the hashes of a file using the template API - import std.digest.crc, std.digest.sha, std.digest.md; + import std.digest.crc, std.digest.md, std.digest.sha; import std.stdio; // Digests a file and prints the result. void digestFile(Hash)(ref Hash hash, string filename) @@ -154,7 +154,7 @@ public import std.ascii : LetterCase; /// @system unittest { - import std.digest.crc, std.digest.sha, std.digest.md; + import std.digest.crc, std.digest.md, std.digest.sha; import std.stdio; // Digests a file and prints the result. @@ -260,8 +260,8 @@ version(ExampleDigest) { //Using the OutputRange feature import std.algorithm.mutation : copy; - import std.range : repeat; import std.digest.md; + import std.range : repeat; auto oneMillionRange = repeat!ubyte(cast(ubyte)'a', 1000000); auto ctx = makeDigest!MD5(); @@ -405,7 +405,7 @@ if (isDigest!T) /// @system unittest { - import std.digest.md, std.digest.hmac; + import std.digest.hmac, std.digest.md; static assert(hasBlockSize!MD5 && MD5.blockSize == 512); static assert(hasBlockSize!(HMAC!MD5) && HMAC!MD5.blockSize == 512); } @@ -413,7 +413,7 @@ if (isDigest!T) package template isDigestibleRange(Range) { import std.digest.md; - import std.range : isInputRange, ElementType; + import std.range : ElementType, isInputRange; enum bool isDigestibleRange = isInputRange!Range && is(typeof( { MD5 ha; //Could use any conformant hash @@ -468,7 +468,7 @@ if (allSatisfy!(isArray, typeof(data))) /// @system unittest { - import std.digest.md, std.digest.sha, std.digest.crc; + import std.digest.crc, std.digest.md, std.digest.sha; auto md5 = digest!MD5( "The quick brown fox jumps over the lazy dog"); auto sha1 = digest!SHA1( "The quick brown fox jumps over the lazy dog"); auto crc32 = digest!CRC32("The quick brown fox jumps over the lazy dog"); @@ -629,8 +629,8 @@ interface Digest { //Using the OutputRange feature import std.algorithm.mutation : copy; - import std.range : repeat; import std.digest.md; + import std.range : repeat; auto oneMillionRange = repeat!ubyte(cast(ubyte)'a', 1000000); auto ctx = new MD5Digest(); @@ -641,7 +641,7 @@ interface Digest /// @system unittest { - import std.digest.md, std.digest.sha, std.digest.crc; + import std.digest.crc, std.digest.md, std.digest.sha; ubyte[] md5 = (new MD5Digest()).digest("The quick brown fox jumps over the lazy dog"); ubyte[] sha1 = (new SHA1Digest()).digest("The quick brown fox jumps over the lazy dog"); ubyte[] crc32 = (new CRC32Digest()).digest("The quick brown fox jumps over the lazy dog"); @@ -1136,7 +1136,7 @@ if (isInputRange!R1 && isInputRange!R2 && !isInfinite!R1 && !isInfinite!R2 && import std.internal.test.dummyrange : ReferenceInputRange; import std.range : takeExactly; import std.string : representation; - import std.utf : byWchar, byDchar; + import std.utf : byDchar, byWchar; { auto hex1 = "02CA3484C375EDD3C0F08D3F50D119E61077".representation; diff --git a/std/digest/hmac.d b/std/digest/hmac.d index 0e6158e0b59..7a9d0f3b12b 100644 --- a/std/digest/hmac.d +++ b/std/digest/hmac.d @@ -16,7 +16,7 @@ Source: $(PHOBOSSRC std/digest/_hmac.d) module std.digest.hmac; -import std.digest.digest : isDigest, hasBlockSize, isDigestibleRange, DigestType; +import std.digest.digest : DigestType, hasBlockSize, isDigest, isDigestibleRange; import std.meta : allSatisfy; /** @@ -33,7 +33,7 @@ version(StdDdoc) /// Computes an HMAC over data read from stdin. @safe unittest { - import std.stdio, std.digest.hmac, std.digest.sha; + import std.digest.hmac, std.digest.sha, std.stdio; import std.string : representation; auto secret = "secret".representation; @@ -89,7 +89,7 @@ if (hashBlockSize % 8 == 0) /// @safe pure nothrow @nogc unittest { - import std.digest.sha, std.digest.hmac; + import std.digest.hmac, std.digest.sha; import std.string : representation; auto hmac = HMAC!SHA1("My s3cR3T keY".representation); hmac.put("Hello, world".representation); @@ -126,7 +126,7 @@ if (hashBlockSize % 8 == 0) /// @safe pure nothrow @nogc unittest { - import std.digest.sha, std.digest.hmac; + import std.digest.hmac, std.digest.sha; import std.string : representation; string data1 = "Hello, world", data2 = "Hola mundo"; auto hmac = HMAC!SHA1("My s3cR3T keY".representation); @@ -157,7 +157,7 @@ if (hashBlockSize % 8 == 0) /// @safe pure nothrow @nogc unittest { - import std.digest.sha, std.digest.hmac; + import std.digest.hmac, std.digest.sha; import std.string : representation; string data1 = "Hello, world", data2 = "Hola mundo"; auto hmac = HMAC!SHA1("My s3cR3T keY".representation); @@ -193,7 +193,7 @@ if (hashBlockSize % 8 == 0) /// @safe pure nothrow @nogc unittest { - import std.digest.sha, std.digest.hmac; + import std.digest.hmac, std.digest.sha; import std.string : representation; string data1 = "Hello, world", data2 = "Hola mundo"; auto hmac = HMAC!SHA1("My s3cR3T keY".representation); @@ -234,7 +234,7 @@ if (isDigest!H) /// @safe pure nothrow @nogc unittest { - import std.digest.sha, std.digest.hmac; + import std.digest.hmac, std.digest.sha; import std.string : representation; string data1 = "Hello, world", data2 = "Hola mundo"; auto digest = hmac!SHA1("My s3cR3T keY".representation) @@ -268,9 +268,9 @@ if (isDigest!H) /// @system pure nothrow @nogc unittest { - import std.digest.sha, std.digest.hmac; - import std.string : representation; import std.algorithm.iteration : map; + import std.digest.hmac, std.digest.sha; + import std.string : representation; string data = "Hello, world"; auto digest = data.representation .map!(a => cast(ubyte)(a+1)) @@ -286,7 +286,7 @@ if (isDigest!H) version(unittest) { - import std.digest.digest : toHexString, LetterCase; + import std.digest.digest : LetterCase, toHexString; alias hex = toHexString!(LetterCase.lower); } diff --git a/std/digest/sha.d b/std/digest/sha.d index 5494e7b3186..4f661f7c2b9 100644 --- a/std/digest/sha.d +++ b/std/digest/sha.d @@ -882,8 +882,8 @@ alias SHA512_256 = SHA!(1024, 256); /// SHA alias for SHA-512/256, hash is ubyte @system unittest { - import std.range; import std.conv : hexString; + import std.range; ubyte[20] digest; ubyte[28] digest224; diff --git a/std/encoding.d b/std/encoding.d index 9e9da74725c..33249e1fb48 100644 --- a/std/encoding.d +++ b/std/encoding.d @@ -103,9 +103,9 @@ Distributed under the Boost Software License, Version 1.0. */ module std.encoding; +import std.range.primitives; import std.traits; import std.typecons; -import std.range.primitives; @system unittest { diff --git a/std/exception.d b/std/exception.d index 44854b87599..9c6d9089046 100644 --- a/std/exception.d +++ b/std/exception.d @@ -631,8 +631,8 @@ if (is(typeof(new E(__FILE__, __LINE__))) && !is(typeof(new E("", __FILE__, __LI @system unittest { - import std.array : empty; import core.exception : OutOfMemoryError; + import std.array : empty; assertNotThrown(enforceEx!Exception(true)); assertNotThrown(enforceEx!Exception(true, "blah")); assertNotThrown(enforceEx!OutOfMemoryError(true)); @@ -1511,7 +1511,7 @@ class ErrnoException : Exception @system unittest { - import core.stdc.errno : errno, EAGAIN; + import core.stdc.errno : EAGAIN, errno; auto old = errno; scope(exit) errno = old; @@ -1658,8 +1658,8 @@ CommonType!(T1, T2) ifThrown(T1, T2)(lazy scope T1 expression, scope T2 delegate //Verify Examples @system unittest { - import std.string; import std.conv; + import std.string; //Revert to a default value upon an error: assert("x".to!int().ifThrown(0) == 0); @@ -1690,9 +1690,9 @@ CommonType!(T1, T2) ifThrown(T1, T2)(lazy scope T1 expression, scope T2 delegate @system unittest { - import std.string; - import std.conv; import core.exception; + import std.conv; + import std.string; //Basic behaviour - all versions. assert("1".to!int().ifThrown(0) == 1); assert("x".to!int().ifThrown(0) == 0); @@ -2022,7 +2022,7 @@ pure @safe unittest { import std.algorithm.comparison : equal; import std.algorithm.iteration : map, splitter; - import std.conv : to, ConvException; + import std.conv : ConvException, to; auto s = "12,1337z32,54,2,7,9,1z,6,8"; diff --git a/std/experimental/allocator/building_blocks/affix_allocator.d b/std/experimental/allocator/building_blocks/affix_allocator.d index 761840dc54a..d4d6cc28b6a 100644 --- a/std/experimental/allocator/building_blocks/affix_allocator.d +++ b/std/experimental/allocator/building_blocks/affix_allocator.d @@ -19,15 +19,15 @@ The following methods are defined if $(D Allocator) defines them, and forward to */ struct AffixAllocator(Allocator, Prefix, Suffix = void) { + import std.algorithm.comparison : min; import std.conv : emplace; + import std.experimental.allocator : IAllocator, theAllocator; import std.experimental.allocator.common : stateSize, forwardToMember, roundUpToMultipleOf, alignedAt, alignDownTo, roundUpToMultipleOf, hasStaticallyKnownAlignment; - import std.experimental.allocator : IAllocator, theAllocator; + import std.math : isPowerOf2; import std.traits : hasMember; - import std.algorithm.comparison : min; import std.typecons : Ternary; - import std.math : isPowerOf2; static if (hasStaticallyKnownAlignment!Allocator) { @@ -370,8 +370,8 @@ struct AffixAllocator(Allocator, Prefix, Suffix = void) @system unittest { + import std.experimental.allocator : IAllocator, theAllocator; import std.experimental.allocator.gc_allocator : GCAllocator; - import std.experimental.allocator : theAllocator, IAllocator; // One word before and after each allocation. auto A = AffixAllocator!(IAllocator, size_t, size_t)(theAllocator); @@ -419,8 +419,8 @@ struct AffixAllocator(Allocator, Prefix, Suffix = void) @system unittest { - import std.experimental.allocator.gc_allocator; import std.experimental.allocator; + import std.experimental.allocator.gc_allocator; import std.typecons : Ternary; alias MyAllocator = AffixAllocator!(GCAllocator, uint); auto a = MyAllocator.instance.makeArray!(shared int)(100); diff --git a/std/experimental/allocator/building_blocks/allocator_list.d b/std/experimental/allocator/building_blocks/allocator_list.d index bd212fbb4f2..1ea27a602fd 100644 --- a/std/experimental/allocator/building_blocks/allocator_list.d +++ b/std/experimental/allocator/building_blocks/allocator_list.d @@ -1,8 +1,8 @@ /// module std.experimental.allocator.building_blocks.allocator_list; -import std.experimental.allocator.common; import std.experimental.allocator.building_blocks.null_allocator; +import std.experimental.allocator.common; import std.experimental.allocator.gc_allocator; version(unittest) import std.stdio; @@ -64,11 +64,11 @@ called `factory`. */ struct AllocatorList(Factory, BookkeepingAllocator = GCAllocator) { - import std.traits : hasMember; import std.conv : emplace; - import std.typecons : Ternary; import std.experimental.allocator.building_blocks.stats_collector : StatsCollector, Options; + import std.traits : hasMember; + import std.typecons : Ternary; private enum ouroboros = is(BookkeepingAllocator == NullAllocator); @@ -536,10 +536,10 @@ template AllocatorList(alias factoryFunction, version(Posix) @system unittest { import std.algorithm.comparison : max; - import std.experimental.allocator.building_blocks.region : Region; import std.experimental.allocator.building_blocks.free_list : ContiguousFreeList; - import std.experimental.allocator.building_blocks.segregator : Segregator; import std.experimental.allocator.building_blocks.null_allocator : NullAllocator; + import std.experimental.allocator.building_blocks.region : Region; + import std.experimental.allocator.building_blocks.segregator : Segregator; import std.experimental.allocator.gc_allocator : GCAllocator; import std.experimental.allocator.mmap_allocator : MmapAllocator; diff --git a/std/experimental/allocator/building_blocks/bitmapped_block.d b/std/experimental/allocator/building_blocks/bitmapped_block.d index a0ded14ab68..24e27a9c5ed 100644 --- a/std/experimental/allocator/building_blocks/bitmapped_block.d +++ b/std/experimental/allocator/building_blocks/bitmapped_block.d @@ -1,8 +1,8 @@ /// module std.experimental.allocator.building_blocks.bitmapped_block; -import std.experimental.allocator.common; import std.experimental.allocator.building_blocks.null_allocator; +import std.experimental.allocator.common; /** @@ -45,15 +45,15 @@ block size to the constructor. struct BitmappedBlock(size_t theBlockSize, uint theAlignment = platformAlignment, ParentAllocator = NullAllocator) { - import std.typecons : tuple, Tuple; - import std.traits : hasMember; import std.conv : text; + import std.traits : hasMember; import std.typecons : Ternary; + import std.typecons : tuple, Tuple; @system unittest { - import std.experimental.allocator.mallocator : AlignedMallocator; import std.algorithm.comparison : max; + import std.experimental.allocator.mallocator : AlignedMallocator; auto m = cast(ubyte[])(AlignedMallocator.instance.alignedAllocate(1024 * 64, max(theAlignment, cast(uint) size_t.sizeof))); scope(exit) AlignedMallocator.instance.deallocate(m); diff --git a/std/experimental/allocator/building_blocks/bucketizer.d b/std/experimental/allocator/building_blocks/bucketizer.d index e63c9274c59..64067ddc0ea 100644 --- a/std/experimental/allocator/building_blocks/bucketizer.d +++ b/std/experimental/allocator/building_blocks/bucketizer.d @@ -17,8 +17,8 @@ for $(D Bucketizer). To handle them separately, $(D Segregator) may be of use. */ struct Bucketizer(Allocator, size_t min, size_t max, size_t step) { - import std.traits : hasMember; import common = std.experimental.allocator.common : roundUpToMultipleOf; + import std.traits : hasMember; import std.typecons : Ternary; static assert((max - (min - 1)) % step == 0, @@ -220,13 +220,13 @@ struct Bucketizer(Allocator, size_t min, size_t max, size_t step) /// @system unittest { + import std.algorithm.comparison : max; import std.experimental.allocator.building_blocks.allocator_list : AllocatorList; import std.experimental.allocator.building_blocks.free_list : FreeList; import std.experimental.allocator.building_blocks.region : Region; - import std.experimental.allocator.mallocator : Mallocator; import std.experimental.allocator.common : unbounded; + import std.experimental.allocator.mallocator : Mallocator; import std.typecons : Ternary; - import std.algorithm.comparison : max; Bucketizer!( FreeList!( AllocatorList!( diff --git a/std/experimental/allocator/building_blocks/fallback_allocator.d b/std/experimental/allocator/building_blocks/fallback_allocator.d index f3f099dfaf0..ca7961b9274 100644 --- a/std/experimental/allocator/building_blocks/fallback_allocator.d +++ b/std/experimental/allocator/building_blocks/fallback_allocator.d @@ -256,9 +256,9 @@ struct FallbackAllocator(Primary, Fallback) @system unittest { + import std.conv : text; import std.experimental.allocator.building_blocks.region : InSituRegion; import std.experimental.allocator.gc_allocator : GCAllocator; - import std.conv : text; import std.typecons : Ternary; FallbackAllocator!(InSituRegion!16_384, GCAllocator) a; // This allocation uses the stack diff --git a/std/experimental/allocator/building_blocks/free_list.d b/std/experimental/allocator/building_blocks/free_list.d index 136e9b44db4..04e33d09a57 100644 --- a/std/experimental/allocator/building_blocks/free_list.d +++ b/std/experimental/allocator/building_blocks/free_list.d @@ -2,7 +2,7 @@ module std.experimental.allocator.building_blocks.free_list; import std.experimental.allocator.common; -import std.typecons : Flag, Yes, No; +import std.typecons : Flag, No, Yes; /** @@ -117,8 +117,8 @@ struct FreeList(ParentAllocator, /// @safe unittest { - import std.experimental.allocator.mallocator : Mallocator; import std.experimental.allocator.common : chooseAtRuntime; + import std.experimental.allocator.mallocator : Mallocator; FreeList!(Mallocator, chooseAtRuntime, chooseAtRuntime) a; a.min = 64; @@ -673,9 +673,9 @@ struct ContiguousFreeList(ParentAllocator, /// @safe unittest { - import std.experimental.allocator.gc_allocator : GCAllocator; import std.experimental.allocator.building_blocks.allocator_list : AllocatorList; + import std.experimental.allocator.gc_allocator : GCAllocator; import std.experimental.allocator.common : unbounded; @@ -896,8 +896,8 @@ struct SharedFreeList(ParentAllocator, /// @safe unittest { - import std.experimental.allocator.mallocator : Mallocator; import std.experimental.allocator.common : chooseAtRuntime; + import std.experimental.allocator.mallocator : Mallocator; shared SharedFreeList!(Mallocator, chooseAtRuntime, chooseAtRuntime) a; // Set the maxSize first so setting the minSize doesn't throw @@ -917,8 +917,8 @@ struct SharedFreeList(ParentAllocator, /// @safe unittest { - import std.experimental.allocator.mallocator : Mallocator; import std.experimental.allocator.common : chooseAtRuntime; + import std.experimental.allocator.mallocator : Mallocator; shared SharedFreeList!(Mallocator, 50, 50, chooseAtRuntime) a; // Set the maxSize first so setting the minSize doesn't throw @@ -1049,10 +1049,10 @@ struct SharedFreeList(ParentAllocator, @system unittest { + import core.thread : ThreadGroup; import std.algorithm.comparison : equal; - import std.range : repeat; import std.experimental.allocator.mallocator : Mallocator; - import core.thread : ThreadGroup; + import std.range : repeat; static shared SharedFreeList!(Mallocator, 64, 128, 10) a; diff --git a/std/experimental/allocator/building_blocks/free_tree.d b/std/experimental/allocator/building_blocks/free_tree.d index 6b64659297e..ad1192b108c 100644 --- a/std/experimental/allocator/building_blocks/free_tree.d +++ b/std/experimental/allocator/building_blocks/free_tree.d @@ -52,7 +52,7 @@ struct FreeTree(ParentAllocator) static assert(ParentAllocator.alignment % size_t.alignof == 0, "FreeTree must be on top of a word-aligned allocator"); - import std.algorithm.comparison : min, max; + import std.algorithm.comparison : max, min; import std.algorithm.mutation : swap; import std.traits : hasMember; diff --git a/std/experimental/allocator/building_blocks/kernighan_ritchie.d b/std/experimental/allocator/building_blocks/kernighan_ritchie.d index f331fba00b2..2a810b5775f 100644 --- a/std/experimental/allocator/building_blocks/kernighan_ritchie.d +++ b/std/experimental/allocator/building_blocks/kernighan_ritchie.d @@ -3,8 +3,8 @@ module std.experimental.allocator.building_blocks.kernighan_ritchie; import std.experimental.allocator.building_blocks.null_allocator; //debug = KRRegion; -debug(KRRegion) import std.stdio; version(unittest) import std.conv : text; +debug(KRRegion) import std.stdio; // KRRegion /** @@ -95,7 +95,7 @@ information is available in client code at deallocation time.) */ struct KRRegion(ParentAllocator = NullAllocator) { - import std.experimental.allocator.common : stateSize, alignedAt; + import std.experimental.allocator.common : alignedAt, stateSize; import std.traits : hasMember; import std.typecons : Ternary; @@ -615,9 +615,9 @@ fronting the GC allocator. */ @system unittest { - import std.experimental.allocator.gc_allocator : GCAllocator; import std.experimental.allocator.building_blocks.fallback_allocator : fallbackAllocator; + import std.experimental.allocator.gc_allocator : GCAllocator; import std.typecons : Ternary; // KRRegion fronting a general-purpose allocator ubyte[1024 * 128] buf; @@ -640,21 +640,21 @@ it actually returns memory to the operating system when possible. @system unittest { import std.algorithm.comparison : max; - import std.experimental.allocator.gc_allocator : GCAllocator; - import std.experimental.allocator.mmap_allocator : MmapAllocator; import std.experimental.allocator.building_blocks.allocator_list : AllocatorList; + import std.experimental.allocator.gc_allocator : GCAllocator; + import std.experimental.allocator.mmap_allocator : MmapAllocator; AllocatorList!(n => KRRegion!MmapAllocator(max(n * 16, 1024 * 1024))) alloc; } @system unittest { import std.algorithm.comparison : max; - import std.experimental.allocator.gc_allocator : GCAllocator; - import std.typecons : Ternary; - import std.experimental.allocator.mallocator : Mallocator; import std.experimental.allocator.building_blocks.allocator_list : AllocatorList; + import std.experimental.allocator.gc_allocator : GCAllocator; + import std.experimental.allocator.mallocator : Mallocator; + import std.typecons : Ternary; /* Create a scalable allocator consisting of 1 MB (or larger) blocks fetched from the garbage-collected heap. Each block is organized as a KR-style @@ -683,11 +683,11 @@ it actually returns memory to the operating system when possible. @system unittest { import std.algorithm.comparison : max; - import std.experimental.allocator.gc_allocator : GCAllocator; - import std.typecons : Ternary; - import std.experimental.allocator.mmap_allocator : MmapAllocator; import std.experimental.allocator.building_blocks.allocator_list : AllocatorList; + import std.experimental.allocator.gc_allocator : GCAllocator; + import std.experimental.allocator.mmap_allocator : MmapAllocator; + import std.typecons : Ternary; /* Create a scalable allocator consisting of 1 MB (or larger) blocks fetched from the garbage-collected heap. Each block is organized as a KR-style @@ -720,11 +720,11 @@ it actually returns memory to the operating system when possible. @system unittest { - import std.experimental.allocator.gc_allocator : GCAllocator; + import std.algorithm.comparison : max; import std.experimental.allocator.building_blocks.allocator_list : AllocatorList; - import std.algorithm.comparison : max; import std.experimental.allocator.common : testAllocator; + import std.experimental.allocator.gc_allocator : GCAllocator; testAllocator!(() => AllocatorList!( n => KRRegion!GCAllocator(max(n * 16, 1024 * 1024)))()); } @@ -755,9 +755,9 @@ it actually returns memory to the operating system when possible. cast(ubyte[])(GCAllocator.instance.allocate(1024 * 1024))); const store = alloc.allocate(KRRegion!().sizeof); auto p = cast(KRRegion!()* ) store.ptr; - import std.conv : emplace; - import std.algorithm.mutation : move; import core.stdc.string : memcpy; + import std.algorithm.mutation : move; + import std.conv : emplace; memcpy(p, &alloc, alloc.sizeof); emplace(&alloc); diff --git a/std/experimental/allocator/building_blocks/quantizer.d b/std/experimental/allocator/building_blocks/quantizer.d index 38a061d7454..b3f205dcc61 100644 --- a/std/experimental/allocator/building_blocks/quantizer.d +++ b/std/experimental/allocator/building_blocks/quantizer.d @@ -212,8 +212,8 @@ struct Quantizer(ParentAllocator, alias roundingFunction) @system unittest { import std.experimental.allocator.building_blocks.free_tree : FreeTree; - import std.experimental.allocator.gc_allocator : GCAllocator; import std.experimental.allocator.common : roundUpToMultipleOf; + import std.experimental.allocator.gc_allocator : GCAllocator; // Quantize small allocations to a multiple of cache line, large ones to a // multiple of page size diff --git a/std/experimental/allocator/building_blocks/region.d b/std/experimental/allocator/building_blocks/region.d index 3809b9dd7e4..6b1f7726e90 100644 --- a/std/experimental/allocator/building_blocks/region.d +++ b/std/experimental/allocator/building_blocks/region.d @@ -1,9 +1,9 @@ /// module std.experimental.allocator.building_blocks.region; -import std.experimental.allocator.common; import std.experimental.allocator.building_blocks.null_allocator; -import std.typecons : Flag, Yes, No; +import std.experimental.allocator.common; +import std.typecons : Flag, No, Yes; /** A $(D Region) allocator allocates memory straight from one contiguous chunk. @@ -329,10 +329,10 @@ struct Region(ParentAllocator = NullAllocator, /// @system unittest { - import std.experimental.allocator.mallocator : Mallocator; + import std.algorithm.comparison : max; import std.experimental.allocator.building_blocks.allocator_list : AllocatorList; - import std.algorithm.comparison : max; + import std.experimental.allocator.mallocator : Mallocator; // Create a scalable list of regions. Each gets at least 1MB at a time by // using malloc. auto batchAllocator = AllocatorList!( @@ -540,9 +540,9 @@ struct InSituRegion(size_t size, size_t minAlign = platformAlignment) : FallbackAllocator; import std.experimental.allocator.building_blocks.free_list : FreeList; - import std.experimental.allocator.gc_allocator : GCAllocator; import std.experimental.allocator.building_blocks.bitmapped_block : BitmappedBlock; + import std.experimental.allocator.gc_allocator : GCAllocator; FallbackAllocator!(InSituRegion!(128 * 1024), GCAllocator) r2; const a2 = r2.allocate(102); assert(a2.length == 102); diff --git a/std/experimental/allocator/building_blocks/segregator.d b/std/experimental/allocator/building_blocks/segregator.d index 2d8ecffb2c8..83520117935 100644 --- a/std/experimental/allocator/building_blocks/segregator.d +++ b/std/experimental/allocator/building_blocks/segregator.d @@ -277,8 +277,8 @@ struct Segregator(size_t threshold, SmallAllocator, LargeAllocator) @system unittest { import std.experimental.allocator.building_blocks.free_list : FreeList; - import std.experimental.allocator.mallocator : Mallocator; import std.experimental.allocator.gc_allocator : GCAllocator; + import std.experimental.allocator.mallocator : Mallocator; alias A = Segregator!( 1024 * 4, @@ -345,8 +345,8 @@ if (Args.length > 3) @system unittest { import std.experimental.allocator.building_blocks.free_list : FreeList; - import std.experimental.allocator.mallocator : Mallocator; import std.experimental.allocator.gc_allocator : GCAllocator; + import std.experimental.allocator.mallocator : Mallocator; alias A = Segregator!( 128, FreeList!(Mallocator, 0, 128), diff --git a/std/experimental/allocator/building_blocks/stats_collector.d b/std/experimental/allocator/building_blocks/stats_collector.d index 327c76b3618..aba084e8129 100644 --- a/std/experimental/allocator/building_blocks/stats_collector.d +++ b/std/experimental/allocator/building_blocks/stats_collector.d @@ -529,8 +529,8 @@ public: */ void reportStatistics(R)(auto ref R output) { - import std.traits : EnumMembers; import std.conv : to; + import std.traits : EnumMembers; foreach (e; EnumMembers!Options) { static if ((flags & e) && e != Options.numAll @@ -611,8 +611,8 @@ public: private PerCallStatistics* statsAt(string f, uint n, opts...)() { - import std.range : repeat; import std.array : array; + import std.range : repeat; static PerCallStatistics s = { f, n, [ opts ], repeat(0UL, opts.length).array }; @@ -656,8 +656,8 @@ public: /// @system unittest { - import std.experimental.allocator.gc_allocator : GCAllocator; import std.experimental.allocator.building_blocks.free_list : FreeList; + import std.experimental.allocator.gc_allocator : GCAllocator; alias Allocator = StatsCollector!(GCAllocator, Options.all, Options.all); Allocator alloc; @@ -666,8 +666,8 @@ public: alloc.deallocate(b); import std.file : deleteme, remove; - import std.stdio : File; import std.range : walkLength; + import std.stdio : File; auto f = deleteme ~ "-dlang.std.experimental.allocator.stats_collector.txt"; scope(exit) remove(f); @@ -705,8 +705,8 @@ public: assert(a.bytesUsed == 0); } - import std.experimental.allocator.gc_allocator : GCAllocator; import std.experimental.allocator.building_blocks.free_list : FreeList; + import std.experimental.allocator.gc_allocator : GCAllocator; test!(StatsCollector!(GCAllocator, Options.all, Options.all)); test!(StatsCollector!(FreeList!(GCAllocator, 128), Options.all, Options.all)); @@ -729,7 +729,7 @@ public: a.deallocate(b1); a.deallocate(b3); } - import std.experimental.allocator.gc_allocator : GCAllocator; import std.experimental.allocator.building_blocks.free_list : FreeList; + import std.experimental.allocator.gc_allocator : GCAllocator; test!(StatsCollector!(GCAllocator, 0, 0)); } diff --git a/std/experimental/allocator/common.d b/std/experimental/allocator/common.d index c1d2540b0c8..59a58151c9b 100644 --- a/std/experimental/allocator/common.d +++ b/std/experimental/allocator/common.d @@ -424,8 +424,8 @@ version(unittest) package void testAllocator(alias make)() { import std.conv : text; - import std.stdio : writeln, stderr; import std.math : isPowerOf2; + import std.stdio : stderr, writeln; import std.typecons : Ternary; alias A = typeof(make()); scope(failure) stderr.writeln("testAllocator failed for ", A.stringof); @@ -550,8 +550,8 @@ version(unittest) || is (AllocInterface : shared ISharedAllocator)) { import std.conv : text; - import std.stdio : writeln, stderr; import std.math : isPowerOf2; + import std.stdio : stderr, writeln; import std.typecons : Ternary; scope(failure) stderr.writeln("testAllocatorObject failed for ", AllocInterface.stringof); diff --git a/std/experimental/allocator/mallocator.d b/std/experimental/allocator/mallocator.d index 5dfdc999966..111ac759c17 100644 --- a/std/experimental/allocator/mallocator.d +++ b/std/experimental/allocator/mallocator.d @@ -230,7 +230,7 @@ struct AlignedMallocator @trusted @nogc nothrow void[] alignedAllocate(size_t bytes, uint a) shared { - import core.stdc.errno : ENOMEM, EINVAL; + import core.stdc.errno : EINVAL, ENOMEM; assert(a.isGoodDynamicAlignment); void* result; auto code = posix_memalign(&result, a, bytes); diff --git a/std/experimental/allocator/package.d b/std/experimental/allocator/package.d index d4724830490..19a32d712e2 100644 --- a/std/experimental/allocator/package.d +++ b/std/experimental/allocator/package.d @@ -229,15 +229,15 @@ public import std.experimental.allocator.common, // Example in the synopsis above @system unittest { - import std.algorithm.comparison : min, max; - import std.experimental.allocator.building_blocks.free_list : FreeList; - import std.experimental.allocator.gc_allocator : GCAllocator; - import std.experimental.allocator.building_blocks.segregator : Segregator; - import std.experimental.allocator.building_blocks.bucketizer : Bucketizer; + import std.algorithm.comparison : max, min; import std.experimental.allocator.building_blocks.allocator_list : AllocatorList; import std.experimental.allocator.building_blocks.bitmapped_block : BitmappedBlock; + import std.experimental.allocator.building_blocks.bucketizer : Bucketizer; + import std.experimental.allocator.building_blocks.free_list : FreeList; + import std.experimental.allocator.building_blocks.segregator : Segregator; + import std.experimental.allocator.gc_allocator : GCAllocator; alias FList = FreeList!(GCAllocator, 0, unbounded); alias A = Segregator!( @@ -601,10 +601,10 @@ allocator can be cast to $(D shared). @system unittest { - import std.experimental.allocator.mallocator : Mallocator; - import std.experimental.allocator.building_blocks.free_list : SharedFreeList; - import std.exception : assertThrown; import core.exception : AssertError; + import std.exception : assertThrown; + import std.experimental.allocator.building_blocks.free_list : SharedFreeList; + import std.experimental.allocator.mallocator : Mallocator; assert(processAllocator); assert(theAllocator); @@ -1320,8 +1320,8 @@ if (isInputRange!R && !isInfinite!R) /*pure*/ nothrow @safe unittest { import std.algorithm.comparison : equal; - import std.internal.test.dummyrange; import std.experimental.allocator.gc_allocator : GCAllocator; + import std.internal.test.dummyrange; import std.range : iota; foreach (DummyType; AllDummyRanges) { diff --git a/std/experimental/allocator/typed.d b/std/experimental/allocator/typed.d index 754c9359f0e..3ba0f3eecce 100644 --- a/std/experimental/allocator/typed.d +++ b/std/experimental/allocator/typed.d @@ -13,10 +13,10 @@ module std.experimental.allocator.typed; import std.experimental.allocator; import std.experimental.allocator.common; -import std.traits : isPointer, hasElaborateDestructor; -import std.typecons : Flag, Yes, No; import std.range : isInputRange, isForwardRange, walkLength, save, empty, front, popFront; +import std.traits : hasElaborateDestructor, isPointer; +import std.typecons : Flag, No, Yes; /** Allocation-related flags dictated by type characteristics. `TypedAllocator` @@ -122,9 +122,9 @@ type. */ struct TypedAllocator(PrimaryAllocator, Policies...) { - import std.typecons : Tuple; - import std.meta : AliasSeq; import std.algorithm.sorting : isSorted; + import std.meta : AliasSeq; + import std.typecons : Tuple; static assert(Policies.length == 0 || isSorted([Stride2!Policies])); diff --git a/std/experimental/checkedint.d b/std/experimental/checkedint.d index 3be83b4069c..d0640cd52a0 100644 --- a/std/experimental/checkedint.d +++ b/std/experimental/checkedint.d @@ -214,8 +214,8 @@ struct Checked(T, Hook = Abort) if (isIntegral!T || is(T == Checked!(U, H), U, H)) { import std.algorithm.comparison : among; - import std.traits : hasMember; import std.experimental.allocator.common : stateSize; + import std.traits : hasMember; /** The type of the integral subject to checking. @@ -1336,7 +1336,7 @@ struct Throw auto x1 = cast(T) x; assert(x1 == 42); x = T.max + 1; - import std.exception : assertThrown, assertNotThrown; + import std.exception : assertNotThrown, assertThrown; assertThrown(cast(T) x); x = x.max; assertThrown(x += 42); @@ -2277,7 +2277,7 @@ if (isIntegral!L && isIntegral!R) else alias Result = typeof(mixin("L() " ~ x ~ " R()")); - import core.checkedint : addu, adds, subs, muls, subu, mulu; + import core.checkedint : adds, addu, muls, mulu, subs, subu; import std.algorithm.comparison : among; static if (x == "==") { diff --git a/std/experimental/logger/core.d b/std/experimental/logger/core.d index 1d4fee6e8e0..d150cf5934d 100644 --- a/std/experimental/logger/core.d +++ b/std/experimental/logger/core.d @@ -1,10 +1,10 @@ /// module std.experimental.logger.core; +import core.sync.mutex : Mutex; import std.datetime; import std.range.primitives; import std.traits; -import core.sync.mutex : Mutex; import std.experimental.logger.filelogger; @@ -627,7 +627,7 @@ alias fatalf = defaultLogFunctionf!(LogLevel.fatal); private struct MsgRange { - import std.traits : isSomeString, isSomeChar; + import std.traits : isSomeChar, isSomeString; private Logger log; @@ -1939,7 +1939,7 @@ version(unittest) private void testFuncNames(Logger logger) @safe @safe unittest { import std.conv : to; - import std.exception : assertThrown, assertNotThrown; + import std.exception : assertNotThrown, assertThrown; import std.format : format; auto l = new TestLogger(LogLevel.all); @@ -2174,8 +2174,8 @@ version(unittest) private void testFuncNames(Logger logger) @safe @safe unittest { import std.conv : to; - import std.string : indexOf; import std.format : format; + import std.string : indexOf; auto oldunspecificLogger = sharedLog; @@ -2996,7 +2996,7 @@ private void trustedStore(T)(ref shared T dst, ref T src) @trusted // to shared logger @system unittest { - import std.concurrency, core.atomic, core.thread; + import core.atomic, core.thread, std.concurrency; static shared logged_count = 0; @@ -3139,9 +3139,9 @@ private void trustedStore(T)(ref shared T dst, ref T src) @trusted // Issue 15517 @system unittest { + import std.file : exists, remove; import std.stdio : File; import std.string : indexOf; - import std.file : exists, remove; string fn = "logfile.log"; if (exists(fn)) diff --git a/std/experimental/logger/filelogger.d b/std/experimental/logger/filelogger.d index 79d5baaab43..3b6e5ddddd7 100644 --- a/std/experimental/logger/filelogger.d +++ b/std/experimental/logger/filelogger.d @@ -1,8 +1,8 @@ /// module std.experimental.logger.filelogger; -import std.stdio; import std.experimental.logger.core; +import std.stdio; /** This $(D Logger) implementation writes log messages to the associated file. The name of the file has to be passed on construction time. If the file @@ -10,9 +10,9 @@ is already present new log messages will be append at its end. */ class FileLogger : Logger { - import std.format : formattedWrite; - import std.datetime : SysTime; import std.concurrency : Tid; + import std.datetime : SysTime; + import std.format : formattedWrite; /** A constructor for the $(D FileLogger) Logger. @@ -131,8 +131,8 @@ class FileLogger : Logger @system unittest { - import std.file : deleteme, remove; import std.array : empty; + import std.file : deleteme, remove; import std.string : indexOf; string filename = deleteme ~ __FUNCTION__ ~ ".tempLogFile"; @@ -160,8 +160,8 @@ class FileLogger : Logger @system unittest { - import std.file : deleteme, remove; import std.array : empty; + import std.file : deleteme, remove; import std.string : indexOf; string filename = deleteme ~ __FUNCTION__ ~ ".tempLogFile"; diff --git a/std/experimental/logger/multilogger.d b/std/experimental/logger/multilogger.d index 58ac051bcc1..ed9cfd9b1ef 100644 --- a/std/experimental/logger/multilogger.d +++ b/std/experimental/logger/multilogger.d @@ -105,8 +105,8 @@ class MultiLogger : Logger @safe unittest { - import std.experimental.logger.nulllogger; import std.exception : assertThrown; + import std.experimental.logger.nulllogger; auto a = new MultiLogger; auto n0 = new NullLogger(); auto n1 = new NullLogger(); diff --git a/std/experimental/logger/package.d b/std/experimental/logger/package.d index d0d141d1dba..b9a075c9f9f 100644 --- a/std/experimental/logger/package.d +++ b/std/experimental/logger/package.d @@ -181,5 +181,5 @@ module std.experimental.logger; public import std.experimental.logger.core; public import std.experimental.logger.filelogger; -public import std.experimental.logger.nulllogger; public import std.experimental.logger.multilogger; +public import std.experimental.logger.nulllogger; diff --git a/std/experimental/typecons.d b/std/experimental/typecons.d index 6b965439bc7..5a41567d636 100644 --- a/std/experimental/typecons.d +++ b/std/experimental/typecons.d @@ -512,7 +512,7 @@ version(StdDdoc) /// @system unittest { - import std.traits : functionAttributes, FunctionAttribute; + import std.traits : FunctionAttribute, functionAttributes; interface A { int run(); } interface B { int stop(); @property int status(); } class X @@ -661,7 +661,7 @@ template unwrap(Target) @system unittest { // Bugzilla 10377 - import std.range, std.algorithm; + import std.algorithm, std.range; interface MyInputRange(T) { @@ -1075,4 +1075,4 @@ pure nothrow @system unittest static assert(!__traits(compiles, arr.ptr++ )); -} \ No newline at end of file +} diff --git a/std/file.d b/std/file.d index 09d611a8141..d74de74a8e7 100644 --- a/std/file.d +++ b/std/file.d @@ -78,14 +78,14 @@ Source: $(PHOBOSSRC std/_file.d) */ module std.file; -import core.stdc.stdlib, core.stdc.string, core.stdc.errno; +import core.stdc.errno, core.stdc.stdlib, core.stdc.string; import std.datetime; +import std.internal.cstring; import std.meta; import std.range.primitives; import std.traits; import std.typecons; -import std.internal.cstring; version (Windows) { @@ -330,9 +330,9 @@ if (isConvertibleToString!R) version (Posix) private void[] readImpl(const(char)[] name, const(FSChar)* namez, size_t upTo = size_t.max) @trusted { + import core.memory : GC; import std.algorithm.comparison : min; import std.array : uninitializedArray; - import core.memory : GC; import std.conv : to; // A few internal configuration parameters { @@ -379,9 +379,9 @@ version (Posix) private void[] readImpl(const(char)[] name, const(FSChar)* namez version (Windows) private void[] readImpl(const(char)[] name, const(FSChar)* namez, size_t upTo = size_t.max) @safe { + import core.memory : GC; import std.algorithm.comparison : min; import std.array : uninitializedArray; - import core.memory : GC; static trustedCreateFileW(const(wchar)* namez, DWORD dwDesiredAccess, DWORD dwShareMode, SECURITY_ATTRIBUTES *lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) @trusted @@ -741,7 +741,7 @@ private void renameImpl(const(char)[] f, const(char)[] t, const(FSChar)* fromz, if (!result) { import core.stdc.wchar_ : wcslen; - import std.conv : to, text; + import std.conv : text, to; if (!f) f = to!(typeof(f))(fromz[0 .. wcslen(fromz)]); @@ -2321,7 +2321,7 @@ private bool ensureDirExists()(in char[] pathname) void mkdirRecurse(in char[] pathname) @safe { - import std.path : dirName, baseName; + import std.path : baseName, dirName; const left = dirName(pathname); if (left.length != pathname.length && !exists(left)) @@ -2338,7 +2338,7 @@ void mkdirRecurse(in char[] pathname) @safe { import std.exception : assertThrown; { - import std.path : buildPath, buildNormalizedPath; + import std.path : buildNormalizedPath, buildPath; immutable basepath = deleteme ~ "_dir"; scope(exit) () @trusted { rmdirRecurse(basepath); }(); @@ -2748,7 +2748,7 @@ else version (NetBSD) } else version (FreeBSD) { - import std.exception : errnoEnforce, assumeUnique; + import std.exception : assumeUnique, errnoEnforce; enum { CTL_KERN = 1, @@ -3436,7 +3436,7 @@ private void copyImpl(const(char)[] f, const(char)[] t, const(FSChar)* fromz, co else version(Posix) { static import core.stdc.stdio; - import std.conv : to, octal; + import std.conv : octal, to; immutable fdr = core.sys.posix.fcntl.open(fromz, O_RDONLY); cenforce(fdr != -1, f, fromz); @@ -3609,7 +3609,7 @@ version(Windows) @system unittest version(Posix) @system unittest { - import std.exception : enforce, collectException; + import std.exception : collectException, enforce; import std.process : executeShell; collectException(rmdirRecurse(deleteme)); auto d = deleteme~"/a/b/c/d/e/f/g"; @@ -3970,10 +3970,10 @@ auto dirEntries(string path, SpanMode mode, bool followSymlink = true) { string[] listdir(string pathname) { - import std.file; - import std.path; import std.algorithm; import std.array; + import std.file; + import std.path; return std.file.dirEntries(pathname, SpanMode.shallow) .filter!(a => a.isFile) @@ -3997,7 +3997,7 @@ auto dirEntries(string path, SpanMode mode, bool followSymlink = true) import std.algorithm.searching : startsWith; import std.array : array; import std.conv : to; - import std.path : dirEntries, buildPath, absolutePath; + import std.path : absolutePath, buildPath, dirEntries; import std.process : thisProcessID; import std.range.primitives : walkLength; @@ -4091,7 +4091,7 @@ auto dirEntries(string path, string pattern, SpanMode mode, bool followSymlink = true) { import std.algorithm.iteration : filter; - import std.path : globMatch, baseName; + import std.path : baseName, globMatch; bool f(DirEntry de) { return globMatch(baseName(de.name), pattern); } return filter!f(DirIterator(path, mode, followSymlink)); @@ -4199,11 +4199,11 @@ auto dirEntries(string path, string pattern, SpanMode mode, Select!(Types.length == 1, Types[0][], Tuple!(Types)[]) slurp(Types...)(string filename, in char[] format) { - import std.stdio : File; - import std.format : formattedRead; import std.array : appender; import std.conv : text; import std.exception : enforce; + import std.format : formattedRead; + import std.stdio : File; auto app = appender!(typeof(return))(); ElementType!(typeof(return)) toAdd; diff --git a/std/format.d b/std/format.d index a746008d640..04c043db20a 100644 --- a/std/format.d +++ b/std/format.d @@ -1003,8 +1003,8 @@ if (!is(Unqual!Char == Char)) struct FormatSpec(Char) if (is(Unqual!Char == Char)) { - import std.ascii : isDigit, isPunctuation, isAlpha; import std.algorithm.searching : startsWith; + import std.ascii : isAlpha, isDigit, isPunctuation; import std.conv : parse, text, to; /** @@ -2134,8 +2134,8 @@ Params: void formatValue(Writer, T, Char)(Writer w, T obj, const ref FormatSpec!Char f) if (is(FloatingPointTypeOf!T) && !is(T == enum) && !hasToString!(T, Char)) { - import std.algorithm.searching : find; import std.algorithm.comparison : min; + import std.algorithm.searching : find; import std.string : indexOf, indexOfAny, indexOfNeither; FormatSpec!Char fs = f; // fs is copy for change its values. @@ -2165,7 +2165,7 @@ if (is(FloatingPointTypeOf!T) && !is(T == enum) && !hasToString!(T, Char)) version (CRuntime_Microsoft) { - import std.math : isNaN, isInfinity; + import std.math : isInfinity, isNaN; immutable double tval = val; // convert early to get "inf" in case of overflow string s; if (isNaN(tval)) @@ -3076,8 +3076,8 @@ private void formatChar(Writer)(Writer w, in dchar c, in char quote) void formatElement(Writer, T, Char)(Writer w, T val, const ref FormatSpec!Char f) if (is(StringTypeOf!T) && !is(T == enum)) { - import std.utf : UTFException; import std.array : appender; + import std.utf : UTFException; StringTypeOf!T str = val; // bug 8015 @@ -3517,8 +3517,8 @@ if (is(T == class) && !is(T == enum)) +/ @safe pure unittest { - import std.format; import std.array : appender; + import std.format; auto writer1 = appender!string(); writer1.formattedWrite("%08b", 42); @@ -3653,8 +3653,8 @@ if (is(T == interface) && (hasToString!(T, Char) || !is(BuiltinTypeOf!T)) && !is // Issue 11175 version (Windows) { + import core.sys.windows.com : IID, IUnknown; import core.sys.windows.windows : HRESULT; - import core.sys.windows.com : IUnknown, IID; interface IUnknown2 : IUnknown { } @@ -4146,8 +4146,8 @@ version(unittest) void formatTest(T)(T val, string[] expected, size_t ln = __LINE__, string fn = __FILE__) { import core.exception : AssertError; - import std.conv : text; import std.array : appender; + import std.conv : text; FormatSpec!char f; auto w = appender!string(); formatValue(w, val, f); @@ -4164,8 +4164,8 @@ version(unittest) void formatTest(T)(string fmt, T val, string[] expected, size_t ln = __LINE__, string fn = __FILE__) @safe { import core.exception : AssertError; - import std.conv : text; import std.array : appender; + import std.conv : text; auto w = appender!string(); formattedWrite(w, fmt, val); foreach (cur; expected) @@ -4248,10 +4248,10 @@ void formatTest(T)(string fmt, T val, string[] expected, size_t ln = __LINE__, s @safe unittest { - import std.conv : text, octal; + import core.stdc.string : strlen; import std.array : appender; + import std.conv : octal, text; import std.c.stdio : snprintf; - import core.stdc.string : strlen; debug(format) printf("std.format.format.unittest\n"); @@ -5072,7 +5072,7 @@ private T unformatValueImpl(T, Range, Char)(ref Range input, const ref FormatSpe if (isInputRange!Range && isSomeChar!T && !is(T == enum) && isSomeChar!(ElementType!Range)) { import std.algorithm.searching : find; - import std.conv : to, text; + import std.conv : text, to; if (spec.spec == 's' || spec.spec == 'c') { auto result = to!T(input.front); @@ -5797,8 +5797,8 @@ if (isSomeString!(typeof(fmt))) immutable(Char)[] format(Char, Args...)(in Char[] fmt, Args args) if (isSomeChar!Char) { - import std.format : formattedWrite, FormatException; import std.array : appender; + import std.format : FormatException, formattedWrite; auto w = appender!(immutable(Char)[]); auto n = formattedWrite(w, fmt, args); version (all) @@ -5815,9 +5815,9 @@ if (isSomeChar!Char) @safe pure unittest { - import std.format; import core.exception; import std.exception; + import std.format; assertCTFEable!( { // assert(format(null) == ""); @@ -5874,8 +5874,8 @@ if (isSomeString!(typeof(fmt))) char[] sformat(Char, Args...)(char[] buf, in Char[] fmt, Args args) { import core.exception : RangeError; + import std.format : FormatException, formattedWrite; import std.utf : encode; - import std.format : formattedWrite, FormatException; size_t i; diff --git a/std/functional.d b/std/functional.d index a0f4c096c0c..44c9bb868d2 100644 --- a/std/functional.d +++ b/std/functional.d @@ -105,8 +105,8 @@ template unaryFun(alias fun, string parmName = "a") { static if (!fun._ctfeMatchUnary(parmName)) { - import std.traits, std.typecons, std.meta; import std.algorithm, std.conv, std.exception, std.math, std.range, std.string; + import std.meta, std.traits, std.typecons; } auto unaryFun(ElementType)(auto ref ElementType __a) { @@ -190,8 +190,8 @@ template binaryFun(alias fun, string parm1Name = "a", { static if (!fun._ctfeMatchBinary(parm1Name, parm2Name)) { - import std.traits, std.typecons, std.meta; import std.algorithm, std.conv, std.exception, std.math, std.range, std.string; + import std.meta, std.traits, std.typecons; } auto binaryFun(ElementType1, ElementType2) (auto ref ElementType1 __a, auto ref ElementType2 __b) @@ -259,7 +259,7 @@ template binaryFun(alias fun, string parm1Name = "a", private uint _ctfeSkipOp(ref string op) { if (!__ctfe) assert(false); - import std.ascii : isASCII, isAlphaNum; + import std.ascii : isAlphaNum, isASCII; immutable oldLength = op.length; while (op.length) { diff --git a/std/getopt.d b/std/getopt.d index 98d4eb62ebd..66194645bb9 100644 --- a/std/getopt.d +++ b/std/getopt.d @@ -28,8 +28,8 @@ Distributed under the Boost Software License, Version 1.0. */ module std.getopt; -import std.traits; import std.exception; // basicExceptionCtors +import std.traits; /** Thrown on one of the following conditions: @@ -560,8 +560,8 @@ follow this pattern: */ private template optionValidator(A...) { - import std.typecons : staticIota; import std.format : format; + import std.typecons : staticIota; enum fmt = "getopt validator: %s (at position %d)"; enum isReceiver(T) = isPointer!T || (is(T == function)) || (is(T == delegate)); @@ -941,8 +941,8 @@ private bool handleOption(R)(string option, R receiver, ref string[] args, alias V = typeof(receiver.values[0]); import std.range : only; - import std.typecons : Tuple, tuple; import std.string : indexOf; + import std.typecons : Tuple, tuple; static Tuple!(K, V) getter(string input) { @@ -1078,9 +1078,9 @@ private struct configuration private bool optMatch(string arg, string optPattern, ref string value, configuration cfg) @safe { - import std.uni : toUpper; - import std.string : indexOf; import std.array : split; + import std.string : indexOf; + import std.uni : toUpper; //writeln("optMatch:\n ", arg, "\n ", optPattern, "\n ", value); //scope(success) writeln("optMatch result: ", value); if (!arg.length || arg[0] != optionChar) return false; @@ -1428,8 +1428,8 @@ private void setConfig(ref configuration cfg, config option) @safe pure nothrow @system unittest // 5228 { - import std.exception; import std.conv; + import std.exception; auto args = ["prog", "--foo=bar"]; int abc; @@ -1614,8 +1614,8 @@ Params: */ void defaultGetoptFormatter(Output)(Output output, string text, Option[] opt) { + import std.algorithm.comparison : max, min; import std.format : formattedWrite; - import std.algorithm.comparison : min, max; output.formattedWrite("%s\n", text); @@ -1669,9 +1669,9 @@ void defaultGetoptFormatter(Output)(Output output, string text, Option[] opt) @system unittest { + import std.array ; import std.conv; import std.string; - import std.array ; bool a; auto args = ["prog", "--foo"]; auto t = getopt(args, config.required, "foo|f", "Help", &a); diff --git a/std/internal/cstring.d b/std/internal/cstring.d index 626ea9a0f7f..08b75e4f143 100644 --- a/std/internal/cstring.d +++ b/std/internal/cstring.d @@ -38,8 +38,8 @@ module std.internal.cstring; } } -import std.traits; import std.range; +import std.traits; version(unittest) @property inout(C)[] asArray(C)(inout C* cstr) pure nothrow @nogc @trusted @@ -159,8 +159,8 @@ if (isSomeChar!To && (isInputRange!From || isSomeString!From) && pragma(inline, false); // because it's rarely called import core.exception : onOutOfMemoryError; - import core.stdc.string : memcpy; import core.stdc.stdlib : malloc, realloc; + import core.stdc.string : memcpy; if (res_is_onstack) { diff --git a/std/internal/math/biguintcore.d b/std/internal/math/biguintcore.d index 7591a7ea8ac..6391a70a9f2 100644 --- a/std/internal/math/biguintcore.d +++ b/std/internal/math/biguintcore.d @@ -47,9 +47,9 @@ alias multibyteSub = multibyteAddSub!('-'); private import core.cpuid; -private import std.traits; -private import std.range.primitives; public import std.ascii : LetterCase; +private import std.range.primitives; +private import std.traits; shared static this() { diff --git a/std/internal/scopebuffer.d b/std/internal/scopebuffer.d index 007e277e352..8d7548a6eb2 100644 --- a/std/internal/scopebuffer.d +++ b/std/internal/scopebuffer.d @@ -98,8 +98,8 @@ if (isAssignable!T && !hasElaborateCopyConstructor!T && !hasElaborateAssign!T) { - import core.stdc.string : memcpy; import core.exception : onOutOfMemoryError; + import core.stdc.string : memcpy; /************************** diff --git a/std/internal/test/dummyrange.d b/std/internal/test/dummyrange.d index 6a6b08cb99b..d7191bdf064 100644 --- a/std/internal/test/dummyrange.d +++ b/std/internal/test/dummyrange.d @@ -5,8 +5,8 @@ Used with the dummy ranges for testing higher order ranges. module std.internal.test.dummyrange; import std.meta; -import std.typecons; import std.range.primitives; +import std.typecons; enum RangeType { @@ -390,8 +390,8 @@ if (is(T == TestFoo)) static auto iota(size_t low = 1, size_t high = 11) { - import std.range : iota; import std.algorithm.iteration : map; + import std.range : iota; return iota(cast(int) low, cast(int) high).map!(a => TestFoo(a)); } @@ -420,7 +420,7 @@ if (is(T == TestFoo)) @system unittest { import std.algorithm.comparison : equal; - import std.range : iota, retro, repeat; + import std.range : iota, repeat, retro; import std.traits : Unqual; static void testInputRange(T,Cmp)() diff --git a/std/json.d b/std/json.d index 7e9a62e41e8..14975e4ce72 100644 --- a/std/json.d +++ b/std/json.d @@ -17,9 +17,9 @@ Distributed under the Boost Software License, Version 1.0. */ module std.json; +import std.array; import std.conv; import std.range.primitives; -import std.array; import std.traits; /// @@ -100,7 +100,7 @@ JSON value node */ struct JSONValue { - import std.exception : enforceEx, enforce; + import std.exception : enforce, enforceEx; union Store { @@ -702,7 +702,7 @@ Params: JSONValue parseJSON(T)(T json, int maxDepth = -1, JSONOptions options = JSONOptions.none) if (isInputRange!T && !isInfinite!T && isSomeChar!(ElementEncodingType!T)) { - import std.ascii : isWhite, isDigit, isHexDigit, toUpper, toLower; + import std.ascii : isDigit, isHexDigit, isWhite, toLower, toUpper; import std.typecons : Yes; import std.utf : encode; @@ -1224,7 +1224,7 @@ string toJSON(const ref JSONValue root, in bool pretty = false, in JSONOptions o break; case JSON_TYPE.FLOAT: - import std.math : isNaN, isInfinity; + import std.math : isInfinity, isNaN; auto val = value.store.floating; @@ -1637,8 +1637,8 @@ EOF"; // handling of special float values (NaN, Inf, -Inf) @safe unittest { - import std.math : isNaN, isInfinity; import std.exception : assertThrown; + import std.math : isInfinity, isNaN; // expected representations of NaN and Inf enum { diff --git a/std/math.d b/std/math.d index 43c18187f5d..ed8abf8ad15 100644 --- a/std/math.d +++ b/std/math.d @@ -686,7 +686,7 @@ float sin(float x) @safe pure nothrow @nogc { return sin(cast(real) x); } /// @safe unittest { - import std.math : sin, PI; + import std.math : PI, sin; import std.stdio : writefln; void someFunc() diff --git a/std/mathspecial.d b/std/mathspecial.d index b0f6e3ec962..4b85189e94c 100644 --- a/std/mathspecial.d +++ b/std/mathspecial.d @@ -53,9 +53,9 @@ * Source: $(PHOBOSSRC std/_mathspecial.d) */ module std.mathspecial; -public import std.math; -private import std.internal.math.gammafunction; private import std.internal.math.errorfunction; +private import std.internal.math.gammafunction; +public import std.math; /* *********************************************** * GAMMA AND RELATED FUNCTIONS * diff --git a/std/meta.d b/std/meta.d index 6b946e1cb17..6a4d87b9345 100644 --- a/std/meta.d +++ b/std/meta.d @@ -1164,8 +1164,8 @@ template aliasSeqOf(alias range) @safe unittest { + import std.conv : octal, to; import std.range : iota; - import std.conv : to, octal; //Testing compile time octal foreach (I2; aliasSeqOf!(iota(0, 8))) foreach (I1; aliasSeqOf!(iota(0, 8))) diff --git a/std/mmfile.d b/std/mmfile.d index 4313b01bcd5..627abb37629 100644 --- a/std/mmfile.d +++ b/std/mmfile.d @@ -17,13 +17,13 @@ */ module std.mmfile; -private import std.file; +private import core.stdc.errno; private import core.stdc.stdio; private import core.stdc.stdlib; -private import core.stdc.errno; +import std.conv, std.exception, std.stdio; +private import std.file; private import std.path; private import std.string; -import std.conv, std.exception, std.stdio; import std.internal.cstring; @@ -38,9 +38,9 @@ version (Windows) else version (Posix) { private import core.sys.posix.fcntl; - private import core.sys.posix.unistd; private import core.sys.posix.sys.mman; private import core.sys.posix.sys.stat; + private import core.sys.posix.unistd; } else { @@ -635,8 +635,8 @@ private: @system unittest { - import std.file : deleteme; import core.memory : GC; + import std.file : deleteme; const size_t K = 1024; size_t win = 64*K; // assume the page size is 64K @@ -681,8 +681,8 @@ private: version(linux) @system unittest // Issue 14868 { - import std.typecons : scoped; import std.file : deleteme; + import std.typecons : scoped; // Test retaining ownership of File/fd diff --git a/std/net/curl.d b/std/net/curl.d index 711c49819c6..a7fe0d3a9f7 100644 --- a/std/net/curl.d +++ b/std/net/curl.d @@ -175,8 +175,8 @@ version(unittest) { // Run unit test with the PHOBOS_TEST_ALLOW_NET=1 set in order to // allow net traffic - import std.stdio; import std.range; + import std.stdio; import std.socket : Address, INADDR_LOOPBACK, Socket, TcpSocket; @@ -238,7 +238,7 @@ version(unittest) private Request!T recvReq(T=char)(Socket s) { import std.algorithm.comparison : min; - import std.algorithm.searching : find, canFind; + import std.algorithm.searching : canFind, find; import std.conv : to; import std.regex : ctRegex, matchFirst; @@ -1287,7 +1287,7 @@ if (isCurlConn!Conn && isSomeChar!Char && isSomeChar!Terminator) void popFront() { - import std.algorithm.searching : findSplitAfter, findSplit; + import std.algorithm.searching : findSplit, findSplitAfter; enforce!CurlException(currentValid, "Cannot call popFront() on empty range"); if (lines.empty) @@ -2417,7 +2417,7 @@ struct HTTP { import std.algorithm.searching : startsWith; import std.conv : to; - import std.regex : regex, match; + import std.regex : match, regex; import std.uni : toLower; // Wrap incoming callback in order to separate http status line from @@ -4061,7 +4061,7 @@ class CurlTimeoutException : CurlException /// Equal to $(REF CURLcode, etc,c,curl) alias CurlCode = CURLcode; -import std.typecons : Flag, Yes, No; +import std.typecons : Flag, No, Yes; /// Flag to specify whether or not an exception is thrown on error. alias ThrowOnError = Flag!"throwOnError"; @@ -4099,7 +4099,7 @@ private struct CurlAPI { version (Posix) { - import core.sys.posix.dlfcn : dlsym, dlopen, dlclose, RTLD_LAZY; + import core.sys.posix.dlfcn : dlclose, dlopen, dlsym, RTLD_LAZY; alias loadSym = dlsym; } else version (Windows) diff --git a/std/net/isemail.d b/std/net/isemail.d index c2c80c11f77..3998917a50b 100644 --- a/std/net/isemail.d +++ b/std/net/isemail.d @@ -28,7 +28,7 @@ module std.net.isemail; import std.range.primitives; // : ElementType; import std.regex; import std.traits; -import std.typecons : Flag, Yes, No; +import std.typecons : Flag, No, Yes; /** * Check that an email address conforms to RFCs 5321, 5322 and others. @@ -62,11 +62,11 @@ EmailStatus isEmail(Char)(const(Char)[] email, CheckDns checkDNS = No.checkDns, EmailStatusCode errorLevel = EmailStatusCode.none) if (isSomeChar!(Char)) { - import std.algorithm.iteration : uniq, filter, map; + import std.algorithm.iteration : filter, map, uniq; import std.algorithm.searching : canFind, maxElement; - import std.exception : enforce; import std.array : array, split; import std.conv : to; + import std.exception : enforce; import std.string : indexOf, lastIndexOf; import std.uni : isNumber; diff --git a/std/numeric.d b/std/numeric.d index c6cea6fc608..508f64f88a5 100644 --- a/std/numeric.d +++ b/std/numeric.d @@ -128,7 +128,7 @@ if (((flags & flags.signed) + precision + exponentWidth) % 8 == 0 && precision + /// @safe unittest { - import std.math : sin, cos; + import std.math : cos, sin; // Define a 16-bit floating point values CustomFloat!16 x; // Using the number of bits @@ -2187,10 +2187,10 @@ F gapWeightedSimilarity(alias comp = "a == b", R1, R2, F)(R1 s, R2 t, F lambda) if (isRandomAccessRange!(R1) && hasLength!(R1) && isRandomAccessRange!(R2) && hasLength!(R2)) { - import std.functional : binaryFun; - import std.algorithm.mutation : swap; - import core.stdc.stdlib : malloc, free; import core.exception : onOutOfMemoryError; + import core.stdc.stdlib : free, malloc; + import std.algorithm.mutation : swap; + import std.functional : binaryFun; if (s.length < t.length) return gapWeightedSimilarity(t, s, lambda); if (!t.length) return 0; @@ -2316,7 +2316,7 @@ optimizations. struct GapWeightedSimilarityIncremental(Range, F = double) if (isRandomAccessRange!(Range) && hasLength!(Range)) { - import core.stdc.stdlib : malloc, realloc, alloca, free; + import core.stdc.stdlib : alloca, free, malloc, realloc; private: Range s, t; @@ -2765,8 +2765,8 @@ private alias lookup_t = float; */ final class Fft { - import std.algorithm.iteration : map; import core.bitop : bsf; + import std.algorithm.iteration : map; import std.array : uninitializedArray; private: @@ -3255,8 +3255,8 @@ void inverseFft(Ret, R)(R range, Ret buf) @system unittest { import std.algorithm; - import std.range; import std.conv; + import std.range; // Test values from R and Octave. auto arr = [1,2,3,4,5,6,7,8]; auto fft1 = fft(arr); diff --git a/std/outbuffer.d b/std/outbuffer.d index f136c8f42b1..913a29881fd 100644 --- a/std/outbuffer.d +++ b/std/outbuffer.d @@ -241,9 +241,9 @@ class OutBuffer void vprintf(string format, va_list args) @trusted nothrow { - import std.string : toStringz; import core.stdc.stdio : vsnprintf; import core.stdc.stdlib : alloca; + import std.string : toStringz; version (unittest) char[3] buffer = void; // trigger reallocation diff --git a/std/parallelism.d b/std/parallelism.d index a079458422c..42b87c74e10 100644 --- a/std/parallelism.d +++ b/std/parallelism.d @@ -44,9 +44,9 @@ module std.parallelism; @system unittest { import std.algorithm.iteration : map; - import std.range : iota; import std.math : approxEqual; import std.parallelism : taskPool; + import std.range : iota; // Parallel reduce can be combined with // std.algorithm.iteration.map to interesting effect. @@ -105,7 +105,7 @@ version(Windows) // BUGS: Only works on Windows 2000 and above. shared static this() { - import core.sys.windows.windows : SYSTEM_INFO, GetSystemInfo; + import core.sys.windows.windows : GetSystemInfo, SYSTEM_INFO; import std.algorithm.comparison : max; SYSTEM_INFO si; @@ -118,7 +118,7 @@ else version(linux) { shared static this() { - import core.sys.posix.unistd : _SC_NPROCESSORS_ONLN, sysconf; + import core.sys.posix.unistd : sysconf, _SC_NPROCESSORS_ONLN; totalCPUs = cast(uint) sysconf(_SC_NPROCESSORS_ONLN); } } @@ -126,7 +126,7 @@ else version(Solaris) { shared static this() { - import core.sys.posix.unistd : _SC_NPROCESSORS_ONLN, sysconf; + import core.sys.posix.unistd : sysconf, _SC_NPROCESSORS_ONLN; totalCPUs = cast(uint) sysconf(_SC_NPROCESSORS_ONLN); } } @@ -2625,7 +2625,7 @@ public: byte[maxStack] buf = void; immutable size_t nBytesNeeded = nWorkUnits * RTask.sizeof; - import core.stdc.stdlib : malloc, free; + import core.stdc.stdlib : free, malloc; if (nBytesNeeded < maxStack) { tasks = (cast(RTask*) buf.ptr)[0 .. nWorkUnits]; @@ -3372,7 +3372,7 @@ private void submitAndExecute( immutable nThreads = pool.size + 1; alias PTask = typeof(scopedTask(doIt)); - import core.stdc.stdlib : malloc, free; + import core.stdc.stdlib : free, malloc; import core.stdc.string : memcpy; // The logical thing to do would be to just use alloca() here, but that @@ -3931,12 +3931,12 @@ version(unittest) // These are the tests that should be run every time Phobos is compiled. @system unittest { + import std.algorithm.comparison : equal, max, min; import std.algorithm.iteration : filter, map, reduce; - import std.algorithm.comparison : equal, min, max; import std.array : split; import std.conv : text; import std.exception : assertThrown; - import std.math : approxEqual, sqrt, log; + import std.math : approxEqual, log, sqrt; import std.range : indexed, iota, join; import std.typecons : Tuple, tuple; diff --git a/std/path.d b/std/path.d index 1aafe469062..9b3049fe181 100644 --- a/std/path.d +++ b/std/path.d @@ -98,9 +98,9 @@ module std.path; // FIXME import std.file; //: getcwd; +static import std.meta; import std.range.primitives; import std.traits; -static import std.meta; version (unittest) { @@ -641,7 +641,7 @@ if (isRandomAccessRange!R && hasSlicing!R && hasLength!R && isSomeChar!(ElementT static assert(dirName("dir/file") == "dir"); import std.array; - import std.utf : byChar, byWchar, byDchar; + import std.utf : byChar, byDchar, byWchar; assert(dirName("".byChar).array == "."); assert(dirName("file"w.byWchar).array == "."w); @@ -1075,7 +1075,7 @@ if (isConvertibleToString!R) assert(stripExtension("file.ext1.ext2"d) == "file.ext1"); import std.array; - import std.utf : byChar, byWchar, byDchar; + import std.utf : byChar, byDchar, byWchar; assert(stripExtension("file".byChar).array == "file"); assert(stripExtension("file.ext"w.byWchar).array == "file"); @@ -1187,7 +1187,7 @@ if ((isRandomAccessRange!R && hasSlicing!R && hasLength!R && isSomeChar!(Element !isConvertibleToString!R && isSomeChar!C) { - import std.range : only, chain; + import std.range : chain, only; import std.utf : byUTF; alias CR = Unqual!(ElementEncodingType!R); @@ -1279,7 +1279,7 @@ if ((isRandomAccessRange!R && hasSlicing!R && hasLength!R && isSomeChar!(Element !isConvertibleToString!R && isSomeChar!C) { - import std.range : only, chain; + import std.range : chain, only; import std.utf : byUTF; alias CR = Unqual!(ElementEncodingType!R); @@ -1539,7 +1539,7 @@ if ((isRandomAccessRange!R1 && hasSlicing!R1 && hasLength!R1 && isSomeChar!(Elem } else { - import std.range : only, chain; + import std.range : chain, only; import std.utf : byUTF; alias CR = Unqual!(ElementEncodingType!R1); @@ -2395,8 +2395,8 @@ if (isConvertibleToString!R) { // equal2 verifies that the range is the same both ways, i.e. // through front/popFront and back/popBack. - import std.range; import std.algorithm; + import std.range; bool equal2(R1, R2)(R1 r1, R2 r2) { static assert(isBidirectionalRange!R1); @@ -2903,12 +2903,12 @@ if ((isNarrowString!R1 || basePS.popFront(); pathPS.popFront(); - import std.range.primitives : walkLength; - import std.range : repeat, chain, choose; import std.algorithm.comparison : mismatch; import std.algorithm.iteration : joiner; import std.array : array; - import std.utf : byCodeUnit, byChar; + import std.range : chain, choose, repeat; + import std.range.primitives : walkLength; + import std.utf : byChar, byCodeUnit; // Remove matching prefix from basePS and pathPS auto tup = mismatch!((a, b) => filenameCmp!cs(a, b) == 0)(basePS, pathPS); @@ -3849,9 +3849,9 @@ string expandTilde(string inputPath) nothrow { version(Posix) { - import core.stdc.stdlib : malloc, free, realloc; import core.exception : onOutOfMemoryError; - import core.stdc.errno : errno, ERANGE; + import core.stdc.errno : ERANGE, errno; + import core.stdc.stdlib : free, malloc, realloc; /* Joins a path from a C string to the remainder of path. @@ -3913,7 +3913,7 @@ string expandTilde(string inputPath) nothrow } else { - import core.sys.posix.pwd : passwd, getpwnam_r; + import core.sys.posix.pwd : getpwnam_r, passwd; import std.string : indexOf; assert(path.length > 2 || (path.length == 2 && !isDirSeparator(path[1]))); diff --git a/std/process.d b/std/process.d index e0182cb40be..a2b39ab2ac4 100644 --- a/std/process.d +++ b/std/process.d @@ -87,8 +87,8 @@ module std.process; version (Posix) { - import core.sys.posix.unistd; import core.sys.posix.sys.wait; + import core.sys.posix.unistd; } version (Windows) { @@ -98,10 +98,10 @@ version (Windows) import std.windows.syserror; } +import std.internal.cstring; +import std.internal.processinit; import std.range.primitives; import std.stdio; -import std.internal.processinit; -import std.internal.cstring; // When the DMC runtime is used, we have to use some custom functions @@ -350,9 +350,9 @@ private Pid spawnProcessImpl(in char[][] args, @trusted // TODO: Should be @safe { import core.exception : RangeError; + import std.algorithm.searching : any; import std.conv : text; import std.path : isDirSeparator; - import std.algorithm.searching : any; import std.string : toStringz; if (args.empty) throw new RangeError(); @@ -386,7 +386,7 @@ private Pid spawnProcessImpl(in char[][] args, scope(exit) if (workDirFD >= 0) close(workDirFD); if (workDir.length) { - import core.sys.posix.fcntl : open, O_RDONLY, stat_t, fstat, S_ISDIR; + import core.sys.posix.fcntl : fstat, open, O_RDONLY, stat_t, S_ISDIR; workDirFD = open(workDir.tempCString(), O_RDONLY); if (workDirFD < 0) throw ProcessException.newFromErrno("Failed to open working directory"); @@ -448,9 +448,9 @@ private Pid spawnProcessImpl(in char[][] args, setCLOEXEC(STDERR_FILENO, false); if (!(config & Config.inheritFDs)) { - import core.sys.posix.poll : pollfd, poll, POLLNVAL; - import core.sys.posix.sys.resource : rlimit, getrlimit, RLIMIT_NOFILE; import core.stdc.stdlib : malloc; + import core.sys.posix.poll : poll, pollfd, POLLNVAL; + import core.sys.posix.sys.resource : getrlimit, rlimit, RLIMIT_NOFILE; // Get the maximum number of file descriptors that could be open. rlimit r; @@ -739,8 +739,8 @@ version (Posix) private string searchPathFor(in char[] executable) @trusted //TODO: @safe nothrow { - import std.conv : to; import std.algorithm.iteration : splitter; + import std.conv : to; import std.path : buildPath; auto pathz = core.stdc.stdlib.getenv("PATH"); @@ -778,7 +778,7 @@ version (Posix) @safe unittest version (Posix) private void setCLOEXEC(int fd, bool on) nothrow @nogc { - import core.sys.posix.fcntl : fcntl, F_GETFD, FD_CLOEXEC, F_SETFD; + import core.sys.posix.fcntl : fcntl, FD_CLOEXEC, F_GETFD, F_SETFD; auto flags = fcntl(fd, F_GETFD); if (flags >= 0) { @@ -813,12 +813,12 @@ version (Posix) @system unittest { import core.sys.posix.fcntl : open, O_RDONLY; import core.sys.posix.unistd : close; - import std.path : buildPath; import std.algorithm.searching : canFind, findSplitBefore; - import std.functional : reverseArgs; import std.array : split; import std.conv : to; static import std.file; + import std.functional : reverseArgs; + import std.path : buildPath; auto directory = uniqueTempPath(); std.file.mkdir(directory); @@ -926,8 +926,8 @@ version (Posix) @system unittest @system unittest // Stream redirection in spawnProcess(). { - import std.string; import std.path : buildPath; + import std.string; version (Windows) TestScript prog = "set /p INPUT= echo %INPUT% output %~1 @@ -1590,7 +1590,7 @@ void kill(Pid pid, int codeOrSignal) } else version (Posix) { - import core.sys.posix.signal : SIGTERM, SIGKILL; + import core.sys.posix.signal : SIGKILL, SIGTERM; TestScript prog = "while true; do sleep 1; done"; } auto pid = spawnProcess(prog.path); @@ -2236,9 +2236,9 @@ private auto executeImpl(alias pipeFunc, Cmd, ExtraPipeFuncArgs...)( in char[] workDir = null, ExtraPipeFuncArgs extraArgs = ExtraPipeFuncArgs.init) { - import std.typecons : Tuple; - import std.array : appender; import std.algorithm.comparison : min; + import std.array : appender; + import std.typecons : Tuple; auto p = pipeFunc(commandLine, Redirect.stdout | Redirect.stderrToStdout, env, config, workDir, extraArgs); @@ -2491,7 +2491,7 @@ private struct TestScript ~this() { - import std.file : remove, exists; + import std.file : exists, remove; if (!path.empty && exists(path)) { try { remove(path); } @@ -2806,10 +2806,10 @@ if (is(typeof(allocator(size_t.init)[0] = char.init))) version(Windows) version(unittest) { - import core.sys.windows.shellapi : CommandLineToArgvW; - import core.sys.windows.windows; import core.stdc.stddef; import core.stdc.wchar_ : wcslen; + import core.sys.windows.shellapi : CommandLineToArgvW; + import core.sys.windows.windows; import std.array; string[] parseCommandLine(string line) @@ -3469,14 +3469,14 @@ Distributed under the Boost Software License, Version 1.0. */ -import core.stdc.stdlib; import core.stdc.errno; -import core.thread; +import core.stdc.stdlib; import core.stdc.string; +import core.thread; version (Windows) { - import std.format, std.random, std.file; + import std.file, std.format, std.random; } version (Posix) { @@ -3484,7 +3484,7 @@ version (Posix) } version (unittest) { - import std.file, std.conv, std.random; + import std.conv, std.file, std.random; } diff --git a/std/random.d b/std/random.d index 5148ac86f5f..9cf7469c401 100644 --- a/std/random.d +++ b/std/random.d @@ -917,9 +917,9 @@ alias Mt19937_64 = MersenneTwisterEngine!(ulong, 64, 312, 156, 31, @safe unittest { + import std.algorithm; import std.exception; import std.range; - import std.algorithm; Mt19937 gen; @@ -1287,7 +1287,7 @@ A single unsigned integer seed value, different on each successive call */ @property uint unpredictableSeed() @trusted { - import core.thread : Thread, getpid, MonoTime; + import core.thread : getpid, MonoTime, Thread; static bool seeded; static MinstdRand0 rand; if (!seeded) @@ -1424,8 +1424,8 @@ auto uniform(string boundaries = "[)", (T1 a, T2 b, ref UniformRandomNumberGenerator urng) if (isFloatingPoint!(CommonType!(T1, T2)) && isUniformRNG!UniformRandomNumberGenerator) { - import std.exception : enforce; import std.conv : text; + import std.exception : enforce; alias NumberType = Unqual!(CommonType!(T1, T2)); static if (boundaries[0] == '(') { @@ -1523,8 +1523,8 @@ auto uniform(string boundaries = "[)", T1, T2, RandomGen) if ((isIntegral!(CommonType!(T1, T2)) || isSomeChar!(CommonType!(T1, T2))) && isUniformRNG!RandomGen) { - import std.exception : enforce; import std.conv : text, unsigned; + import std.exception : enforce; alias ResultType = Unqual!(CommonType!(T1, T2)); static if (boundaries[0] == '(') { @@ -1966,8 +1966,8 @@ if (isFloatingPoint!F) @safe unittest { - import std.math; import std.algorithm; + import std.math; static assert(is(CommonType!(double, int) == double)); auto a = uniformDistribution(5); assert(a.length == 5); @@ -2048,8 +2048,8 @@ if (isRandomAccessRange!Range && hasLength!Range && isUniformRNG!RandomGen) @system unittest { - import std.algorithm.searching : canFind; import std.algorithm.iteration : map; + import std.algorithm.searching : canFind; auto array = [1, 2, 3, 4, 5]; auto elemAddr = &choice(array); @@ -2123,8 +2123,8 @@ Params: void partialShuffle(Range, RandomGen)(Range r, in size_t n, ref RandomGen gen) if (isRandomAccessRange!Range && isUniformRNG!RandomGen) { - import std.exception : enforce; import std.algorithm.mutation : swapAt; + import std.exception : enforce; enforce(n <= r.length, "n must be <= r.length for partialShuffle."); foreach (i; 0 .. n) { @@ -2242,8 +2242,8 @@ in } body { - import std.exception : enforce; import std.algorithm.iteration : reduce; + import std.exception : enforce; double sum = reduce!"a + b"(0.0, proportions.save); enforce(sum > 0, "Proportions in a dice cannot sum to zero"); immutable point = uniform(0.0, sum, rng); @@ -2659,8 +2659,8 @@ if (isInputRange!Range && (isUniformRNG!UniformRNG || is(UniformRNG == void))) private void initialize(size_t howMany, size_t total) { - import std.exception : enforce; import std.conv : text; + import std.exception : enforce; _available = total; _toSelect = howMany; enforce(_toSelect <= _available, @@ -3011,9 +3011,9 @@ if (isInputRange!Range && hasLength!Range && isUniformRNG!UniformRNG) @system unittest { // @system because it takes the address of a local + import std.conv : text; import std.exception; import std.range; - import std.conv : text; // For test purposes, an infinite input range struct TestInputRange { diff --git a/std/range/interfaces.d b/std/range/interfaces.d index e519a667e90..76d00e38ff8 100644 --- a/std/range/interfaces.d +++ b/std/range/interfaces.d @@ -519,9 +519,9 @@ template outputRangeObject(E...) { @system unittest { - import std.internal.test.dummyrange; import std.algorithm.comparison : equal; import std.array; + import std.internal.test.dummyrange; static void testEquality(R)(iInputRange r1, R r2) { assert(equal(r1, r2)); diff --git a/std/range/package.d b/std/range/package.d index ec8280f6af2..6da8f9d90a6 100644 --- a/std/range/package.d +++ b/std/range/package.d @@ -227,10 +227,10 @@ to $(HTTP fantascienza.net/leonardo/so/, Leonardo Maffi). */ module std.range; -public import std.range.primitives; -public import std.range.interfaces; public import std.array; -public import std.typecons : Flag, Yes, No; +public import std.range.interfaces; +public import std.range.primitives; +public import std.typecons : Flag, No, Yes; import std.meta; // allSatisfy, staticMap import std.traits; // CommonType, isCallable, isFloatingPoint, isIntegral, @@ -1221,8 +1221,8 @@ pure @safe nothrow unittest */ pure @safe nothrow unittest { - import std.algorithm.sorting : sort; import std.algorithm.comparison : equal; + import std.algorithm.sorting : sort; int[] arr1 = [5, 2, 8]; int[] arr2 = [3, 7, 9]; @@ -2871,8 +2871,8 @@ pure @safe nothrow unittest // tail --lines=n import std.algorithm.comparison : equal; import std.algorithm.iteration : joiner; - import std.string : lineSplitter; import std.exception : assumeWontThrow; + import std.string : lineSplitter; assert("one\ntwo\nthree" .lineSplitter .tail(2) @@ -4197,7 +4197,7 @@ if (Ranges.length && allSatisfy!(isInputRange, Ranges)) return ranges[0].length; //[min|max](ranges[0].length, ranges[1].length, ...) - import std.algorithm.comparison : min, max; + import std.algorithm.comparison : max, min; if (stoppingPolicy == StoppingPolicy.shortest) return mixin(q{min(%(ranges[%s].length%|, %))}.format(iota(0, R.length))); else @@ -4360,7 +4360,7 @@ enum StoppingPolicy import std.algorithm.mutation : swap; import std.algorithm.sorting : sort; - import std.exception : assertThrown, assertNotThrown; + import std.exception : assertNotThrown, assertThrown; import std.typecons : tuple; int[] a = [ 1, 2, 3 ]; @@ -5593,7 +5593,7 @@ debug @system unittest { import std.algorithm.comparison : equal; import std.algorithm.searching : count; - import std.math : approxEqual, nextUp, nextDown; + import std.math : approxEqual, nextDown, nextUp; import std.meta : AliasSeq; static assert(is(ElementType!(typeof(iota(0f))) == float)); @@ -7815,8 +7815,8 @@ public: /// @safe pure nothrow unittest { - import std.array : array; import std.algorithm.comparison : equal; + import std.array : array; assert([0, 1, 2, 3].slide(2).equal!equal( [[0, 1], [1, 2], [2, 3]] @@ -7870,8 +7870,8 @@ public: // different window sizes @safe pure nothrow unittest { - import std.array : array; import std.algorithm.comparison : equal; + import std.array : array; assert([0, 1, 2, 3].slide(1).array == [[0], [1], [2], [3]]); assert([0, 1, 2, 3].slide(2).array == [[0, 1], [1, 2], [2, 3]]); @@ -7985,8 +7985,8 @@ public: // test slicing, length @safe pure nothrow unittest { - import std.array : array; import std.algorithm.comparison : equal; + import std.array : array; // test index assert(iota(3).slide(4)[0].equal([0, 1, 2])); @@ -8170,7 +8170,7 @@ public: @safe pure nothrow unittest { import std.algorithm.comparison : equal; - import std.internal.test.dummyrange : DummyRange, Length, RangeType, ReturnBy, AllDummyRanges; + import std.internal.test.dummyrange : AllDummyRanges, DummyRange, Length, RangeType, ReturnBy; import std.meta : AliasSeq; alias AllForwardDummyRanges = AliasSeq!( @@ -10729,7 +10729,7 @@ if (isInputRange!R && is(R == class)) @safe unittest // bug 9060 { - import std.algorithm.iteration : map, joiner, group; + import std.algorithm.iteration : group, joiner, map; import std.algorithm.searching : until; // fix for std.algorithm auto r = map!(x => 0)([1]); @@ -11058,8 +11058,8 @@ if (isInputRange!R && isIntegral!(ElementType!R)) /// You can use bitwise to implement an uniform bool generator @safe unittest { - import std.random : rndGen; import std.algorithm.comparison : equal; + import std.random : rndGen; auto rb = rndGen.bitwise; static assert(isInfinite!(typeof(rb))); diff --git a/std/range/primitives.d b/std/range/primitives.d index 761dd5443f0..2c4201bfc77 100644 --- a/std/range/primitives.d +++ b/std/range/primitives.d @@ -1364,7 +1364,7 @@ template hasLvalueElements(R) /// @safe unittest { - import std.range : iota, chain; + import std.range : chain, iota; static assert( hasLvalueElements!(int[])); static assert( hasLvalueElements!(const(int)[])); @@ -1850,8 +1850,8 @@ if (isBidirectionalRange!Range) /// @safe unittest { - import std.algorithm.iteration : filterBidirectional; import std.algorithm.comparison : equal; + import std.algorithm.iteration : filterBidirectional; auto a = [1, 2, 3]; a.popFrontExactly(1); diff --git a/std/regex/internal/backtracking.d b/std/regex/internal/backtracking.d index c13e371e2ee..71ea9723823 100644 --- a/std/regex/internal/backtracking.d +++ b/std/regex/internal/backtracking.d @@ -6,8 +6,8 @@ module std.regex.internal.backtracking; package(std.regex): +import core.stdc.stdlib, std.range.primitives, std.traits, std.typecons; import std.regex.internal.ir; -import std.range.primitives, std.typecons, std.traits, core.stdc.stdlib; /+ BacktrackingMatcher implements backtracking scheme of matching @@ -799,7 +799,7 @@ alias Sequence(int B, int E) = staticIota!(B, E); struct CtContext { - import std.conv : to, text; + import std.conv : text, to; //dirty flags bool counter; //to mark the portion of matches to save diff --git a/std/regex/internal/generator.d b/std/regex/internal/generator.d index 8bfda4a1092..8a51c58a20d 100644 --- a/std/regex/internal/generator.d +++ b/std/regex/internal/generator.d @@ -12,11 +12,11 @@ module std.regex.internal.generator; */ @trusted private struct SampleGenerator(Char) { - import std.regex.internal.ir : Regex, IR, IRL; - import std.array : appender, Appender; + import std.array : Appender, appender; import std.format : formattedWrite; - import std.utf : isValidDchar, byChar; import std.random : Xorshift; + import std.regex.internal.ir : IR, IRL, Regex; + import std.utf : byChar, isValidDchar; Regex!Char re; Appender!(char[]) app; uint limit, seed; diff --git a/std/regex/internal/ir.d b/std/regex/internal/ir.d index 755eca176c7..28b199895d9 100644 --- a/std/regex/internal/ir.d +++ b/std/regex/internal/ir.d @@ -9,7 +9,7 @@ module std.regex.internal.ir; package(std.regex): -import std.exception, std.uni, std.meta, std.traits, std.range.primitives; +import std.exception, std.meta, std.range.primitives, std.traits, std.uni; debug(std_regex_parser) import std.stdio; // just a common trait, may be moved elsewhere @@ -707,10 +707,10 @@ template BackLooper(E) // @trusted uint lookupNamedGroup(String)(NamedGroup[] dict, String name) {//equal is @system? - import std.range : assumeSorted; - import std.conv : text; - import std.algorithm.iteration : map; import std.algorithm.comparison : equal; + import std.algorithm.iteration : map; + import std.conv : text; + import std.range : assumeSorted; auto fnd = assumeSorted!"cmp(a,b) < 0"(map!"a.name"(dict)).lowerBound(name).length; enforce(fnd < dict.length && equal(dict[fnd].name, name), diff --git a/std/regex/internal/kickstart.d b/std/regex/internal/kickstart.d index 162ef7cc88d..f303b43b6ba 100644 --- a/std/regex/internal/kickstart.d +++ b/std/regex/internal/kickstart.d @@ -6,8 +6,8 @@ module std.regex.internal.kickstart; package(std.regex): -import std.regex.internal.ir; import std.range.primitives, std.utf; +import std.regex.internal.ir; //utility for shiftOr, returns a minimum number of bytes to test in a Char uint effectiveSize(Char)() @@ -395,8 +395,8 @@ public: // (that given the haystack in question is valid UTF string) @trusted size_t search(const(Char)[] haystack, size_t idx) {//@BUG: apparently assumes little endian machines - import std.conv : text; import core.stdc.string : memchr; + import std.conv : text; assert(!empty); auto p = cast(const(ubyte)*)(haystack.ptr+idx); uint state = uint.max; diff --git a/std/regex/internal/parser.d b/std/regex/internal/parser.d index 58e10225fbf..6498bddb74a 100644 --- a/std/regex/internal/parser.d +++ b/std/regex/internal/parser.d @@ -4,10 +4,10 @@ */ module std.regex.internal.parser; -import std.regex.internal.ir; +static import std.ascii; import std.range.primitives, std.uni, std.meta, std.traits, std.typecons, std.exception; -static import std.ascii; +import std.regex.internal.ir; // package relevant info from parser into a regex object auto makeRegex(S, CG)(Parser!(S, CG) p) diff --git a/std/regex/internal/tests.d b/std/regex/internal/tests.d index ccfb80c7dfa..46f972d828e 100644 --- a/std/regex/internal/tests.d +++ b/std/regex/internal/tests.d @@ -529,8 +529,8 @@ alias Sequence(int B, int E) = staticIota!(B, E); @safe unittest { - import std.algorithm.iteration : map; import std.algorithm.comparison : equal; + import std.algorithm.iteration : map; enum cx = ctRegex!"(A|B|C)"; auto mx = match("B",cx); assert(mx); @@ -560,8 +560,8 @@ alias Sequence(int B, int E) = staticIota!(B, E); @safe unittest { - import std.algorithm.iteration : map; import std.algorithm.comparison : equal; + import std.algorithm.iteration : map; //global matching void test_body(alias matchFn)() { @@ -603,8 +603,8 @@ alias Sequence(int B, int E) = staticIota!(B, E); //tests for accumulated std.regex issues and other regressions @safe unittest { - import std.algorithm.iteration : map; import std.algorithm.comparison : equal; + import std.algorithm.iteration : map; void test_body(alias matchFn)() { //issue 5857 @@ -1014,9 +1014,9 @@ alias Sequence(int B, int E) = staticIota!(B, E); // bugzilla 14615 @safe unittest { - import std.stdio : writeln; - import std.regex : replaceFirst, replaceFirstInto, regex; import std.array : appender; + import std.regex : regex, replaceFirst, replaceFirstInto; + import std.stdio : writeln; auto example = "Hello, world!"; auto pattern = regex("^Hello, (bug)"); // won't find this one diff --git a/std/regex/internal/thompson.d b/std/regex/internal/thompson.d index 103726edb62..4d7deaa1f88 100644 --- a/std/regex/internal/thompson.d +++ b/std/regex/internal/thompson.d @@ -10,8 +10,8 @@ module std.regex.internal.thompson; package(std.regex): -import std.regex.internal.ir; import std.range.primitives; +import std.regex.internal.ir; //State of VM thread struct Thread(DataIndex) diff --git a/std/regex/package.d b/std/regex/package.d index c0c52a8f9b9..f1d7f8763c5 100644 --- a/std/regex/package.d +++ b/std/regex/package.d @@ -296,10 +296,10 @@ Macros: +/ module std.regex; +import std.range.primitives, std.traits; import std.regex.internal.ir; import std.regex.internal.thompson; //TODO: get rid of this dependency -import std.traits, std.range.primitives; -import std.typecons; // : Flag, Yes, No; +import std.typecons; // : Flag, No, Yes; /++ $(D Regex) object holds regular expression pattern in compiled form. @@ -409,7 +409,7 @@ if (isSomeString!(S)) public auto regexImpl(S)(S pattern, const(char)[] flags="") if (isSomeString!(S)) { - import std.regex.internal.parser : Parser, CodeGen; + import std.regex.internal.parser : CodeGen, Parser; auto parser = Parser!(Unqual!(typeof(pattern)), CodeGen)(pattern, flags); auto r = parser.program; return r; @@ -418,7 +418,7 @@ if (isSomeString!(S)) template ctRegexImpl(alias pattern, string flags=[]) { - import std.regex.internal.parser, std.regex.internal.backtracking; + import std.regex.internal.backtracking, std.regex.internal.parser; enum r = regex(pattern, flags); alias Char = BasicElementOf!(typeof(pattern)); enum source = ctGenRegExCode(r); @@ -692,7 +692,7 @@ public: if (isSomeString!R) { private: - import core.stdc.stdlib : malloc, free; + import core.stdc.stdlib : free, malloc; alias Char = BasicElementOf!R; alias EngineType = Engine!Char; EngineType _engine; @@ -810,7 +810,7 @@ public: private @trusted auto matchOnce(alias Engine, RegEx, R)(R input, RegEx re) { - import core.stdc.stdlib : malloc, free; + import core.stdc.stdlib : free, malloc; import std.exception : enforce; alias Char = BasicElementOf!R; alias EngineType = Engine!Char; @@ -1052,9 +1052,9 @@ if (isSomeString!R && is(RegEx == StaticRegex!(BasicElementOf!R))) // another set of tests just to cover the new API @system unittest { - import std.conv : to; - import std.algorithm.iteration : map; import std.algorithm.comparison : equal; + import std.algorithm.iteration : map; + import std.conv : to; foreach (String; AliasSeq!(string, wstring, const(dchar)[])) { @@ -1138,8 +1138,8 @@ if (isOutputRange!(OutR, ElementEncodingType!R[]) && isOutputRange!(OutR, ElementEncodingType!(Capt.String)[])) { import std.algorithm.searching : find; - import std.conv : text, parse; - import std.ascii : isDigit, isAlpha; + import std.ascii : isAlpha, isDigit; + import std.conv : parse, text; import std.exception : enforce; enum State { Normal, Dollar } auto state = State.Normal; @@ -1422,7 +1422,7 @@ if (isOutputRange!(Sink, dchar) && isSomeString!R && isRegexFor!(RegEx, R)) @system unittest { // insert comma as thousands delimiter in fifty randomly produced big numbers - import std.array, std.random, std.conv, std.range; + import std.array, std.conv, std.random, std.range; static re = regex(`(?<=\d)(?=(\d\d\d)+\b)`, "g"); auto sink = appender!(char [])(); enum ulong min = 10UL ^^ 10, max = 10UL ^^ 19; @@ -1706,16 +1706,16 @@ auto escaper(Range)(Range r) /// @system unittest { - import std.regex; import std.algorithm.comparison; + import std.regex; string s = `This is {unfriendly} to *regex*`; assert(s.escaper.equal(`This is \{unfriendly\} to \*regex\*`)); } @system unittest { - import std.conv; import std.algorithm.comparison; + import std.conv; foreach (S; AliasSeq!(string, wstring, dstring)) { auto s = "^".to!S; diff --git a/std/signals.d b/std/signals.d index 646908ac72b..ec9c1af1fcb 100644 --- a/std/signals.d +++ b/std/signals.d @@ -62,9 +62,9 @@ */ module std.signals; -import std.stdio; -import core.stdc.stdlib : calloc, realloc, free; import core.exception : onOutOfMemoryError; +import core.stdc.stdlib : calloc, free, realloc; +import std.stdio; // Special function for internal use only. // Use of this is where the slot had better be a delegate @@ -85,8 +85,8 @@ extern (C) void rt_detachDisposeEvent( Object obj, DisposeEvt evt ); mixin template Signal(T1...) { - static import core.stdc.stdlib; static import core.exception; + static import core.stdc.stdlib; /*** * A slot is implemented as a delegate. * The slot_t is the type of the delegate. diff --git a/std/socket.d b/std/socket.d index d5b4693700b..effad6c6639 100644 --- a/std/socket.d +++ b/std/socket.d @@ -44,7 +44,7 @@ module std.socket; -import core.stdc.stdint, core.stdc.string, std.string, core.stdc.stdlib, std.conv; +import core.stdc.stdint, core.stdc.stdlib, core.stdc.string, std.conv, std.string; import core.stdc.config; import core.time : dur, Duration; @@ -60,8 +60,8 @@ version(Windows) pragma (lib, "ws2_32.lib"); pragma (lib, "wsock32.lib"); - public import core.sys.windows.winsock2; private import core.sys.windows.windows, std.windows.syserror; + public import core.sys.windows.winsock2; private alias _ctimeval = core.sys.windows.winsock2.timeval; private alias _clinger = core.sys.windows.winsock2.linger; @@ -85,16 +85,16 @@ else version(Posix) } } - import core.sys.posix.netdb; - import core.sys.posix.sys.un : sockaddr_un; - private import core.sys.posix.fcntl; - private import core.sys.posix.unistd; private import core.sys.posix.arpa.inet; - private import core.sys.posix.netinet.tcp; + private import core.sys.posix.fcntl; + import core.sys.posix.netdb; private import core.sys.posix.netinet.in_; - private import core.sys.posix.sys.time; + private import core.sys.posix.netinet.tcp; private import core.sys.posix.sys.select; private import core.sys.posix.sys.socket; + private import core.sys.posix.sys.time; + import core.sys.posix.sys.un : sockaddr_un; + private import core.sys.posix.unistd; private alias _ctimeval = core.sys.posix.sys.time.timeval; private alias _clinger = core.sys.posix.sys.socket.linger; diff --git a/std/stdio.d b/std/stdio.d index 06dc977cda3..09e1126af6e 100644 --- a/std/stdio.d +++ b/std/stdio.d @@ -13,8 +13,8 @@ Authors: $(HTTP digitalmars.com, Walter Bright), */ module std.stdio; -public import core.stdc.stdio; import core.stdc.stddef; // wchar_t +public import core.stdc.stdio; import std.algorithm.mutation; // copy import std.meta; // allSatisfy import std.range.primitives; // ElementEncodingType, empty, front, @@ -350,7 +350,7 @@ Hello, Jimmy! struct File { import std.range.primitives : ElementEncodingType; - import std.traits : isScalarType, isArray; + import std.traits : isArray, isScalarType; enum Orientation { unknown, narrow, wide } private struct Impl @@ -500,9 +500,9 @@ Throws: $(D ErrnoException) in case of error. */ void reopen(string name, in char[] stdioOpenmode = "rb") @trusted { - import std.internal.cstring : tempCString; - import std.exception : enforce, errnoEnforce; import std.conv : text; + import std.exception : enforce, errnoEnforce; + import std.internal.cstring : tempCString; enforce(isOpen, "Attempting to reopen() an unopened file"); @@ -525,8 +525,8 @@ Throws: $(D ErrnoException) in case of error. @system unittest // Test changing filename { + import std.exception : assertNotThrown, assertThrown; static import std.file; - import std.exception : assertThrown, assertNotThrown; auto deleteme = testFilename(); std.file.write(deleteme, "foo"); @@ -547,8 +547,8 @@ Throws: $(D ErrnoException) in case of error. version (CRuntime_Microsoft) {} else // Not implemented @system unittest // Test changing mode { + import std.exception : assertNotThrown, assertThrown; static import std.file; - import std.exception : assertThrown, assertNotThrown; auto deleteme = testFilename(); std.file.write(deleteme, "foo"); @@ -649,9 +649,9 @@ Throws: $(D ErrnoException) in case of error. version(Windows) void windowsHandleOpen(HANDLE handle, in char[] stdioOpenmode) { + import core.stdc.stdint : intptr_t; import std.exception : errnoEnforce; import std.format : format; - import core.stdc.stdint : intptr_t; // Create file descriptors from the handles version (DIGITAL_MARS_STDIO) @@ -838,8 +838,8 @@ Throws: $(D Exception) if the file is not opened or if the call to $(D fflush) f @safe unittest { // Issue 12349 - static import std.file; import std.exception : assertThrown; + static import std.file; auto deleteme = testFilename(); auto f = File(deleteme, "w"); @@ -1003,7 +1003,7 @@ Throws: $(D Exception) if the file is not opened. */ void seek(long offset, int origin = SEEK_SET) @trusted { - import std.conv : to, text; + import std.conv : text, to; import std.exception : enforce, errnoEnforce; enforce(isOpen, "Attempting to seek() in an unopened file"); @@ -1031,8 +1031,8 @@ Throws: $(D Exception) if the file is not opened. @system unittest { - static import std.file; import std.conv : text; + static import std.file; auto deleteme = testFilename(); auto f = File(deleteme, "w+"); @@ -1089,8 +1089,8 @@ Throws: $(D Exception) if the file is not opened. /// @system unittest { - static import std.file; import std.conv : text; + static import std.file; auto testFile = testFilename(); std.file.write(testFile, "abcdefghijklmnopqrstuvwqxyz"); @@ -1152,7 +1152,7 @@ Throws: $(D Exception) if the file is not opened. version(Windows) { - import core.sys.windows.windows : ULARGE_INTEGER, OVERLAPPED, BOOL; + import core.sys.windows.windows : BOOL, OVERLAPPED, ULARGE_INTEGER; private BOOL lockImpl(alias F, Flags...)(ulong start, ulong length, Flags flags) @@ -1172,8 +1172,8 @@ Throws: $(D Exception) if the file is not opened. private static T wenforce(T)(T cond, string str) { - import std.windows.syserror : sysErrorString; import core.sys.windows.windows : GetLastError; + import std.windows.syserror : sysErrorString; if (cond) return cond; throw new Exception(str ~ ": " ~ sysErrorString(GetLastError())); @@ -1220,8 +1220,8 @@ $(UL enforce(isOpen, "Attempting to call lock() on an unopened file"); version (Posix) { - import std.exception : errnoEnforce; import core.sys.posix.fcntl : F_RDLCK, F_SETLKW, F_WRLCK; + import std.exception : errnoEnforce; immutable short type = lockType == LockType.readWrite ? F_WRLCK : F_RDLCK; errnoEnforce(lockImpl(F_SETLKW, type, start, length) != -1, @@ -1254,9 +1254,9 @@ specified file segment was already locked. enforce(isOpen, "Attempting to call tryLock() on an unopened file"); version (Posix) { - import std.exception : errnoEnforce; import core.stdc.errno : EACCES, EAGAIN, errno; import core.sys.posix.fcntl : F_RDLCK, F_SETLK, F_WRLCK; + import std.exception : errnoEnforce; immutable short type = lockType == LockType.readWrite ? F_WRLCK : F_RDLCK; immutable res = lockImpl(F_SETLK, type, start, length); @@ -1294,8 +1294,8 @@ Removes the lock over the specified file segment. enforce(isOpen, "Attempting to call unlock() on an unopened file"); version (Posix) { - import std.exception : errnoEnforce; import core.sys.posix.fcntl : F_SETLK, F_UNLCK; + import std.exception : errnoEnforce; errnoEnforce(lockImpl(F_SETLK, F_UNLCK, start, length) != -1, "Could not remove lock for file `"~_name~"'"); } @@ -1395,7 +1395,7 @@ Throws: $(D Exception) if the file is not opened. */ void write(S...)(S args) { - import std.traits : isBoolean, isIntegral, isAggregateType; + import std.traits : isAggregateType, isBoolean, isIntegral; auto w = lockingTextWriter(); foreach (arg; args) { @@ -1540,8 +1540,8 @@ void main() @system unittest { - static import std.file; import std.algorithm.comparison : equal; + static import std.file; import std.meta : AliasSeq; auto deleteme = testFilename(); @@ -2300,8 +2300,8 @@ $(REF readText, std,file) @system unittest { - static import std.file; import std.algorithm.comparison : equal; + static import std.file; scope(failure) printf("Failed test at line %d\n", __LINE__); auto deleteme = testFilename(); @@ -3021,9 +3021,9 @@ void main() @system unittest { - static import std.file; import std.algorithm.mutation : reverse; import std.exception : collectException; + static import std.file; import std.range : only, retro; import std.string : format; @@ -3231,8 +3231,8 @@ void main() @safe unittest { - static import std.file; import std.exception : collectException; + static import std.file; auto deleteme = testFilename(); scope(exit) collectException(std.file.remove(deleteme)); @@ -3395,8 +3395,8 @@ struct LockingTextReader @system unittest // bugzilla 13686 { - static import std.file; import std.algorithm.comparison : equal; + static import std.file; import std.utf : byDchar; auto deleteme = testFilename(); @@ -4564,9 +4564,9 @@ alias stdin = makeGlobal!(core.stdc.stdio.stdin); @safe unittest { // Read stdin, sort lines, write to stdout - import std.array : array; - import std.algorithm.sorting : sort; import std.algorithm.mutation : copy; + import std.algorithm.sorting : sort; + import std.array : array; import std.typecons : Yes; void main() { @@ -5113,12 +5113,12 @@ version(linux) { File openNetwork(string host, ushort port) { - static import sock = core.sys.posix.sys.socket; - static import core.sys.posix.unistd; import core.stdc.string : memcpy; import core.sys.posix.arpa.inet : htons; import core.sys.posix.netdb : gethostbyname; import core.sys.posix.netinet.in_ : sockaddr_in; + static import core.sys.posix.unistd; + static import sock = core.sys.posix.sys.socket; import std.conv : to; import std.exception : enforce; import std.internal.cstring : tempCString; diff --git a/std/string.d b/std/string.d index fa59969fed7..1d2adaed1a0 100644 --- a/std/string.d +++ b/std/string.d @@ -185,9 +185,9 @@ private: } } -public import std.uni : icmp, toLower, toLowerInPlace, toUpper, toUpperInPlace; public import std.format : format, sformat; -import std.typecons : Flag, Yes, No; +import std.typecons : Flag, No, Yes; +public import std.uni : icmp, toLower, toLowerInPlace, toUpper, toUpperInPlace; import std.meta; // AliasSeq, staticIndexOf import std.range.primitives; // back, ElementEncodingType, ElementType, front, @@ -199,8 +199,8 @@ import std.traits; // isConvertibleToString, isNarrowString, isSomeChar, //public imports for backward compatibility public import std.algorithm.comparison : cmp; -public import std.algorithm.searching : startsWith, endsWith, count; -public import std.array : join, replace, replaceInPlace, split, empty; +public import std.algorithm.searching : count, endsWith, startsWith; +public import std.array : empty, join, replace, replaceInPlace, split; /* ************* Exceptions *************** */ @@ -257,7 +257,7 @@ inout(char)[] fromStringz(inout(char)* cString) @nogc @system pure nothrow { immutable(char)* toStringz(const(char)[] s) @trusted pure nothrow out (result) { - import core.stdc.string : strlen, memcmp; + import core.stdc.string : memcmp, strlen; if (result) { auto slen = s.length; @@ -378,7 +378,7 @@ if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && { static import std.ascii; static import std.uni; - import std.utf : byDchar, byCodeUnit, UTFException, codeLength; + import std.utf : byCodeUnit, byDchar, codeLength, UTFException; alias Char = Unqual!(ElementEncodingType!Range); if (cs == Yes.caseSensitive) @@ -579,7 +579,7 @@ if (isConvertibleToString!Range) import std.conv : to; import std.exception : assertCTFEable; import std.traits : EnumMembers; - import std.utf : byChar, byWchar, byDchar; + import std.utf : byChar, byDchar, byWchar; debug(string) trustedPrintf("string.indexOf.unittest\n"); assertCTFEable!( @@ -635,7 +635,7 @@ if (isConvertibleToString!Range) { import std.conv : to; import std.traits : EnumMembers; - import std.utf : byCodeUnit, byChar, byWchar; + import std.utf : byChar, byCodeUnit, byWchar; debug(string) trustedPrintf("string.indexOf(startIdx).unittest\n"); assert("hello".byCodeUnit.indexOf(cast(dchar)'l', 1) == 2); @@ -2309,8 +2309,8 @@ S capitalize(S)(S input) @trusted pure if (isSomeString!S) { import std.array : array; - import std.utf : byUTF; import std.uni : asCapitalized; + import std.utf : byUTF; return input.asCapitalized.byUTF!(ElementEncodingType!(S)).array; } @@ -3214,7 +3214,7 @@ if ((isRandomAccessRange!Range && isSomeChar!(ElementEncodingType!Range) || isNarrowString!Range) && !isConvertibleToString!Range) { - import std.uni : lineSep, paraSep, nelSep; + import std.uni : lineSep, nelSep, paraSep; if (str.empty) return str; @@ -3308,7 +3308,7 @@ if ((isBidirectionalRange!Range && isSomeChar!(ElementEncodingType!Range) || @safe pure unittest { - import std.uni : lineSep, paraSep, nelSep; + import std.uni : lineSep, nelSep, paraSep; import std.utf : decode; assert(chomp(" hello world \n\r") == " hello world \n"); assert(chomp(" hello world \r\n") == " hello world "); @@ -3396,7 +3396,7 @@ if (isConvertibleToString!Range) // Ranges import std.array : array; - import std.utf : byChar, byWchar, byDchar; + import std.utf : byChar, byDchar, byWchar; assert(chomp("hello world\r\n" .byChar ).array == "hello world"); assert(chomp("hello world\r\n"w.byWchar).array == "hello world"w); assert(chomp("hello world\r\n"d.byDchar).array == "hello world"d); @@ -3496,7 +3496,7 @@ unittest // Ranges import std.array : array; - import std.utf : byChar, byWchar, byDchar; + import std.utf : byChar, byDchar, byWchar; assert(chompPrefix("hello world" .byChar , "hello"d).array == " world"); assert(chompPrefix("hello world"w.byWchar, "hello" ).array == " world"w); assert(chompPrefix("hello world"d.byDchar, "hello"w).array == " world"d); @@ -3608,7 +3608,7 @@ if (isConvertibleToString!Range) @safe pure unittest { import std.array : array; - import std.utf : byChar, byWchar, byDchar, byCodeUnit, invalidUTFstrings; + import std.utf : byChar, byCodeUnit, byDchar, byWchar, invalidUTFstrings; assert(chop("hello world".byChar).array == "hello worl"); assert(chop("hello world\n"w.byWchar).array == "hello world"w); @@ -3719,7 +3719,7 @@ if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && static if (C.sizeof == 1) { - import std.utf : byDchar, byChar; + import std.utf : byChar, byDchar; return leftJustifier(r.byDchar, width, fillChar).byChar; } else static if (C.sizeof == 2) @@ -3862,7 +3862,7 @@ if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && static if (C.sizeof == 1) { - import std.utf : byDchar, byChar; + import std.utf : byChar, byDchar; return rightJustifier(r.byDchar, width, fillChar).byChar; } else static if (C.sizeof == 2) @@ -4090,7 +4090,7 @@ if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && static if (C.sizeof == 1) { - import std.utf : byDchar, byChar; + import std.utf : byChar, byDchar; return centerJustifier(r.byDchar, width, fillChar).byChar; } else static if (C.sizeof == 2) @@ -4240,7 +4240,7 @@ auto detabber(Range)(Range r, size_t tabSize = 8) if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && !isConvertibleToString!Range) { - import std.uni : lineSep, paraSep, nelSep; + import std.uni : lineSep, nelSep, paraSep; import std.utf : codeUnitLimit, decodeFront; assert(tabSize > 0); @@ -4471,7 +4471,7 @@ if (!(isForwardRange!Range && isSomeChar!(ElementEncodingType!Range)) && auto entabber(Range)(Range r, size_t tabSize = 8) if (isForwardRange!Range && !isConvertibleToString!Range) { - import std.uni : lineSep, paraSep, nelSep; + import std.uni : lineSep, nelSep, paraSep; import std.utf : codeUnitLimit, decodeFront; assert(tabSize > 0); @@ -5853,8 +5853,8 @@ C1[] tr(C1, C2, C3, C4 = immutable char) @system pure unittest { - import std.exception : assertThrown; import core.exception : AssertError; + import std.exception : assertThrown; assertThrown!AssertError(tr("abcdef", "cd", "CD", "X")); } @@ -6513,7 +6513,7 @@ if ((isInputRange!Range && isSomeChar!(Unqual!(ElementEncodingType!Range)) || else { // decoding not needed for wchars and dchars - import std.uni : lineSep, paraSep, nelSep; + import std.uni : lineSep, nelSep, paraSep; size_t column; @@ -6545,7 +6545,7 @@ if ((isInputRange!Range && isSomeChar!(Unqual!(ElementEncodingType!Range)) || /// @safe pure unittest { - import std.utf : byChar, byWchar, byDchar; + import std.utf : byChar, byDchar, byWchar; assert(column("1234 ") == 5); assert(column("1234 "w) == 5); diff --git a/std/uni.d b/std/uni.d index 39b0474ad64..93931d6504e 100644 --- a/std/uni.d +++ b/std/uni.d @@ -875,7 +875,7 @@ size_t replicateBits(size_t times, size_t bits)(size_t val) @safe pure nothrow @ @safe pure nothrow @nogc unittest // for replicate { - import std.algorithm.iteration : sum, map; + import std.algorithm.iteration : map, sum; import std.range : iota; size_t m = 0b111; size_t m2 = 0b01; @@ -3401,7 +3401,7 @@ private: import std.algorithm.comparison : equal; import std.algorithm.mutation : copy; import std.conv : text; - import std.range : iota, chain; + import std.range : chain, iota; import std.range.primitives : isBidirectionalRange, isOutputRange; void funcRef(T)(ref T u24) { @@ -5762,7 +5762,7 @@ template idxTypes(Key, size_t fullBits, Prefix...) if (is(Char1 : dchar) && is(Char2 : dchar)) { import std.algorithm.comparison : cmp; - import std.algorithm.iteration : map, filter; + import std.algorithm.iteration : filter, map; import std.ascii : toLower; static bool pred(dchar c) {return !c.isWhite && c != '-' && c != '_';} return cmp( @@ -6542,7 +6542,7 @@ if (isInputRange!Range && is(Unqual!(ElementType!Range) == dchar)) @safe unittest { import std.algorithm.comparison : equal; - import std.range : take, drop; + import std.range : drop, take; import std.range.primitives : walkLength; auto text = "noe\u0308l"; // noël using e + combining diaeresis assert(text.walkLength == 5); // 5 code points @@ -7492,7 +7492,7 @@ enum { public dchar compose(dchar first, dchar second) pure nothrow @safe { import std.algorithm.iteration : map; - import std.internal.unicode_comp : compositionTable, composeCntShift, composeIdxMask; + import std.internal.unicode_comp : composeCntShift, composeIdxMask, compositionTable; import std.range : assumeSorted; immutable packed = compositionJumpTrie[first]; if (packed == ushort.max) @@ -7539,7 +7539,7 @@ public dchar compose(dchar first, dchar second) pure nothrow @safe public Grapheme decompose(UnicodeDecomposition decompType=Canonical)(dchar ch) @safe { import std.algorithm.searching : until; - import std.internal.unicode_decomp : decompCompatTable, decompCanonTable; + import std.internal.unicode_decomp : decompCanonTable, decompCompatTable; static if (decompType == Canonical) { alias table = decompCanonTable; @@ -8115,7 +8115,7 @@ public bool isWhite(dchar c) @safe pure nothrow @nogc bool isLower(dchar c) { - import std.ascii : isLower, isASCII; + import std.ascii : isASCII, isLower; if (isASCII(c)) return isLower(c); return lowerCaseTrie[c]; @@ -8148,7 +8148,7 @@ bool isLower(dchar c) @safe pure nothrow @nogc bool isUpper(dchar c) { - import std.ascii : isUpper, isASCII; + import std.ascii : isASCII, isUpper; if (isASCII(c)) return isUpper(c); return upperCaseTrie[c]; @@ -8744,7 +8744,7 @@ private size_t encodeTo(scope dchar[] buf, size_t idx, dchar c) @trusted pure no private void toCaseInPlace(alias indexFn, uint maxIdx, alias tableFn, C)(ref C[] s) @trusted pure if (is(C == char) || is(C == wchar) || is(C == dchar)) { - import std.utf : decode, codeLength; + import std.utf : codeLength, decode; size_t curIdx = 0; size_t destIdx = 0; alias slowToCase = toCaseInPlaceAlloc!(indexFn, maxIdx, tableFn); @@ -8812,7 +8812,7 @@ private template toCaseLength(alias indexFn, uint maxIdx, alias tableFn) { size_t toCaseLength(C)(in C[] str) { - import std.utf : decode, codeLength; + import std.utf : codeLength, decode; size_t codeLen = 0; size_t lastNonTrivial = 0; size_t curIdx = 0; @@ -9024,8 +9024,8 @@ if (isSomeString!S) @system unittest //@@@BUG std.format is not @safe { - import std.format : format; static import std.ascii; + import std.format : format; foreach (ch; 0 .. 0x80) assert(std.ascii.toLower(ch) == toLower(ch)); assert(toLower('Я') == 'я'); @@ -9150,8 +9150,8 @@ dchar toUpper(dchar c) @safe unittest { - import std.format : format; static import std.ascii; + import std.format : format; foreach (ch; 0 .. 0x80) assert(std.ascii.toUpper(ch) == toUpper(ch)); assert(toUpper('я') == 'Я'); diff --git a/std/uri.d b/std/uri.d index 0f03d03bae2..75208e1982c 100644 --- a/std/uri.d +++ b/std/uri.d @@ -316,8 +316,8 @@ if (isSomeChar!Char) string decode(Char)(in Char[] encodedURI) if (isSomeChar!Char) { - import std.utf : encode; import std.algorithm.iteration : each; + import std.utf : encode; auto s = URI_Decode(encodedURI, URI_Reserved | URI_Hash); char[] r; s.each!(c => encode(r, c)); @@ -332,8 +332,8 @@ if (isSomeChar!Char) string decodeComponent(Char)(in Char[] encodedURIComponent) if (isSomeChar!Char) { - import std.utf : encode; import std.algorithm.iteration : each; + import std.utf : encode; auto s = URI_Decode(encodedURIComponent, 0); char[] r; s.each!(c => encode(r, c)); diff --git a/std/utf.d b/std/utf.d index e2860745859..f98e8182e13 100644 --- a/std/utf.d +++ b/std/utf.d @@ -59,11 +59,11 @@ $(TR $(TD Miscellaneous) $(TD +/ module std.utf; +import std.exception; // basicExceptionCtors import std.meta; // AliasSeq import std.range.primitives; import std.traits; // isSomeChar, isSomeString import std.typecons; // Flag, Yes, No -import std.exception; // basicExceptionCtors //debug=utf; // uncomment to turn on debugging printf's @@ -75,7 +75,7 @@ debug (utf) import core.stdc.stdio : printf; +/ class UTFException : Exception { - import core.internal.string : unsignedToTempString, UnsignedStringBuf; + import core.internal.string : UnsignedStringBuf, unsignedToTempString; uint[4] sequence; size_t len; @@ -346,10 +346,10 @@ body @system unittest { + import core.exception : AssertError; import std.conv : to; import std.exception; import std.string : format; - import core.exception : AssertError; static void test(string s, dchar c, size_t i = 0, size_t line = __LINE__) { enforce(stride(s, i) == codeLength!char(c), @@ -454,10 +454,10 @@ if (isInputRange!S && is(Unqual!(ElementType!S) == wchar)) @system unittest { + import core.exception : AssertError; import std.conv : to; import std.exception; import std.string : format; - import core.exception : AssertError; static void test(wstring s, dchar c, size_t i = 0, size_t line = __LINE__) { enforce(stride(s, i) == codeLength!wchar(c), @@ -533,10 +533,10 @@ if (is(S : const dchar[]) || @system unittest { + import core.exception : AssertError; import std.conv : to; import std.exception; import std.string : format; - import core.exception : AssertError; static void test(dstring s, dchar c, size_t i = 0, size_t line = __LINE__) { enforce(stride(s, i) == codeLength!dchar(c), @@ -679,10 +679,10 @@ if (isBidirectionalRange!S && is(Unqual!(ElementType!S) == char) && !isRandomAcc @system unittest { + import core.exception : AssertError; import std.conv : to; import std.exception; import std.string : format; - import core.exception : AssertError; static void test(string s, dchar c, size_t i = size_t.max, size_t line = __LINE__) { enforce(strideBack(s, i == size_t.max ? s.length : i) == codeLength!char(c), @@ -776,10 +776,10 @@ if (is(S : const wchar[]) || @system unittest { + import core.exception : AssertError; import std.conv : to; import std.exception; import std.string : format; - import core.exception : AssertError; static void test(wstring s, dchar c, size_t i = size_t.max, size_t line = __LINE__) { enforce(strideBack(s, i == size_t.max ? s.length : i) == codeLength!wchar(c), @@ -861,10 +861,10 @@ if (isBidirectionalRange!S && is(Unqual!(ElementEncodingType!S) == dchar)) @system unittest { + import core.exception : AssertError; import std.conv : to; import std.exception; import std.string : format; - import core.exception : AssertError; static void test(dstring s, dchar c, size_t i = size_t.max, size_t line = __LINE__) { enforce(strideBack(s, i == size_t.max ? s.length : i) == codeLength!dchar(c), @@ -1747,8 +1747,8 @@ version(unittest) private void testDecode(R)(R range, size_t expectedIndex, size_t line = __LINE__) { - import std.string : format; import core.exception : AssertError; + import std.string : format; static if (hasLength!R) immutable lenBefore = range.length; @@ -1775,8 +1775,8 @@ version(unittest) private void testDecodeFront(R)(ref R range, size_t expectedNumCodeUnits, size_t line = __LINE__) { - import std.string : format; import core.exception : AssertError; + import std.string : format; static if (hasLength!R) immutable lenBefore = range.length; @@ -1805,8 +1805,8 @@ version(unittest) private void testDecodeBack(R)(ref R range, return; else { - import std.string : format; import core.exception : AssertError; + import std.string : format; static if (hasLength!R) immutable lenBefore = range.length; @@ -1842,8 +1842,8 @@ version(unittest) private void testAllDecode(R)(R range, version(unittest) private void testBadDecode(R)(R range, size_t index, size_t line = __LINE__) { - import std.string : format; import core.exception : AssertError; + import std.string : format; immutable initialIndex = index; @@ -1873,8 +1873,8 @@ version(unittest) private void testBadDecodeBack(R)(R range, size_t line = __LIN return; else { - import std.string : format; import core.exception : AssertError; + import std.string : format; static if (hasLength!R) immutable lenBefore = range.length; @@ -2615,9 +2615,9 @@ if (isInputRange!InputRange && !isInfinite!InputRange && is(ElementType!InputRan @safe unittest { + import std.algorithm.iteration : filter; import std.conv : to; import std.exception; - import std.algorithm.iteration : filter; assertCTFEable!( { @@ -2745,8 +2745,8 @@ if (isInputRange!S && !isInfinite!S && isSomeChar!(ElementEncodingType!S)) @system pure unittest { - import std.internal.test.dummyrange : ReferenceInputRange; import std.algorithm.comparison : equal; + import std.internal.test.dummyrange : ReferenceInputRange; auto r1 = new ReferenceInputRange!dchar("Hellø"); auto r2 = new ReferenceInputRange!dchar("𐐷"); @@ -2795,8 +2795,8 @@ if (isInputRange!S && !isInfinite!S && isSomeChar!(ElementEncodingType!S)) @system pure unittest { - import std.internal.test.dummyrange : ReferenceInputRange; import std.algorithm.comparison : equal; + import std.internal.test.dummyrange : ReferenceInputRange; auto r1 = new ReferenceInputRange!dchar("𤭢"); auto r2 = new ReferenceInputRange!dchar("𐐷"); @@ -3004,11 +3004,11 @@ if (isSomeString!S && isPointer!P && isSomeChar!(typeof(*P.init)) && @safe pure unittest { + import core.exception : AssertError; + import std.algorithm; import std.conv : to; import std.exception; import std.string : format; - import core.exception : AssertError; - import std.algorithm; assertCTFEable!( { diff --git a/std/uuid.d b/std/uuid.d index 879a99215e4..d4147c56f6a 100644 --- a/std/uuid.d +++ b/std/uuid.d @@ -333,7 +333,7 @@ public struct UUID */ this(T)(in T[] uuid) if (isSomeChar!(Unqual!T)) { - import std.conv : to, parse; + import std.conv : parse, to; if (uuid.length < 36) { throw new UUIDParsingException(to!string(uuid), 0, @@ -402,9 +402,9 @@ public struct UUID @safe pure unittest { + import std.conv : to; import std.exception; import std.meta; - import std.conv : to; foreach (S; AliasSeq!(char[], const(char)[], immutable(char)[], wchar[], const(wchar)[], immutable(wchar)[], @@ -1233,7 +1233,7 @@ if (isInputRange!RNG && isIntegral!(ElementType!RNG)) /// @safe unittest { - import std.random : Xorshift192, unpredictableSeed; + import std.random : unpredictableSeed, Xorshift192; //simple call auto uuid = randomUUID(); @@ -1253,13 +1253,13 @@ if (isInputRange!RNG && isIntegral!(ElementType!RNG)) */ @safe unittest { - import std.random : rndGen, Mt19937; + import std.random : Mt19937, rndGen; static assert(is(typeof(rndGen) == Mt19937)); } @safe unittest { - import std.random : Xorshift192, unpredictableSeed; + import std.random : unpredictableSeed, Xorshift192; //simple call auto uuid = randomUUID(); @@ -1314,8 +1314,8 @@ UUID parseUUID(Range)(ref Range uuidRange) if (isInputRange!Range && is(Unqual!(ElementType!Range) == dchar)) { - import std.conv : ConvException, parse; import std.ascii : isHexDigit; + import std.conv : ConvException, parse; static if (isForwardRange!Range) auto errorCopy = uuidRange.save; @@ -1475,9 +1475,9 @@ if (isInputRange!Range @safe pure unittest { + import std.conv : to; import std.exception; import std.meta; - import std.conv : to; struct TestRange(bool forward) { diff --git a/std/variant.d b/std/variant.d index eb15fd6f26e..c94b4ff211a 100644 --- a/std/variant.d +++ b/std/variant.d @@ -796,7 +796,7 @@ public: @property T coerce(T)() { - import std.conv : to, text; + import std.conv : text, to; static if (isNumeric!T || isBoolean!T) { if (convertsTo!real) @@ -2690,7 +2690,7 @@ if (isAlgebraic!VariantType && Handler.length > 0) @system unittest { - import std.exception : assertThrown, assertNotThrown; + import std.exception : assertNotThrown, assertThrown; // Make sure Variant can handle types with opDispatch but no length field. struct SWithNoLength { @@ -2729,8 +2729,8 @@ if (isAlgebraic!VariantType && Handler.length > 0) @system unittest { // Bugzilla 15039 - import std.variant; import std.typecons; + import std.variant; alias IntTypedef = Typedef!int; alias Obj = Algebraic!(int, IntTypedef, This[]); diff --git a/std/windows/charset.d b/std/windows/charset.d index 5c40189f07e..c6abe7a381a 100644 --- a/std/windows/charset.d +++ b/std/windows/charset.d @@ -50,11 +50,11 @@ else: version (Windows): -private import std.conv; private import core.sys.windows.windows; -private import std.windows.syserror; -private import std.utf; +private import std.conv; private import std.string; +private import std.utf; +private import std.windows.syserror; import std.internal.cstring; diff --git a/std/windows/registry.d b/std/windows/registry.d index b1197b4b1e5..dc68e013bb8 100644 --- a/std/windows/registry.d +++ b/std/windows/registry.d @@ -38,15 +38,15 @@ module std.windows.registry; version (Windows): -import std.array; -import std.system : Endian, endian; -import std.exception; import core.sys.windows.windows; -import std.windows.syserror; +import std.array; import std.conv; -import std.utf : toUTF8, toUTF16; -private import std.internal.windows.advapi32; +import std.exception; import std.internal.cstring; +private import std.internal.windows.advapi32; +import std.system : Endian, endian; +import std.utf : toUTF16, toUTF8; +import std.windows.syserror; //debug = winreg; debug(winreg) import std.stdio; @@ -82,7 +82,7 @@ class Win32Exception : WindowsException @property int error() { return super.code; } } -version(unittest) import std.string : startsWith, endsWith; +version(unittest) import std.string : endsWith, startsWith; @safe unittest { diff --git a/std/windows/syserror.d b/std/windows/syserror.d index 83de681662a..ff844dc41df 100644 --- a/std/windows/syserror.d +++ b/std/windows/syserror.d @@ -65,11 +65,11 @@ else: version (Windows): -import std.windows.charset; +import core.sys.windows.windows; import std.array : appender; import std.conv : to; import std.format : formattedWrite; -import core.sys.windows.windows; +import std.windows.charset; string sysErrorString( DWORD errCode, @@ -164,8 +164,8 @@ T wenforce(T)(T condition, const(char)[] name, const(wchar)* namez, string file { static string trustedToString(const(wchar)* stringz) @trusted { - import std.conv : to; import core.stdc.wchar_ : wcslen; + import std.conv : to; auto len = wcslen(stringz); return to!string(stringz[0 .. len]); } @@ -180,9 +180,9 @@ T wenforce(T)(T condition, const(char)[] name, const(wchar)* namez, string file version(Windows) @system unittest { + import std.algorithm.searching : endsWith, startsWith; import std.exception; import std.string; - import std.algorithm.searching : startsWith, endsWith; auto e = collectException!WindowsException( DeleteFileA("unexisting.txt").wenforce("DeleteFile") diff --git a/std/zip.d b/std/zip.d index 961eaa4f974..39dd57a8b07 100644 --- a/std/zip.d +++ b/std/zip.d @@ -97,7 +97,7 @@ enum CompressionMethod : ushort */ final class ArchiveMember { - import std.conv : to, octal; + import std.conv : octal, to; import std.datetime : DosFileTime, SysTime, SysTimeToDosFileTime; /** @@ -286,8 +286,8 @@ final class ArchiveMember */ final class ZipArchive { - import std.bitmanip : littleEndianToNative, nativeToLittleEndian; import std.algorithm.comparison : max; + import std.bitmanip : littleEndianToNative, nativeToLittleEndian; import std.conv : to; import std.datetime : DosFileTime; @@ -852,8 +852,8 @@ debug(print) assert(zip3.directory["foo"].compressedSize == am1.compressedSize); // Test if packing and unpacking produces the original data - import std.random : uniform, MinstdRand0; - import std.stdio, std.conv; + import std.conv, std.stdio; + import std.random : MinstdRand0, uniform; MinstdRand0 gen; const uint itemCount = 20, minSize = 10, maxSize = 500; foreach (variant; 0 .. 2) @@ -887,8 +887,8 @@ debug(print) @system unittest { - import std.random : Mt19937, randomShuffle; import std.conv : to; + import std.random : Mt19937, randomShuffle; // Test if packing and unpacking preserves order. auto rand = Mt19937(15966); string[] names; diff --git a/std/zlib.d b/std/zlib.d index 68954719077..7965f3055b0 100644 --- a/std/zlib.d +++ b/std/zlib.d @@ -674,8 +674,8 @@ class UnCompress /* ========================== unittest ========================= */ -private import std.stdio; private import std.random; +private import std.stdio; @system unittest // by Dave {