summaryrefslogtreecommitdiffstats
path: root/libphobos
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2022-01-02 13:36:51 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2022-01-03 12:26:05 +0100
commitc43b5909031c7aa32ac65df3e392a12d32c45194 (patch)
treeb7ef2e344e36132f68816e197e39c58bd39e9ac9 /libphobos
parentdocs: Use ; for function declarations. (diff)
downloadgcc-c43b5909031c7aa32ac65df3e392a12d32c45194.tar.gz
gcc-c43b5909031c7aa32ac65df3e392a12d32c45194.tar.bz2
gcc-c43b5909031c7aa32ac65df3e392a12d32c45194.tar.xz
d: Merge upstream dmd 001bfd97b, druntime 759e6023, phobos 468788323.
D front-end changes: - Import latest changes to mainline. - Fix bad format specifiers in front-end errors (PR103840). - Refactoring of some leaf modules to the dmd/root package. - Updating copyright notice dates and urls. Phobos changes: - Import latest changes to mainline. gcc/d/ChangeLog: PR d/103840 * dmd/MERGE: Merge upstream dmd 001bfd97b. * Make-lang.in (D_FRONTEND_OBJS): Rename d/complex.o to d/root-complex.o, and d/utf.o to d/root/utf.o. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 759e6023. * src/MERGE: Merge upstream phobos 468788323.
Diffstat (limited to 'libphobos')
-rw-r--r--libphobos/libdruntime/MERGE2
-rw-r--r--libphobos/src/MERGE2
-rw-r--r--libphobos/src/std/algorithm/mutation.d20
-rw-r--r--libphobos/src/std/container/array.d45
-rw-r--r--libphobos/src/std/conv.d4
-rw-r--r--libphobos/src/std/format/internal/read.d22
-rw-r--r--libphobos/src/std/format/read.d13
-rw-r--r--libphobos/src/std/sumtype.d1
-rw-r--r--libphobos/src/std/uni/package.d8
-rw-r--r--libphobos/src/std/utf.d25
-rw-r--r--libphobos/src/std/xml.d2
11 files changed, 89 insertions, 55 deletions
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
index 70f7ff596a8..3aa798a543c 100644
--- a/libphobos/libdruntime/MERGE
+++ b/libphobos/libdruntime/MERGE
@@ -1,4 +1,4 @@
1fd9a45448244fb9dd4326520ad8526c540895eb0 1759e60231a12482a1e1df5f891964e270dae0a1b
2 2
3The first line of this file holds the git revision number of the last 3The first line of this file holds the git revision number of the last
4merge done from the dlang/druntime repository. 4merge done from the dlang/druntime repository.
diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE
index b517749b542..b60fa170c4c 100644
--- a/libphobos/src/MERGE
+++ b/libphobos/src/MERGE
@@ -1,4 +1,4 @@
1495e835c2da47606142ff24c85de707e3b955a9a 14687883231eba3bda7691321f2af107fdb3d0a44
2 2
3The first line of this file holds the git revision number of the last 3The first line of this file holds the git revision number of the last
4merge done from the dlang/phobos repository. 4merge done from the dlang/phobos repository.
diff --git a/libphobos/src/std/algorithm/mutation.d b/libphobos/src/std/algorithm/mutation.d
index 22b7b98c229..b0e77076812 100644
--- a/libphobos/src/std/algorithm/mutation.d
+++ b/libphobos/src/std/algorithm/mutation.d
@@ -866,6 +866,9 @@ if (isInputRange!InputRange
866Initializes all elements of `range` with their `.init` value. 866Initializes all elements of `range` with their `.init` value.
867Assumes that the elements of the range are uninitialized. 867Assumes that the elements of the range are uninitialized.
868 868
869This function is unavailable if `T` is a `struct` and `T.this()` is annotated
870with `@disable`.
871
869Params: 872Params:
870 range = An 873 range = An
871 $(REF_ALTTEXT input range, isInputRange, std,range,primitives) 874 $(REF_ALTTEXT input range, isInputRange, std,range,primitives)
@@ -874,10 +877,11 @@ Params:
874 877
875See_Also: 878See_Also:
876 $(LREF fill) 879 $(LREF fill)
877 $(LREF uninitializeFill) 880 $(LREF uninitializedFill)
878 */ 881 */
879void initializeAll(Range)(Range range) 882void initializeAll(Range)(Range range)
880if (isInputRange!Range && hasLvalueElements!Range && hasAssignableElements!Range) 883if (isInputRange!Range && hasLvalueElements!Range && hasAssignableElements!Range
884 && __traits(compiles, { static ElementType!Range _; }))
881{ 885{
882 import core.stdc.string : memset, memcpy; 886 import core.stdc.string : memset, memcpy;
883 import std.traits : hasElaborateAssign, isDynamicArray; 887 import std.traits : hasElaborateAssign, isDynamicArray;
@@ -1037,6 +1041,18 @@ if (is(Range == char[]) || is(Range == wchar[]))
1037 assert(xs[1].x == 3); 1041 assert(xs[1].x == 3);
1038} 1042}
1039 1043
1044// https://issues.dlang.org/show_bug.cgi?id=22105
1045@system unittest
1046{
1047 struct NoDefaultCtor
1048 {
1049 @disable this();
1050 }
1051
1052 NoDefaultCtor[1] array = void;
1053 static assert(!__traits(compiles, array[].initializeAll));
1054}
1055
1040// move 1056// move
1041/** 1057/**
1042Moves `source` into `target`, via a destructive copy when necessary. 1058Moves `source` into `target`, via a destructive copy when necessary.
diff --git a/libphobos/src/std/container/array.d b/libphobos/src/std/container/array.d
index 63dc86403ec..08f9ead196e 100644
--- a/libphobos/src/std/container/array.d
+++ b/libphobos/src/std/container/array.d
@@ -428,8 +428,6 @@ if (!is(immutable T == immutable bool))
428 428
429 @property void length(size_t newLength) 429 @property void length(size_t newLength)
430 { 430 {
431 import std.algorithm.mutation : initializeAll;
432
433 if (length >= newLength) 431 if (length >= newLength)
434 { 432 {
435 // shorten 433 // shorten
@@ -440,10 +438,22 @@ if (!is(immutable T == immutable bool))
440 _payload = _payload.ptr[0 .. newLength]; 438 _payload = _payload.ptr[0 .. newLength];
441 return; 439 return;
442 } 440 }
443 immutable startEmplace = length; 441
444 reserve(newLength); 442 static if (__traits(compiles, { static T _; }))
445 initializeAll(_payload.ptr[startEmplace .. newLength]); 443 {
446 _payload = _payload.ptr[0 .. newLength]; 444 import std.algorithm.mutation : initializeAll;
445
446 immutable startEmplace = length;
447 reserve(newLength);
448 initializeAll(_payload.ptr[startEmplace .. newLength]);
449 _payload = _payload.ptr[0 .. newLength];
450 }
451 else
452 {
453 assert(0, "Cannot add elements to array because `" ~
454 fullyQualifiedName!T ~ ".this()` is annotated with " ~
455 "`@disable`.");
456 }
447 } 457 }
448 458
449 @property size_t capacity() const 459 @property size_t capacity() const
@@ -901,12 +911,16 @@ if (!is(immutable T == immutable bool))
901 /** 911 /**
902 * Sets the number of elements in the array to `newLength`. If `newLength` 912 * Sets the number of elements in the array to `newLength`. If `newLength`
903 * is greater than `length`, the new elements are added to the end of the 913 * is greater than `length`, the new elements are added to the end of the
904 * array and initialized with `T.init`. 914 * array and initialized with `T.init`. If `T` is a `struct` whose default
915 * constructor is annotated with `@disable`, `newLength` must be lower than
916 * or equal to `length`.
905 * 917 *
906 * Complexity: 918 * Complexity:
907 * Guaranteed $(BIGOH abs(length - newLength)) if `capacity >= newLength`. 919 * Guaranteed $(BIGOH abs(length - newLength)) if `capacity >= newLength`.
908 * If `capacity < newLength` the worst case is $(BIGOH newLength). 920 * If `capacity < newLength` the worst case is $(BIGOH newLength).
909 * 921 *
922 * Precondition: `__traits(compiles, { static T _; }) || newLength <= length`
923 *
910 * Postcondition: `length == newLength` 924 * Postcondition: `length == newLength`
911 */ 925 */
912 @property void length(size_t newLength) 926 @property void length(size_t newLength)
@@ -1708,6 +1722,23 @@ if (!is(immutable T == immutable bool))
1708 assert(equal(a[], [1,2,3,4,5,6,7,8])); 1722 assert(equal(a[], [1,2,3,4,5,6,7,8]));
1709} 1723}
1710 1724
1725// https://issues.dlang.org/show_bug.cgi?id=22105
1726@system unittest
1727{
1728 import core.exception : AssertError;
1729 import std.exception : assertThrown, assertNotThrown;
1730
1731 struct NoDefaultCtor
1732 {
1733 int i;
1734 @disable this();
1735 this(int j) { i = j; }
1736 }
1737
1738 auto array = Array!NoDefaultCtor([NoDefaultCtor(1), NoDefaultCtor(2)]);
1739 assertNotThrown!AssertError(array.length = 1);
1740 assertThrown!AssertError(array.length = 5);
1741}
1711 1742
1712//////////////////////////////////////////////////////////////////////////////// 1743////////////////////////////////////////////////////////////////////////////////
1713// Array!bool 1744// Array!bool
diff --git a/libphobos/src/std/conv.d b/libphobos/src/std/conv.d
index d9db9b08d6b..98df7fd1ccf 100644
--- a/libphobos/src/std/conv.d
+++ b/libphobos/src/std/conv.d
@@ -2377,7 +2377,7 @@ Throws:
2377 A $(LREF ConvException) If an overflow occurred during conversion or 2377 A $(LREF ConvException) If an overflow occurred during conversion or
2378 if no character of the input was meaningfully converted. 2378 if no character of the input was meaningfully converted.
2379*/ 2379*/
2380auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref Source s) 2380auto parse(Target, Source, Flag!"doCount" doCount = No.doCount)(ref scope Source s)
2381if (isSomeChar!(ElementType!Source) && 2381if (isSomeChar!(ElementType!Source) &&
2382 isIntegral!Target && !is(Target == enum)) 2382 isIntegral!Target && !is(Target == enum))
2383{ 2383{
@@ -2482,7 +2482,7 @@ if (isSomeChar!(ElementType!Source) &&
2482 v = -v; 2482 v = -v;
2483 2483
2484 static if (isNarrowString!Source) 2484 static if (isNarrowString!Source)
2485 s = cast(Source) source; 2485 s = s[$-source.length..$];
2486 2486
2487 static if (doCount) 2487 static if (doCount)
2488 { 2488 {
diff --git a/libphobos/src/std/format/internal/read.d b/libphobos/src/std/format/internal/read.d
index 102e59fcd5c..9130499081c 100644
--- a/libphobos/src/std/format/internal/read.d
+++ b/libphobos/src/std/format/internal/read.d
@@ -228,26 +228,8 @@ if (isInputRange!Range && is(StringTypeOf!T) && !isAggregateType!T && !is(T == e
228} 228}
229 229
230T unformatValueImpl(T, Range, Char)(ref Range input, scope const ref FormatSpec!Char fmt) 230T unformatValueImpl(T, Range, Char)(ref Range input, scope const ref FormatSpec!Char fmt)
231if (isInputRange!Range && isArray!T && !is(StringTypeOf!T) && !isAggregateType!T 231if (isInputRange!Range && !is(StringTypeOf!T) && !isAggregateType!T
232 && !is(T == enum)) 232 && (isArray!T || isAssociativeArray!T || is(T == enum)))
233{
234 import std.conv : parse, text;
235 import std.format : enforceFmt;
236
237 const spec = fmt.spec;
238 if (spec == '(')
239 {
240 return unformatRange!T(input, fmt);
241 }
242
243 enforceFmt(spec == 's',
244 text("Wrong unformat specifier '%", spec , "' for ", T.stringof));
245
246 return parse!T(input);
247}
248
249T unformatValueImpl(T, Range, Char)(ref Range input, scope const ref FormatSpec!Char fmt)
250if (isInputRange!Range && isAssociativeArray!T && !is(T == enum))
251{ 233{
252 import std.conv : parse, text; 234 import std.conv : parse, text;
253 import std.format : enforceFmt; 235 import std.format : enforceFmt;
diff --git a/libphobos/src/std/format/read.d b/libphobos/src/std/format/read.d
index 0de88183fb2..b3d8d1f6c3f 100644
--- a/libphobos/src/std/format/read.d
+++ b/libphobos/src/std/format/read.d
@@ -719,3 +719,16 @@ T unformatValue(T, Range, Char)(ref Range input, scope const ref FormatSpec!Char
719 int b; 719 int b;
720 assertThrown(formattedRead(str, "%s %d-%s", &a, &b, &c)); 720 assertThrown(formattedRead(str, "%s %d-%s", &a, &b, &c));
721} 721}
722
723// https://issues.dlang.org/show_bug.cgi?id=18051
724@safe pure unittest
725{
726 import std.format : format;
727
728 enum Op { lt, gt, eq }
729
730 auto s = format!"%s"(Op.lt);
731 Op op;
732 assert(formattedRead!"%s"(s, op) == 1);
733 assert(op == Op.lt);
734}
diff --git a/libphobos/src/std/sumtype.d b/libphobos/src/std/sumtype.d
index 8242f1e3ee5..658fd384784 100644
--- a/libphobos/src/std/sumtype.d
+++ b/libphobos/src/std/sumtype.d
@@ -1700,7 +1700,6 @@ template match(handlers...)
1700 * Throws: 1700 * Throws:
1701 * [MatchException], if the currently-held type has no matching handler. 1701 * [MatchException], if the currently-held type has no matching handler.
1702 * 1702 *
1703 * See_Also: `std.variant.tryVisit`
1704 * See_Also: $(REF tryVisit, std,variant) 1703 * See_Also: $(REF tryVisit, std,variant)
1705 */ 1704 */
1706version (D_Exceptions) 1705version (D_Exceptions)
diff --git a/libphobos/src/std/uni/package.d b/libphobos/src/std/uni/package.d
index a27cbea177b..192b6fd2b2d 100644
--- a/libphobos/src/std/uni/package.d
+++ b/libphobos/src/std/uni/package.d
@@ -5798,7 +5798,7 @@ if (is(Char1 : dchar) && is(Char2 : dchar))
5798// Utilities for compression of Unicode code point sets 5798// Utilities for compression of Unicode code point sets
5799//============================================================================ 5799//============================================================================
5800 5800
5801@safe void compressTo(uint val, ref ubyte[] arr) pure nothrow 5801@safe void compressTo(uint val, ref scope ubyte[] arr) pure nothrow
5802{ 5802{
5803 // not optimized as usually done 1 time (and not public interface) 5803 // not optimized as usually done 1 time (and not public interface)
5804 if (val < 128) 5804 if (val < 128)
@@ -5817,7 +5817,7 @@ if (is(Char1 : dchar) && is(Char2 : dchar))
5817 } 5817 }
5818} 5818}
5819 5819
5820@safe uint decompressFrom(const(ubyte)[] arr, ref size_t idx) pure 5820@safe uint decompressFrom(scope const(ubyte)[] arr, ref size_t idx) pure
5821{ 5821{
5822 import std.exception : enforce; 5822 import std.exception : enforce;
5823 immutable first = arr[idx++]; 5823 immutable first = arr[idx++];
@@ -8412,7 +8412,7 @@ int hangulSyllableIndex(dchar ch) pure nothrow @nogc @safe
8412} 8412}
8413 8413
8414// internal helper: compose hangul syllables leaving dchar.init in holes 8414// internal helper: compose hangul syllables leaving dchar.init in holes
8415void hangulRecompose(dchar[] seq) pure nothrow @nogc @safe 8415void hangulRecompose(scope dchar[] seq) pure nothrow @nogc @safe
8416{ 8416{
8417 for (size_t idx = 0; idx + 1 < seq.length; ) 8417 for (size_t idx = 0; idx + 1 < seq.length; )
8418 { 8418 {
@@ -8695,7 +8695,7 @@ inout(C)[] normalize(NormalizationForm norm=NFC, C)(return scope inout(C)[] inpu
8695} 8695}
8696 8696
8697// canonically recompose given slice of code points, works in-place and mutates data 8697// canonically recompose given slice of code points, works in-place and mutates data
8698private size_t recompose(size_t start, dchar[] input, ubyte[] ccc) pure nothrow @safe 8698private size_t recompose(size_t start, scope dchar[] input, scope ubyte[] ccc) pure nothrow @safe
8699{ 8699{
8700 assert(input.length == ccc.length); 8700 assert(input.length == ccc.length);
8701 int accumCC = -1;// so that it's out of 0 .. 255 range 8701 int accumCC = -1;// so that it's out of 0 .. 255 range
diff --git a/libphobos/src/std/utf.d b/libphobos/src/std/utf.d
index 866ec48cbdc..a29025a179a 100644
--- a/libphobos/src/std/utf.d
+++ b/libphobos/src/std/utf.d
@@ -1168,7 +1168,7 @@ do
1168 1168
1169/// ditto 1169/// ditto
1170dchar decode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)( 1170dchar decode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)(
1171auto ref S str, ref size_t index) @trusted pure 1171auto ref scope S str, ref size_t index) @trusted pure
1172if (isSomeString!S) 1172if (isSomeString!S)
1173in 1173in
1174{ 1174{
@@ -1274,7 +1274,7 @@ do
1274 1274
1275/// ditto 1275/// ditto
1276dchar decodeFront(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)( 1276dchar decodeFront(UseReplacementDchar useReplacementDchar = No.useReplacementDchar, S)(
1277ref S str, out size_t numCodeUnits) @trusted pure 1277ref scope S str, out size_t numCodeUnits) @trusted pure
1278if (isSomeString!S) 1278if (isSomeString!S)
1279in 1279in
1280{ 1280{
@@ -2541,14 +2541,12 @@ size_t encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
2541 `UTFException` if `c` is not a valid UTF code point. 2541 `UTFException` if `c` is not a valid UTF code point.
2542 +/ 2542 +/
2543void encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)( 2543void encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
2544 ref char[] str, dchar c) @safe pure 2544 ref scope char[] str, dchar c) @safe pure
2545{ 2545{
2546 char[] r = str;
2547
2548 if (c <= 0x7F) 2546 if (c <= 0x7F)
2549 { 2547 {
2550 assert(isValidDchar(c)); 2548 assert(isValidDchar(c));
2551 r ~= cast(char) c; 2549 str ~= cast(char) c;
2552 } 2550 }
2553 else 2551 else
2554 { 2552 {
@@ -2589,9 +2587,8 @@ void encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
2589 c = _utfException!useReplacementDchar("Encoding an invalid code point in UTF-8", c); 2587 c = _utfException!useReplacementDchar("Encoding an invalid code point in UTF-8", c);
2590 goto L3; 2588 goto L3;
2591 } 2589 }
2592 r ~= buf[0 .. L]; 2590 str ~= buf[0 .. L];
2593 } 2591 }
2594 str = r;
2595} 2592}
2596 2593
2597/// 2594///
@@ -2666,10 +2663,8 @@ void encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
2666 2663
2667/// ditto 2664/// ditto
2668void encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)( 2665void encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
2669 ref wchar[] str, dchar c) @safe pure 2666 ref scope wchar[] str, dchar c) @safe pure
2670{ 2667{
2671 wchar[] r = str;
2672
2673 if (c <= 0xFFFF) 2668 if (c <= 0xFFFF)
2674 { 2669 {
2675 if (0xD800 <= c && c <= 0xDFFF) 2670 if (0xD800 <= c && c <= 0xDFFF)
@@ -2677,7 +2672,7 @@ void encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
2677 2672
2678 assert(isValidDchar(c)); 2673 assert(isValidDchar(c));
2679 L1: 2674 L1:
2680 r ~= cast(wchar) c; 2675 str ~= cast(wchar) c;
2681 } 2676 }
2682 else if (c <= 0x10FFFF) 2677 else if (c <= 0x10FFFF)
2683 { 2678 {
@@ -2686,7 +2681,7 @@ void encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
2686 assert(isValidDchar(c)); 2681 assert(isValidDchar(c));
2687 buf[0] = cast(wchar)((((c - 0x10000) >> 10) & 0x3FF) + 0xD800); 2682 buf[0] = cast(wchar)((((c - 0x10000) >> 10) & 0x3FF) + 0xD800);
2688 buf[1] = cast(wchar)(((c - 0x10000) & 0x3FF) + 0xDC00); 2683 buf[1] = cast(wchar)(((c - 0x10000) & 0x3FF) + 0xDC00);
2689 r ~= buf; 2684 str ~= buf;
2690 } 2685 }
2691 else 2686 else
2692 { 2687 {
@@ -2694,8 +2689,6 @@ void encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
2694 c = _utfException!useReplacementDchar("Encoding an invalid code point in UTF-16", c); 2689 c = _utfException!useReplacementDchar("Encoding an invalid code point in UTF-16", c);
2695 goto L1; 2690 goto L1;
2696 } 2691 }
2697
2698 str = r;
2699} 2692}
2700 2693
2701@safe unittest 2694@safe unittest
@@ -2727,7 +2720,7 @@ void encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
2727 2720
2728/// ditto 2721/// ditto
2729void encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)( 2722void encode(UseReplacementDchar useReplacementDchar = No.useReplacementDchar)(
2730 ref dchar[] str, dchar c) @safe pure 2723 ref scope dchar[] str, dchar c) @safe pure
2731{ 2724{
2732 if ((0xD800 <= c && c <= 0xDFFF) || 0x10FFFF < c) 2725 if ((0xD800 <= c && c <= 0xDFFF) || 0x10FFFF < c)
2733 c = _utfException!useReplacementDchar("Encoding an invalid code point in UTF-32", c); 2726 c = _utfException!useReplacementDchar("Encoding an invalid code point in UTF-32", c);
diff --git a/libphobos/src/std/xml.d b/libphobos/src/std/xml.d
index 37fab6db038..fdfdc3f70ab 100644
--- a/libphobos/src/std/xml.d
+++ b/libphobos/src/std/xml.d
@@ -433,7 +433,7 @@ enum DecodeMode
433 * writefln(decode("a &gt; b")); // writes "a > b" 433 * writefln(decode("a &gt; b")); // writes "a > b"
434 * -------------- 434 * --------------
435 */ 435 */
436string decode(return scope string s, DecodeMode mode=DecodeMode.LOOSE) @safe pure 436string decode(string s, DecodeMode mode=DecodeMode.LOOSE) @safe pure
437{ 437{
438 import std.algorithm.searching : startsWith; 438 import std.algorithm.searching : startsWith;
439 439