Skip to content

Commit 032d04d

Browse files
authored
Merge pull request #4956 from edi33416/fix_deprecations
Fix issue 16970 - Fix deprecations and warnings when compiling Phobos merged-on-behalf-of: Sebastian Wilzbach <sebi.wilzbach@gmail.com>
2 parents 085e41e + 3d98191 commit 032d04d

File tree

6 files changed

+34
-80
lines changed

6 files changed

+34
-80
lines changed

std/algorithm/iteration.d

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2654,7 +2654,6 @@ template reduce(fun...) if (fun.length >= 1)
26542654
If $(D r) is empty, an $(D Exception) is thrown.
26552655
26562656
Params:
2657-
fun = one or more functions
26582657
r = an iterable value as defined by $(D isIterable)
26592658
26602659
Returns:
@@ -2693,7 +2692,6 @@ template reduce(fun...) if (fun.length >= 1)
26932692
Use $(D fold) instead of $(D reduce) to use the seed version in a UFCS chain.
26942693
26952694
Params:
2696-
fun = one or more functions
26972695
seed = the initial value of the accumulator
26982696
r = an iterable value as defined by $(D isIterable)
26992697
@@ -3170,7 +3168,6 @@ if (fun.length >= 1)
31703168
Once `S` has been determined, then $(D S s = e;) and $(D s = f(s, e);) must
31713169
both be legal.
31723170
Params:
3173-
fun = one or more functions
31743171
range = an input range as defined by `isInputRange`
31753172
Returns:
31763173
a range containing the consecutive reduced values.
@@ -3189,7 +3186,6 @@ if (fun.length >= 1)
31893186
`cumulativeFold` will operate on an unqualified copy. If this happens
31903187
then the returned type will not perfectly match `S`.
31913188
Params:
3192-
fun = one or more functions
31933189
range = an input range as defined by `isInputRange`
31943190
seed = the initial value of the accumulator
31953191
Returns:

std/exception.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,8 +2143,8 @@ pure nothrow @safe unittest
21432143
Convenience mixin for trivially sub-classing exceptions
21442144
21452145
Even trivially sub-classing an exception involves writing boilerplate code
2146-
for the constructor to: 1) correctly pass in the source file and line number
2147-
the exception was thrown from; 2) be usable with $(LREF enforce) which
2146+
for the constructor to: 1$(RPAREN) correctly pass in the source file and line number
2147+
the exception was thrown from; 2$(RPAREN) be usable with $(LREF enforce) which
21482148
expects exception constructors to take arguments in a fixed order. This
21492149
mixin provides that boilerplate code.
21502150

std/range/package.d

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,18 +1853,27 @@ Lazily takes only up to `n` elements of a range. This is
18531853
particularly useful when using with infinite ranges.
18541854
18551855
Unlike $(LREF takeExactly), `take` does not require that there
1856-
are `n` or more elements in `r`. As a consequence, length
1857-
information is not applied to the result unless `r` also has
1856+
are `n` or more elements in `input`. As a consequence, length
1857+
information is not applied to the result unless `input` also has
18581858
length information.
18591859
18601860
Params:
1861-
r = an input range to iterate over up to `n` times
1861+
input = an input range to iterate over up to `n` times
18621862
n = the number of elements to take
18631863
18641864
Returns:
18651865
At minimum, an input range. If the range offers random access
18661866
and `length`, `take` offers them as well.
18671867
*/
1868+
Take!R take(R)(R input, size_t n)
1869+
if (isInputRange!(Unqual!R) && !isInfinite!(Unqual!R) && hasSlicing!(Unqual!R) &&
1870+
!is(R T == Take!T))
1871+
{
1872+
import std.algorithm.comparison : min;
1873+
return input[0 .. min(n, input.length)];
1874+
}
1875+
1876+
/// ditto
18681877
struct Take(Range)
18691878
if (isInputRange!(Unqual!Range) &&
18701879
//take _cannot_ test hasSlicing on infinite ranges, because hasSlicing uses
@@ -2054,17 +2063,6 @@ if (isInputRange!(Unqual!Range) &&
20542063
}
20552064
}
20562065

2057-
/// ditto
2058-
Take!R take(R)(R input, size_t n)
2059-
if (isInputRange!(Unqual!R) && !isInfinite!(Unqual!R) && hasSlicing!(Unqual!R) &&
2060-
!is(R T == Take!T))
2061-
{
2062-
// @@@BUG@@@
2063-
//return input[0 .. min(n, $)];
2064-
import std.algorithm.comparison : min;
2065-
return input[0 .. min(n, input.length)];
2066-
}
2067-
20682066
/**
20692067
This template simply aliases itself to R and is useful for consistency in
20702068
generic code.

std/socket.d

Lines changed: 18 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -629,48 +629,18 @@ private mixin template socketOSExceptionCtors()
629629

630630

631631
/**
632-
* Class for exceptions thrown from an $(D InternetHost).
632+
* Class for exceptions thrown from an `InternetHost`.
633633
*/
634634
class HostException: SocketOSException
635635
{
636636
mixin socketOSExceptionCtors;
637637
}
638638

639639
/**
640-
* $(D InternetHost) is a class for resolving IPv4 addresses.
640+
* `InternetHost` is a class for resolving IPv4 addresses.
641641
*
642-
* Consider using $(D getAddress), $(D parseAddress) and $(D Address) methods
642+
* Consider using `getAddress`, `parseAddress` and `Address` methods
643643
* instead of using this class directly.
644-
*
645-
* Example:
646-
* ---
647-
* auto ih = new InternetHost;
648-
*
649-
* // Forward lookup
650-
* writeln("About www.digitalmars.com:");
651-
* if (ih.getHostByName("www.digitalmars.com"))
652-
* {
653-
* writefln(" Name: %s", ih.name);
654-
* auto ip = InternetAddress.addrToString(ih.addrList[0]);
655-
* writefln(" IP address: %s", ip);
656-
* foreach (string s; ih.aliases)
657-
* writefln(" Alias: %s", s);
658-
* writeln("---");
659-
*
660-
* // Reverse lookup
661-
* writefln("About IP %s:", ip);
662-
* if (ih.getHostByAddr(ih.addrList[0]))
663-
* {
664-
* writefln(" Name: %s", ih.name);
665-
* foreach (string s; ih.aliases)
666-
* writefln(" Alias: %s", s);
667-
* }
668-
* else
669-
* writeln(" Reverse lookup failed");
670-
* }
671-
* else
672-
* writeln(" Can't resolve www.digitalmars.com");
673-
* ---
674644
*/
675645
class InternetHost
676646
{
@@ -824,7 +794,7 @@ class InternetHost
824794
}
825795
}
826796

827-
797+
///
828798
@safe unittest
829799
{
830800
InternetHost ih = new InternetHost;
@@ -834,29 +804,21 @@ class InternetHost
834804
ih.getHostByAddr("127.0.0.1");
835805
assert(ih.addrList[0] == 0x7F_00_00_01);
836806

837-
softUnittest({
838-
if (!ih.getHostByName("www.digitalmars.com"))
839-
return; // don't fail if not connected to internet
840-
//writefln("addrList.length = %d", ih.addrList.length);
841-
assert(ih.addrList.length);
842-
InternetAddress ia = new InternetAddress(ih.addrList[0], InternetAddress.PORT_ANY);
843-
assert(ih.name == "www.digitalmars.com" || ih.name == "digitalmars.com",
844-
ih.name);
845-
// writefln("IP address = %s", ia.toAddrString());
846-
// writefln("name = %s", ih.name);
847-
// foreach (int i, string s; ih.aliases)
848-
// {
849-
// writefln("aliases[%d] = %s", i, s);
850-
// }
851-
// writefln("---");
807+
if (!ih.getHostByName("www.digitalmars.com"))
808+
return; // don't fail if not connected to internet
852809

853-
//assert(ih.getHostByAddr(ih.addrList[0]));
854-
// writefln("name = %s", ih.name);
855-
// foreach (int i, string s; ih.aliases)
856-
// {
857-
// writefln("aliases[%d] = %s", i, s);
858-
// }
859-
});
810+
assert(ih.addrList.length);
811+
InternetAddress ia = new InternetAddress(ih.addrList[0], InternetAddress.PORT_ANY);
812+
assert(ih.name == "www.digitalmars.com" || ih.name == "digitalmars.com",
813+
ih.name);
814+
815+
assert(ih.getHostByAddr(ih.addrList[0]));
816+
string getHostNameFromInt = ih.name.dup;
817+
818+
assert(ih.getHostByAddr(ia.toAddrString()));
819+
string getHostNameFromStr = ih.name.dup;
820+
821+
assert(getHostNameFromInt == getHostNameFromStr);
860822
}
861823

862824

std/stdio.d

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2350,7 +2350,6 @@ $(REF readText, std,file)
23502350
Range primitives may throw $(D StdioException) on I/O error.
23512351
23522352
Params:
2353-
file = file handle to parse from
23542353
format = tuple record $(REF_ALTTEXT _format, formattedRead, std, _format)
23552354
23562355
Returns:

std/utf.d

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3527,13 +3527,12 @@ int impureVariable;
35273527
*
35283528
* Params:
35293529
* C = `char`, `wchar`, or `dchar`
3530-
* r = input range of characters, or array of characters
35313530
* Returns:
3532-
* A forward range if r is a range and not auto-decodable, as defined by
3531+
* A forward range if `R` is a range and not auto-decodable, as defined by
35333532
* $(REF isAutodecodableString, std, traits), and if the base range is
35343533
* also a forward range.
35353534
*
3536-
* Or, if r is a range and it is auto-decodable and
3535+
* Or, if `R` is a range and it is auto-decodable and
35373536
* `is(ElementEncodingType!typeof(r) == C)`, then the range is passed
35383537
* to $(LREF byCodeUnit).
35393538
*

0 commit comments

Comments
 (0)