Merge pull request #8966 from ibuclaw/merge_stable

merge stable
This commit is contained in:
Iain Buclaw 2024-04-02 00:02:32 +02:00 committed by GitHub
commit d1cb5ca585
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 52 additions and 48 deletions

View file

@ -1,24 +0,0 @@
`isForwardRange`, `isBidirectionalRange`, and `isRandomAccessRange` now take an optional element type
In Phobos 2.106, an optional second template parameter was added to
`isInputRange` to enable conveniently checking a range's element type. Now, the
same parameter has been added to `isForwardRange`, `isBidirectionalRange`, and
`isRandomAccessRange`.
As before, if a second type argument is passed to one of these templates, the
range's element type is checked to see if it is
$(DDSUBLINK spec/const3, implicit_qualifier_conversions, qualifier-convertible)
to the given type, and this additional check must pass in order for the
template to evaluate to `true`.
Examples:
---
// exact match
static assert( isForwardRange!(int[], int));
// match with qualifier conversion
static assert( isBidirectionalRange!(int[], const(int));
// not a match
static assert(!isRandomAccessRange!(int[], string));
---

View file

@ -1,20 +0,0 @@
std.uni has been upgraded from Unicode 15.0.0 to 15.1.0
This Unicode update was released September 12, 2023.
See: https://www.unicode.org/versions/Unicode15.1.0/
```
import std;
void main()
{
const alphaCount = iota(0, dchar.max).filter!(std.uni.isAlpha).walkLength;
writeln(alphaCount);
// formerly: 137765
// now: 138387
// 622 new dchars return true for `isAlpha`
}
```
The internal unicode tables (std/internal/unicode_tables.d) have also been changed to use hex strings instead of array literals, which makes them faster to import.
The exact speed up depends on your computer and D compiler, but it likely cuts between 30 and 100 milliseconds if you compile something which imports `std.string` or `std.uni`.

View file

@ -647,7 +647,7 @@ fronting the GC allocator.
import std.experimental.allocator.gc_allocator : GCAllocator;
import std.typecons : Ternary;
// KRRegion fronting a general-purpose allocator
ubyte[1024 * 128] buf;
align(KRRegion!().alignment) ubyte[1024 * 128] buf;
auto alloc = fallbackAllocator(KRRegion!()(buf), GCAllocator.instance);
auto b = alloc.allocate(100);
assert(b.length == 100);
@ -916,7 +916,7 @@ version (StdUnittest)
@system unittest
{ import std.typecons : Ternary;
ubyte[1024] b;
align(KRRegion!().alignment) ubyte[1024] b;
auto alloc = KRRegion!()(b);
auto k = alloc.allocate(128);

View file

@ -2422,6 +2422,7 @@ struct HTTP
import std.algorithm.searching : findSplit, startsWith;
import std.string : indexOf, chomp;
import std.uni : toLower;
import std.exception : assumeUnique;
// Wrap incoming callback in order to separate http status line from
// http headers. On redirected requests there may be several such
@ -2448,7 +2449,9 @@ struct HTTP
}
auto m = header.findSplit(": ");
auto fieldName = m[0].toLower();
const(char)[] lowerFieldName = m[0].toLower();
///Fixes https://issues.dlang.org/show_bug.cgi?id=24458
string fieldName = lowerFieldName is m[0] ? lowerFieldName.idup : assumeUnique(lowerFieldName);
auto fieldContent = m[2].chomp;
if (fieldName == "content-type")
{

View file

@ -559,6 +559,14 @@ private template isBuildableFrom(U)
enum isBuildableFrom(T) = isBuildable!(T, U);
}
private enum hasCopyCtor(T) = __traits(hasCopyConstructor, T);
// T is expected to be an instantiation of Tuple.
private template noMemberHasCopyCtor(T)
{
import std.meta : anySatisfy;
enum noMemberHasCopyCtor = !anySatisfy!(hasCopyCtor, T.Types);
}
/**
_Tuple of values, for example $(D Tuple!(int, string)) is a record that
@ -745,7 +753,8 @@ if (distinctFieldNames!(Specs))
* compatible with the target `Tuple`'s type.
*/
this(U)(U another)
if (areBuildCompatibleTuples!(typeof(this), U))
if (areBuildCompatibleTuples!(typeof(this), U) &&
(noMemberHasCopyCtor!(typeof(this)) || !is(Unqual!U == Unqual!(typeof(this)))))
{
field[] = another.field[];
}
@ -1655,6 +1664,42 @@ if (distinctFieldNames!(Specs))
Tuple!(MyStruct) t;
}
// https://issues.dlang.org/show_bug.cgi?id=24465
@safe unittest
{
{
static struct S
{
this(ref return scope inout(S) rhs) scope @trusted inout pure nothrow {}
}
static void foo(Tuple!S)
{
}
Tuple!S t;
foo(t);
auto t2 = Tuple!S(t);
}
{
static struct S {}
Tuple!S t;
auto t2 = Tuple!S(t);
// This can't be done if Tuple has a copy constructor, because it's not
// allowed to have an rvalue constructor at that point, and the
// compiler doesn't to something intelligent like transform it into a
// move instead. However, it has been legal with Tuple for a while
// (maybe even since it was first added) when the type doesn't have a
// copy constructor, so this is testing to make sure that the fix to
// make copy constructors work doesn't mess up the rvalue constructor
// when none of the Tuple's members have copy constructors.
auto t3 = Tuple!S(Tuple!S.init);
}
}
/**
Creates a copy of a $(LREF Tuple) with its fields in _reverse order.