Skip to content

Commit 19fe0bf

Browse files
committed
Merge pull request #306 from monarchdodra/sliceNothrow
Slice nothrow
2 parents b2aebc0 + 92f92aa commit 19fe0bf

9 files changed

+23
-15
lines changed

src/rt/arrayassign.d

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extern (C) void[] _d_arrayassign(TypeInfo ti, void[] from, void[] to)
3636
char[10] tmp = void;
3737
string msg = "lengths don't match for array copy,"c;
3838
msg ~= tmp.intToString(to.length) ~ " = " ~ tmp.intToString(from.length);
39-
throw new Exception(msg);
39+
throw new Error(msg);
4040
}
4141

4242
auto element_size = ti.tsize();
@@ -92,7 +92,7 @@ extern (C) void[] _d_arrayctor(TypeInfo ti, void[] from, void[] to)
9292
char[10] tmp = void;
9393
string msg = "lengths don't match for array initialization,"c;
9494
msg ~= tmp.intToString(to.length) ~ " = " ~ tmp.intToString(from.length);
95-
throw new Exception(msg);
95+
throw new Error(msg);
9696
}
9797

9898
auto element_size = ti.tsize();

src/rt/arraybyte.d

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,15 @@ else
4040

4141
//version = log;
4242

43+
@trusted pure nothrow
4344
bool disjoint(T)(T[] a, T[] b)
4445
{
4546
return (a.ptr + a.length <= b.ptr || b.ptr + b.length <= a.ptr);
4647
}
4748

4849
alias byte T;
4950

50-
extern (C):
51+
extern (C) @trusted nothrow:
5152

5253
/* ======================================================================== */
5354

src/rt/arraycast.d

+6-4
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,20 @@ module rt.arraycast;
1717
* Runtime helper to convert dynamic array of one
1818
* type to dynamic array of another.
1919
* Adjusts the length of the array.
20-
* Throws exception if new length is not aligned.
20+
* Throws an error if new length is not aligned.
2121
*/
2222

2323
extern (C)
2424

25+
@trusted nothrow
2526
void[] _d_arraycast(size_t tsize, size_t fsize, void[] a)
2627
{
2728
auto length = a.length;
2829

2930
auto nbytes = length * fsize;
3031
if (nbytes % tsize != 0)
3132
{
32-
throw new Exception("array cast misalignment");
33+
throw new Error("array cast misalignment");
3334
}
3435
length = nbytes / tsize;
3536
*cast(size_t *)&a = length; // jam new length
@@ -56,20 +57,21 @@ unittest
5657
* Runtime helper to convert dynamic array of bits
5758
* dynamic array of another.
5859
* Adjusts the length of the array.
59-
* Throws exception if new length is not aligned.
60+
* Throws an error if new length is not aligned.
6061
*/
6162

6263
version (none)
6364
{
6465
extern (C)
6566

67+
@trusted nothrow
6668
void[] _d_arraycast_frombit(uint tsize, void[] a)
6769
{
6870
uint length = a.length;
6971

7072
if (length & 7)
7173
{
72-
throw new Exception("bit[] array cast misalignment");
74+
throw new Error("bit[] array cast misalignment");
7375
}
7476
length /= 8 * tsize;
7577
*cast(size_t *)&a = length; // jam new length

src/rt/arraycat.d

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private
1919
debug import core.stdc.stdio;
2020
}
2121

22-
extern (C):
22+
extern (C) @trusted nothrow:
2323

2424
byte[] _d_arraycopy(size_t size, byte[] from, byte[] to)
2525
{
@@ -28,7 +28,7 @@ byte[] _d_arraycopy(size_t size, byte[] from, byte[] to)
2828

2929
if (to.length != from.length)
3030
{
31-
throw new Exception("lengths don't match for array copy");
31+
throw new Error("lengths don't match for array copy");
3232
}
3333
else if (to.ptr + to.length * size <= from.ptr ||
3434
from.ptr + from.length * size <= to.ptr)
@@ -37,7 +37,7 @@ byte[] _d_arraycopy(size_t size, byte[] from, byte[] to)
3737
}
3838
else
3939
{
40-
throw new Exception("overlapping array copy");
40+
throw new Error("overlapping array copy");
4141
}
4242
return to;
4343
}

src/rt/arraydouble.d

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ else
3939

4040
//version = log;
4141

42+
@trusted pure nothrow
4243
bool disjoint(T)(T[] a, T[] b)
4344
{
4445
return (a.ptr + a.length <= b.ptr || b.ptr + b.length <= a.ptr);
@@ -49,7 +50,7 @@ bool disjoint(T)(T[] a, T[] b)
4950

5051
alias double T;
5152

52-
extern (C):
53+
extern (C) @trusted nothrow:
5354

5455
/* ======================================================================== */
5556

src/rt/arrayfloat.d

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ else
3939

4040
//version = log;
4141

42+
@trusted pure nothrow
4243
bool disjoint(T)(T[] a, T[] b)
4344
{
4445
return (a.ptr + a.length <= b.ptr || b.ptr + b.length <= a.ptr);
4546
}
4647

4748
alias float T;
4849

49-
extern (C):
50+
extern (C) @trusted nothrow:
5051

5152
/* ======================================================================== */
5253
/* ======================================================================== */

src/rt/arrayint.d

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,15 @@ else
4040

4141
//version = log;
4242

43+
@trusted pure nothrow
4344
bool disjoint(T)(T[] a, T[] b)
4445
{
4546
return (a.ptr + a.length <= b.ptr || b.ptr + b.length <= a.ptr);
4647
}
4748

4849
alias int T;
4950

50-
extern (C):
51+
extern (C) @trusted nothrow:
5152

5253
/* ======================================================================== */
5354

src/rt/arrayreal.d

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ else
3939

4040
//version = log;
4141

42+
@trusted pure nothrow
4243
bool disjoint(T)(T[] a, T[] b)
4344
{
4445
return (a.ptr + a.length <= b.ptr || b.ptr + b.length <= a.ptr);
4546
}
4647

4748
alias real T;
4849

49-
extern (C):
50+
extern (C) @trusted nothrow:
5051

5152
/* ======================================================================== */
5253

src/rt/arrayshort.d

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,15 @@ else
4040

4141
//version = log;
4242

43+
@trusted pure nothrow
4344
bool disjoint(T)(T[] a, T[] b)
4445
{
4546
return (a.ptr + a.length <= b.ptr || b.ptr + b.length <= a.ptr);
4647
}
4748

4849
alias short T;
4950

50-
extern (C):
51+
extern (C) @trusted nothrow:
5152

5253
/* ======================================================================== */
5354

0 commit comments

Comments
 (0)