diff --git a/std/base64.d b/std/base64.d index 0fc92ac2b01..f07f3411016 100644 --- a/std/base64.d +++ b/std/base64.d @@ -2060,7 +2060,8 @@ class Base64Exception : Exception // Verify that any existing workaround that uses & still works. InputRange ir2; OutputRange or2; - () @trusted { + () @trusted + { assert(Base64.encode(ir2, &or2) == 8); }(); assert(or2.result == "Gis8TV1u"); @@ -2092,7 +2093,8 @@ class Base64Exception : Exception // Verify that any existing workaround that uses & still works. InputRange ir2; OutputRange or2; - () @trusted { + () @trusted + { assert(Base64.decode(ir2, &or2) == 6); }(); assert(or2.result == [0x1a, 0x2b, 0x3c, 0x4d, 0x5d, 0x6e]); diff --git a/std/bigint.d b/std/bigint.d index 0240ea1d179..4b668b01858 100644 --- a/std/bigint.d +++ b/std/bigint.d @@ -1968,7 +1968,8 @@ unittest // https://issues.dlang.org/show_bug.cgi?id=6850 @safe unittest { - pure long pureTest() { + pure long pureTest() + { BigInt a = 1; BigInt b = 1336; a += b; diff --git a/std/bitmanip.d b/std/bitmanip.d index b84a6762d19..b3b4846a9ad 100644 --- a/std/bitmanip.d +++ b/std/bitmanip.d @@ -450,7 +450,8 @@ unittest // https://issues.dlang.org/show_bug.cgi?id=6686 @safe unittest { - union S { + union S + { ulong bits = ulong.max; mixin (bitfields!( ulong, "back", 31, @@ -509,7 +510,8 @@ unittest @safe unittest { { - static struct Integrals { + static struct Integrals + { bool checkExpectations(bool eb, int ei, short es) { return b == eb && i == ei && s == es; } mixin(bitfields!( @@ -531,7 +533,8 @@ unittest //https://issues.dlang.org/show_bug.cgi?id=8876 { - struct MoreIntegrals { + struct MoreIntegrals + { bool checkExpectations(uint eu, ushort es, uint ei) { return u == eu && s == es && i == ei; } mixin(bitfields!( @@ -554,7 +557,8 @@ unittest enum A { True, False } enum B { One, Two, Three, Four } - static struct Enums { + static struct Enums + { bool checkExpectations(A ea, B eb) { return a == ea && b == eb; } mixin(bitfields!( @@ -609,7 +613,8 @@ unittest // https://issues.dlang.org/show_bug.cgi?id=15305 @safe unittest { - struct S { + struct S + { mixin(bitfields!( bool, "alice", 1, ulong, "bob", 63, @@ -659,7 +664,8 @@ Following arguments works the same way as `bitfield`'s. The bitfield must fit in bits known to be zero because of the pointer alignment. */ -template taggedPointer(T : T*, string name, Ts...) { +template taggedPointer(T : T*, string name, Ts...) +{ enum taggedPointer = createTaggedReference!(T*, T.alignof, name, Ts); } @@ -767,7 +773,8 @@ if (is(T == class)) Object, "a", uint, "b", 4))); - struct S { + struct S + { mixin(taggedClassRef!( Object, "a", bool, "b", 1)); diff --git a/std/conv.d b/std/conv.d index 4248e4b9d44..bf5b0e23a9d 100644 --- a/std/conv.d +++ b/std/conv.d @@ -1053,7 +1053,8 @@ if (!(is(S : T) && else static if (isPointer!S && isSomeChar!(PointerTarget!S)) { // This is unsafe because we cannot guarantee that the pointer is null terminated. - return () @system { + return () @system + { static if (is(S : const(char)*)) import core.stdc.string : strlen; else @@ -1208,7 +1209,8 @@ if (!(is(S : T) && */ private template isSwitchable(E) { - enum bool isSwitchable = is(typeof({ + enum bool isSwitchable = is(typeof( + { switch (E.init) { default: } })); } @@ -2786,12 +2788,14 @@ Lerr: assertCTFEable!({ string s = "-1234abc"; assert(parse! int(s) == -1234 && s == "abc"); }); assertCTFEable!({ string s = "1234abc"; assert(parse!uint(s) == 1234 && s == "abc"); }); + //dfmt off assertCTFEable!({ string s = "1234abc"; assert(parse!( int, string, Yes.doCount)(s) == tuple( 1234, 4) && s == "abc"); }); assertCTFEable!({ string s = "-1234abc"; assert(parse!( int, string, Yes.doCount)(s) == tuple(-1234, 5) && s == "abc"); }); assertCTFEable!({ string s = "1234abc"; assert(parse!(uint, string, Yes.doCount)(s) == tuple( 1234 ,4) && s == "abc"); }); + //dfmt on } // https://issues.dlang.org/show_bug.cgi?id=13931 diff --git a/std/digest/package.d b/std/digest/package.d index ea3738b2f82..f26dcc73b7f 100644 --- a/std/digest/package.d +++ b/std/digest/package.d @@ -852,7 +852,8 @@ ref T[N] asArray(size_t N, T)(ref T[] source, string errorMsg = "") * Fill in a preallocated buffer with the ASCII hex representation from a byte buffer */ private void toHexStringImpl(Order order, LetterCase letterCase, BB, HB) -(scope const ref BB byteBuffer, ref HB hexBuffer){ +(scope const ref BB byteBuffer, ref HB hexBuffer) +{ static if (letterCase == LetterCase.upper) { import std.ascii : hexDigits = hexDigits; diff --git a/std/exception.d b/std/exception.d index 5c786859c8e..a2c7569ce9a 100644 --- a/std/exception.d +++ b/std/exception.d @@ -578,7 +578,8 @@ private noreturn bailOut(E : Throwable = Exception)(string file, size_t line, sc { static int g; ~this() {} // impure & unsafe destructor - bool opCast(T:bool)() { + bool opCast(T:bool)() + { int* p = cast(int*) 0; // unsafe operation int n = g; // impure operation return true; @@ -1460,7 +1461,8 @@ version (StdUnittest) assert(mayPointTo(voidArr, a)); // slice-contiaining void[N] might point at anything assert(mayPointTo(voidArr, b)); - static assert(() { + static assert(() + { void[16] arr1 = void; void[size_t.sizeof] arr2 = void; int var; @@ -2331,7 +2333,8 @@ pure nothrow @safe unittest auto save = f.handle!(Exception, RangePrimitive.save, - function(Exception e, ref ThrowingRange r) { + function(Exception e, ref ThrowingRange r) + { return ThrowingRange(); })(); diff --git a/std/experimental/allocator/building_blocks/affix_allocator.d b/std/experimental/allocator/building_blocks/affix_allocator.d index d0d0b7cb27c..60745a3ebc6 100644 --- a/std/experimental/allocator/building_blocks/affix_allocator.d +++ b/std/experimental/allocator/building_blocks/affix_allocator.d @@ -446,7 +446,8 @@ version (StdUnittest) import std.experimental.allocator.building_blocks.bitmapped_block : BitmappedBlock; import std.experimental.allocator.common : testAllocator; - testAllocator!({ + testAllocator!( + { auto a = AffixAllocator!(BitmappedBlock!128, ulong, ulong) (BitmappedBlock!128(new ubyte[128 * 4096])); return a; diff --git a/std/experimental/allocator/building_blocks/bitmapped_block.d b/std/experimental/allocator/building_blocks/bitmapped_block.d index 571e4e69161..c6f64677624 100644 --- a/std/experimental/allocator/building_blocks/bitmapped_block.d +++ b/std/experimental/allocator/building_blocks/bitmapped_block.d @@ -1742,7 +1742,8 @@ pure @safe unittest import std.typecons : Ternary; auto a = (() @trusted => BitmappedBlock!(64, 64, NullAllocator, Yes.multiblock)(new ubyte[10_240]))(); - () nothrow @nogc { + () nothrow @nogc + { assert(a.empty == Ternary.yes); const b = a.allocate(100); assert(b.length == 100); diff --git a/std/experimental/allocator/building_blocks/free_list.d b/std/experimental/allocator/building_blocks/free_list.d index d2b32099226..0e6c92462b0 100644 --- a/std/experimental/allocator/building_blocks/free_list.d +++ b/std/experimental/allocator/building_blocks/free_list.d @@ -436,7 +436,8 @@ struct FreeList(ParentAllocator, import std.experimental.allocator.building_blocks.stats_collector : StatsCollector, Options; - struct StatsCollectorWrapper { + struct StatsCollectorWrapper + { ~this() { // buf2 should still be around and buf1 deallocated diff --git a/std/experimental/allocator/building_blocks/kernighan_ritchie.d b/std/experimental/allocator/building_blocks/kernighan_ritchie.d index 6883d33adae..ef49173e5fc 100644 --- a/std/experimental/allocator/building_blocks/kernighan_ritchie.d +++ b/std/experimental/allocator/building_blocks/kernighan_ritchie.d @@ -717,7 +717,8 @@ it actually returns memory to the operating system when possible. from the garbage-collected heap. Each block is organized as a KR-style heap. More blocks are allocated and freed on a need basis. */ - AllocatorList!((n) { + AllocatorList!((n) + { auto result = KRRegion!MmapAllocator(max(n * 2, 1024 * 1024)); return result; }) alloc; diff --git a/std/experimental/allocator/building_blocks/stats_collector.d b/std/experimental/allocator/building_blocks/stats_collector.d index 3770af10ceb..f0a40f02d9e 100644 --- a/std/experimental/allocator/building_blocks/stats_collector.d +++ b/std/experimental/allocator/building_blocks/stats_collector.d @@ -712,8 +712,7 @@ public: import std.array : array; import std.range : repeat; - static PerCallStatistics s = { f, n, [ opts ], - repeat(0UL, opts.length).array }; + static PerCallStatistics s = { f, n, [ opts ], repeat(0UL, opts.length).array }; static bool inserted; if (!inserted) diff --git a/std/experimental/allocator/package.d b/std/experimental/allocator/package.d index 7dbc47a6f02..47834d6eeeb 100644 --- a/std/experimental/allocator/package.d +++ b/std/experimental/allocator/package.d @@ -1007,7 +1007,8 @@ private ref RCIAllocator setupThreadAllocator() assert(_threadAllocator.isNull); import core.lifetime : emplace; static ulong[stateSize!(ThreadAllocator).divideRoundUp(ulong.sizeof)] _threadAllocatorState; - () @trusted { + () @trusted + { _threadAllocator = RCIAllocator(emplace!(ThreadAllocator)(_threadAllocatorState[], processAllocator())); }(); return _threadAllocator; @@ -1375,9 +1376,13 @@ nothrow @safe @nogc unittest cast(void) Mallocator.instance.make!Pure(0); static int g = 0; - static struct Impure { this(int) nothrow @nogc @safe { - g++; - } } + static struct Impure + { + this(int) nothrow @nogc @safe + { + g++; + } + } static assert(!__traits(compiles, cast(void) Mallocator.instance.make!Impure(0))); } @@ -2047,7 +2052,8 @@ if (isInputRange!R && !isInfinite!R) int val; @disable this(); - this(int b){ + this(int b) + { this.val = i++; } @@ -3743,7 +3749,8 @@ unittest foreach (b; allox) { - () pure nothrow @safe { + () pure nothrow @safe + { void[] p; Ternary r = (() @nogc => a.resolveInternalPointer(&b[0], p))(); assert(&p[0] == &b[0] && p.length >= b.length); diff --git a/std/format/internal/write.d b/std/format/internal/write.d index 85954faa35e..e4b13c62495 100644 --- a/std/format/internal/write.d +++ b/std/format/internal/write.d @@ -145,9 +145,7 @@ if (is(IntegralTypeOf!T) && !is(T == enum) && !hasToString!(T, Char)) if (f.spec == 'r') { // raw write, skip all else and write the thing - auto raw = (ref val) @trusted { - return (cast(const char*) &val)[0 .. val.sizeof]; - }(val); + auto raw = (ref val) @trusted { return (cast(const char*) &val)[0 .. val.sizeof]; }(val); import std.range.primitives : put; if (needToSwapEndianess(f)) foreach_reverse (c; raw) @@ -580,9 +578,7 @@ if (is(FloatingPointTypeOf!T) && !is(T == enum) && !hasToString!(T, Char)) if (spec == 'r') { // raw write, skip all else and write the thing - auto raw = (ref val) @trusted { - return (cast(const char*) &val)[0 .. val.sizeof]; - }(val); + auto raw = (ref val) @trusted { return (cast(const char*) &val)[0 .. val.sizeof]; }(val); if (needToSwapEndianess(f)) { @@ -1840,7 +1836,8 @@ template hasToString(T, Char) enum hasToString = HasToStringResult.none; } else static if (is(typeof( - (T val) { + (T val) + { const FormatSpec!Char f; static struct S {void put(scope Char s){}} S s; @@ -1854,7 +1851,8 @@ template hasToString(T, Char) enum hasToString = HasToStringResult.customPutWriterFormatSpec; } else static if (is(typeof( - (T val) { + (T val) + { static struct S {void put(scope Char s){}} S s; val.toString(s); @@ -2206,6 +2204,7 @@ if (hasToString!(T, Char)) static union UF2 { string toString() { return ""; } } static class CF2 { override string toString() { return ""; } } + //dfmt off static interface IK1 { void toString(scope void delegate(scope const(char)[]) sink, FormatSpec!char) const; } static class CIK1 : IK1 { override void toString(scope void delegate(scope const(char)[]) sink, @@ -2219,6 +2218,7 @@ if (hasToString!(T, Char)) static class KC1 { void toString(scope void delegate(scope const(char)[]) sink, FormatSpec!char) const { sink("KC1"); } } + //dfmt on IF1 cif1 = new CIF1; assertThrown!FormatException(format("%f", cif1)); assertThrown!FormatException(format("%f", SF1())); diff --git a/std/format/package.d b/std/format/package.d index f1d47055836..792b638fd87 100644 --- a/std/format/package.d +++ b/std/format/package.d @@ -1668,7 +1668,8 @@ if (isSomeString!(typeof(fmt))) assert(sformat(buf[], "foo%%") == "foo%"); assert(sformat(buf[], "foo%s", 'C') == "fooC"); assert(sformat(buf[], "%s foo", "bar") == "bar foo"); - () @trusted { + () @trusted + { assertThrown!RangeError(sformat(buf[], "%s foo %s", "bar", "abc")); } (); assert(sformat(buf[], "foo %d", -123) == "foo -123"); diff --git a/std/format/write.d b/std/format/write.d index 2aa45d724b5..235e315725e 100644 --- a/std/format/write.d +++ b/std/format/write.d @@ -1292,7 +1292,8 @@ void formatValue(Writer, T, Char)(auto ref Writer w, auto ref T val, scope const @safe pure unittest { static enum State: ubyte { INACTIVE } - static struct S { + static struct S + { State state = State.INACTIVE; int generation = 1; alias state this; diff --git a/std/getopt.d b/std/getopt.d index cb97eebe31b..ad619ea06d9 100644 --- a/std/getopt.d +++ b/std/getopt.d @@ -460,7 +460,8 @@ GetoptResult getopt(T...)(ref string[] args, T opts) You can pass them to `getopt` in any position, except in between an option string and its bound pointer. */ -enum config { +enum config +{ /// Turn case sensitivity on caseSensitive, /// Turn case sensitivity off (default) @@ -485,14 +486,16 @@ enum config { `helpWanted` is set if the option `--help` or `-h` was passed to the option parser. */ -struct GetoptResult { +struct GetoptResult +{ bool helpWanted; /// Flag indicating if help was requested Option[] options; /// All possible options } /** Information about an option. */ -struct Option { +struct Option +{ string optShort; /// The short symbol for this option string optLong; /// The long symbol for this option string help; /// The description of this option @@ -1485,7 +1488,8 @@ private void setConfig(ref configuration cfg, config option) @safe pure nothrow { import std.exception; - enum Foo { + enum Foo + { bar, baz } diff --git a/std/json.d b/std/json.d index 6e94a5d71ce..0521b11ad83 100644 --- a/std/json.d +++ b/std/json.d @@ -486,7 +486,8 @@ struct JSONValue { type_tag = JSONType.string; // FIXME: std.Array.Array(Range) is not deduced as 'pure' - () @trusted { + () @trusted + { import std.utf : byUTF; store.str = cast(immutable)(arg.byUTF!char.array); }(); @@ -1211,7 +1212,8 @@ if (isSomeFiniteCharInputRange!T) return str.data.length ? str.data : ""; } - bool tryGetSpecialFloat(string str, out double val) { + bool tryGetSpecialFloat(string str, out double val) + { switch (str) { case JSONFloatLiteral.nan: @@ -2164,7 +2166,8 @@ EOF"; import std.math.traits : isNaN, isInfinity; // expected representations of NaN and Inf - enum { + enum + { nanString = '"' ~ JSONFloatLiteral.nan ~ '"', infString = '"' ~ JSONFloatLiteral.inf ~ '"', negativeInfString = '"' ~ JSONFloatLiteral.negativeInf ~ '"', @@ -2216,7 +2219,8 @@ pure nothrow @safe @nogc unittest pure nothrow @safe unittest { import std.typecons; - void Test(C)() { + void Test(C)() + { C[] a = ['x']; JSONValue testVal = a; assert(testVal.type == JSONType.string); diff --git a/std/logger/core.d b/std/logger/core.d index 846f6ee214a..3a1c216a4fb 100644 --- a/std/logger/core.d +++ b/std/logger/core.d @@ -559,7 +559,8 @@ abstract class Logger this(this This)(LogLevel lv) { this.logLevel_ = lv; - this.fatalHandler_ = delegate() { + this.fatalHandler_ = delegate() + { throw new Error("A fatal log message was logged"); }; @@ -1420,7 +1421,8 @@ private @property shared(Logger) defaultSharedLoggerImpl() @trusted void[__traits(classInstanceSize, FileLogger)] _buffer = void; import std.concurrency : initOnce; - initOnce!stdSharedDefaultLogger({ + initOnce!stdSharedDefaultLogger( + { auto buffer = cast(ubyte[]) _buffer; return cast(shared) emplace!(FileLogger)(buffer, stderr, LogLevel.info); }()); @@ -1711,13 +1713,9 @@ version (StdUnittest) private void testFuncNames(Logger logger) @safe assert(tl1.line == __LINE__ - 3); auto oldunspecificLogger = sharedLog; - scope(exit) { - sharedLog = atomicLoad(oldunspecificLogger); - } + scope(exit) sharedLog = atomicLoad(oldunspecificLogger); - () @trusted { - sharedLog = cast(shared) tl1; - }(); + () @trusted { sharedLog = cast(shared) tl1; }(); log(); assert(tl1.line == __LINE__ - 1); @@ -1764,9 +1762,7 @@ version (StdUnittest) private void testFuncNames(Logger logger) @safe { bool errorThrown = false; auto tl = new TestLogger; - auto dele = delegate() { - errorThrown = true; - }; + auto dele = delegate() { errorThrown = true; }; tl.fatalHandler = dele; tl.fatal(); assert(errorThrown); @@ -1815,17 +1811,13 @@ version (StdUnittest) private void testFuncNames(Logger logger) @safe assert(l.line == lineNumber); assert(l.logLevel == LogLevel.all); - () @trusted { - assertThrown!Throwable(l.logf(LogLevel.fatal, msg, "Yet")); - } (); + () @trusted { assertThrown!Throwable(l.logf(LogLevel.fatal, msg, "Yet")); }(); lineNumber = __LINE__ - 2; assert(l.msg == msg.format("Yet")); assert(l.line == lineNumber); assert(l.logLevel == LogLevel.all); - () @trusted { - assertThrown!Throwable(l.logf(LogLevel.fatal, true, msg, "Yet")); - } (); + () @trusted { assertThrown!Throwable(l.logf(LogLevel.fatal, true, msg, "Yet")); }(); lineNumber = __LINE__ - 2; assert(l.msg == msg.format("Yet")); assert(l.line == lineNumber); @@ -1837,32 +1829,24 @@ version (StdUnittest) private void testFuncNames(Logger logger) @safe assert(l.logLevel == LogLevel.all); Logger oldunspecificLogger; - () @trusted { - oldunspecificLogger = cast() sharedLog; - }(); + () @trusted { oldunspecificLogger = cast() sharedLog; }(); assert(oldunspecificLogger.logLevel == LogLevel.info, to!string(oldunspecificLogger.logLevel)); assert(l.logLevel == LogLevel.all); - () @trusted { - sharedLog = cast(shared) l; - }(); + () @trusted { sharedLog = cast(shared) l; }(); assert(globalLogLevel == LogLevel.all, to!string(globalLogLevel)); scope(exit) { - () @trusted { - sharedLog = atomicLoad(cast(shared) oldunspecificLogger); - }(); + () @trusted { sharedLog = atomicLoad(cast(shared) oldunspecificLogger); }(); } - () @trusted { - assert((cast() sharedLog).logLevel == LogLevel.all); - }(); + () @trusted { assert((cast() sharedLog).logLevel == LogLevel.all); }(); assert(stdThreadLocalLog.logLevel == LogLevel.all); assert(globalLogLevel == LogLevel.all); @@ -1904,7 +1888,8 @@ version (StdUnittest) private void testFuncNames(Logger logger) @safe assert(l.logLevel == LogLevel.all); msg = "%s Another message"; - () @trusted { + () @trusted + { assertThrown!Throwable(logf(LogLevel.fatal, msg, "Yet")); } (); lineNumber = __LINE__ - 2; @@ -1912,7 +1897,8 @@ version (StdUnittest) private void testFuncNames(Logger logger) @safe assert(l.line == lineNumber); assert(l.logLevel == LogLevel.all); - () @trusted { + () @trusted + { assertThrown!Throwable(logf(LogLevel.fatal, true, msg, "Yet")); } (); lineNumber = __LINE__ - 2; @@ -1989,7 +1975,8 @@ version (StdUnittest) private void testFuncNames(Logger logger) @safe auto l = new FileLogger(filename); sharedLog = cast(shared) l; - () @trusted { + () @trusted + { (cast() sharedLog).logLevel = LogLevel.critical; }(); @@ -2034,7 +2021,8 @@ version (StdUnittest) private void testFuncNames(Logger logger) @safe auto mem = new TestLogger; mem.fatalHandler = delegate() {}; - () @trusted { + () @trusted + { sharedLog = cast(shared) mem; }(); @@ -2284,7 +2272,8 @@ version (StdUnittest) private void testFuncNames(Logger logger) @safe auto mem = new TestLogger; mem.fatalHandler = delegate() {}; - () @trusted { + () @trusted + { sharedLog = cast(shared) mem; }(); @@ -2542,7 +2531,8 @@ version (StdUnittest) private void testFuncNames(Logger logger) @safe stdThreadLocalLog.logLevel = LogLevel.all; - () @trusted { + () @trusted + { sharedLog = cast(shared) mem; }(); @@ -2781,7 +2771,8 @@ version (StdUnittest) private void testFuncNames(Logger logger) @safe auto tl = new TestLogger(LogLevel.info); - () @trusted { + () @trusted + { sharedLog = cast(shared) tl; }(); @@ -2810,7 +2801,8 @@ version (StdUnittest) private void testFuncNames(Logger logger) @safe auto tl = new TestLogger(LogLevel.info); logger.insertLogger("required", tl); - () @trusted { + () @trusted + { sharedLog = cast(shared) logger; }(); @@ -2901,7 +2893,8 @@ private void trustedStore(T)(ref shared T dst, ref T src) @trusted sharedLog = atomicLoad(oldSharedLog); } - () @trusted { + () @trusted + { sharedLog = cast(shared) new IgnoredLog; }(); @@ -2924,7 +2917,8 @@ private void trustedStore(T)(ref shared T dst, ref T src) @trusted @safe unittest { - auto dl = () @trusted { + auto dl = () @trusted + { return cast(FileLogger) cast() sharedLog; }(); assert(dl !is null); @@ -3034,7 +3028,8 @@ private void trustedStore(T)(ref shared T dst, ref T src) @trusted auto fl = new FileLogger(fn); - () @trusted { + () @trusted + { sharedLog = cast(shared) fl; }(); diff --git a/std/math/exponential.d b/std/math/exponential.d index 2c28ebaf017..17dacae7100 100644 --- a/std/math/exponential.d +++ b/std/math/exponential.d @@ -2458,7 +2458,8 @@ if (isFloatingPoint!T) @safe unittest { import std.meta : AliasSeq; - void foo() { + void foo() + { static foreach (T; AliasSeq!(real, double, float)) {{ int exp; diff --git a/std/math/hardware.d b/std/math/hardware.d index cca9f3ba10b..3e3b627dabd 100644 --- a/std/math/hardware.d +++ b/std/math/hardware.d @@ -241,7 +241,8 @@ version (StdDdoc) { import std.math.traits : isNaN; - static void func() { + static void func() + { int a = 10 * 10; } real a = 3.5; @@ -268,7 +269,8 @@ version (StdDdoc) { import std.math.traits : isNaN; - static void func() { + static void func() + { int a = 10 * 10; } real a = 3.5; diff --git a/std/math/trigonometry.d b/std/math/trigonometry.d index a3d04c60402..e0ed9cba72a 100644 --- a/std/math/trigonometry.d +++ b/std/math/trigonometry.d @@ -952,7 +952,8 @@ private real atan2Asm(real y, real x) @trusted pure nothrow @nogc { version (Win64) { - asm pure nothrow @nogc { + asm pure nothrow @nogc + { naked; fld real ptr [RDX]; // y fld real ptr [RCX]; // x @@ -962,7 +963,8 @@ private real atan2Asm(real y, real x) @trusted pure nothrow @nogc } else { - asm pure nothrow @nogc { + asm pure nothrow @nogc + { fld y; fld x; fpatan; diff --git a/std/meta.d b/std/meta.d index 2db341da85e..ead5806bd30 100644 --- a/std/meta.d +++ b/std/meta.d @@ -657,7 +657,8 @@ template staticMap(alias fun, args...) // @@@ BUG @@@ The test below exposes failure of the straightforward use. // See @adamdruppe's comment to https://github.com/dlang/phobos/pull/8039 - template id(alias what) { + template id(alias what) + { enum id = __traits(identifier, what); } enum A { a } @@ -1156,7 +1157,8 @@ private template SmartAlias(T...) @safe unittest { - static assert(is(typeof({ + static assert(is(typeof( + { alias T(T0, int a, double b, alias T1, string c) = AliasSeq!(T0, a, b, T1, c); alias T0 = ApplyRight!(ApplyLeft, ApplyRight); alias T1 = T0!ApplyLeft; diff --git a/std/numeric.d b/std/numeric.d index 648b70eeea8..4e22b54d057 100644 --- a/std/numeric.d +++ b/std/numeric.d @@ -3132,7 +3132,8 @@ if (!isIntegral!T) { pragma(inline, true); import std.algorithm.mutation : swap; - enum canUseBinaryGcd = is(typeof(() { + enum canUseBinaryGcd = is(typeof(() + { T t, u; t <<= 1; t >>= 1; diff --git a/std/typecons.d b/std/typecons.d index 67a1ede8148..e89f8d529a9 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -2633,10 +2633,12 @@ private: } } - static assert(!__traits(compiles, () @safe { + static assert(!__traits(compiles, () @safe + { auto r = Rebindable!(immutable Foo)(new Foo); })); - static assert(__traits(compiles, () @system { + static assert(__traits(compiles, () @system + { auto r = Rebindable!(immutable Foo)(new Foo); })); } @@ -2871,7 +2873,8 @@ Rebindable!T rebindable(T)(Rebindable!T obj) @system unittest { interface CI { int foo() const; } - class C : CI { + class C : CI + { int foo() const { return 42; } @property int bar() const { return 23; } } @@ -3126,7 +3129,8 @@ if (is(T == class) || is(T == interface)) import core.thread; - auto thread = new core.thread.Thread({ + auto thread = new core.thread.Thread( + { a = new shared Data(); b = new shared Data(); }); @@ -3783,7 +3787,8 @@ auto nullable(T)(T t) } @safe unittest { - static int f(scope const Nullable!int x) { + static int f(scope const Nullable!int x) + { return x.isNull ? 42 : x.get; } Nullable!int a; @@ -4621,7 +4626,8 @@ if (is (typeof(nullValue) == T)) @safe unittest { - static int f(scope const Nullable!(int, int.min) x) { + static int f(scope const Nullable!(int, int.min) x) + { return x.isNull ? 42 : x.get; } Nullable!(int, int.min) a; @@ -5085,7 +5091,8 @@ auto nullableRef(T)(T* t) } @system unittest { - static int f(scope const NullableRef!int x) { + static int f(scope const NullableRef!int x) + { return x.isNull ? 42 : x.get; } int x = 5; @@ -5806,7 +5813,8 @@ private static: { private string foo_; - this(string s) { + this(string s) + { foo_ = s; } @@ -5897,7 +5905,8 @@ private static: { private string n_; - public { + public + { Issue17177 overloaded(string n) { this.n_ = n; @@ -5963,7 +5972,8 @@ version (StdUnittest) } // A class to be overridden - private class issue10647_Foo{ + private class issue10647_Foo + { void bar(int a) { } } } @@ -7600,7 +7610,8 @@ pure @system unittest // https://issues.dlang.org/show_bug.cgi?id=6606 @betterC @safe pure nothrow @nogc unittest { - union U { + union U + { size_t i; void* p; } @@ -7615,12 +7626,14 @@ pure @system unittest // Same as above but for old RefCounted and not @safe @betterC @system pure nothrow @nogc unittest { - union U { + union U + { size_t i; void* p; } - struct S { + struct S + { U u; } @@ -8625,7 +8638,8 @@ mixin template Proxy(alias a) } // workaround for https://issues.dlang.org/show_bug.cgi?id=19669 -private enum isDIP1000 = __traits(compiles, () @safe { +private enum isDIP1000 = __traits(compiles, () @safe +{ int x; int* p; p = &x; @@ -9254,11 +9268,13 @@ if (is(T == class)) import std.algorithm.mutation : move; auto invalid = a1.move; // illegal, scoped objects can't be moved } - static assert(!is(typeof({ + static assert(!is(typeof( + { auto e1 = a1; // illegal, scoped objects can't be copied assert([a1][0].x == 42); // ditto }))); - static assert(!is(typeof({ + static assert(!is(typeof( + { alias ScopedObject = typeof(a1); auto e2 = ScopedObject(); // illegal, must be built via scoped!A auto e3 = ScopedObject(1); // ditto @@ -9609,7 +9625,8 @@ kinds of coupling. The author argues citing several studies that coupling has a negative effect on code quality. `Flag` offers a simple structuring method for passing yes/no flags to APIs. */ -template Flag(string name) { +template Flag(string name) +{ /// enum Flag : bool { @@ -10184,7 +10201,8 @@ template ReplaceTypeUnless(alias pred, From, To, T...) { template replaceTemplateArgs(T...) { - static if (is(typeof(T[0]))) { // template argument is value or symbol + static if (is(typeof(T[0]))) // template argument is value or symbol + { static if (__traits(compiles, { alias _ = T[0]; })) // it's a symbol alias replaceTemplateArgs = T[0]; diff --git a/std/uri.d b/std/uri.d index bf7cbc06438..ff7923257ea 100644 --- a/std/uri.d +++ b/std/uri.d @@ -54,8 +54,8 @@ private enum private immutable char[16] hex2ascii = "0123456789ABCDEF"; -private immutable ubyte[128] uri_flags = // indexed by character - ({ +private immutable ubyte[128] uri_flags = ( // indexed by character + { ubyte[128] uflags; // Compile time initialize diff --git a/std/utf.d b/std/utf.d index 3eef5cbcc03..8f159223a85 100644 --- a/std/utf.d +++ b/std/utf.d @@ -2278,13 +2278,11 @@ version (StdUnittest) private void testBadDecodeBack(R)(R range, size_t line = _ static assert(isSafe!({ S str; size_t i = 0; decodeFront(str, i); })); static assert(isSafe!({ S str; decodeFront(str); })); static assert((functionAttributes!({ S str; size_t i = 0; decode(str, i); }) & FunctionAttribute.pure_) != 0); - static assert((functionAttributes!({ - S str; size_t i = 0; decodeFront(str, i); - }) & FunctionAttribute.pure_) != 0); + static assert((functionAttributes!({ S str; size_t i = 0; decodeFront(str, i);}) & + FunctionAttribute.pure_) != 0); static assert((functionAttributes!({ S str; decodeFront(str); }) & FunctionAttribute.pure_) != 0); - static assert((functionAttributes!({ - S str; size_t i = 0; decodeBack(str, i); - }) & FunctionAttribute.pure_) != 0); + static assert((functionAttributes!({ S str; size_t i = 0; decodeBack(str, i);}) & + FunctionAttribute.pure_) != 0); static assert((functionAttributes!({ S str; decodeBack(str); }) & FunctionAttribute.pure_) != 0); } }); @@ -2953,7 +2951,8 @@ if (isSomeString!S) @safe unittest { import std.exception; - assertThrown((){ + assertThrown(() + { char[3]a=[167, 133, 175]; validate(a[]); }()); diff --git a/std/zlib.d b/std/zlib.d index beb280f891d..acc05f909b9 100644 --- a/std/zlib.d +++ b/std/zlib.d @@ -330,7 +330,8 @@ void arrayPrint(ubyte[] array) +/ /// the header format the compressed stream is wrapped in -enum HeaderFormat { +enum HeaderFormat +{ deflate, /// a standard zlib header gzip, /// a gzip file format header determineFromData /// used when decompressing. Try to automatically detect the stream format by looking at the data