Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 309fdb1

Browse files
dkorpeldlang-bot
authored andcommitted
annotate pure functions with return/scope
1 parent d72a0d0 commit 309fdb1

18 files changed

Lines changed: 67 additions & 67 deletions

File tree

src/core/atomic.d

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ enum MemoryOrder
6666
* Returns:
6767
* The value of 'val'.
6868
*/
69-
T atomicLoad(MemoryOrder ms = MemoryOrder.seq, T)(ref const T val) pure nothrow @nogc @trusted
69+
T atomicLoad(MemoryOrder ms = MemoryOrder.seq, T)(return ref const T val) pure nothrow @nogc @trusted
7070
if (!is(T == shared U, U) && !is(T == shared inout U, U) && !is(T == shared const U, U))
7171
{
7272
static if (__traits(isFloating, T))
@@ -80,7 +80,7 @@ T atomicLoad(MemoryOrder ms = MemoryOrder.seq, T)(ref const T val) pure nothrow
8080
}
8181

8282
/// Ditto
83-
T atomicLoad(MemoryOrder ms = MemoryOrder.seq, T)(ref shared const T val) pure nothrow @nogc @trusted
83+
T atomicLoad(MemoryOrder ms = MemoryOrder.seq, T)(return ref shared const T val) pure nothrow @nogc @trusted
8484
if (!hasUnsharedIndirections!T)
8585
{
8686
import core.internal.traits : hasUnsharedIndirections;
@@ -162,7 +162,7 @@ void atomicStore(MemoryOrder ms = MemoryOrder.seq, T, V)(ref shared T val, share
162162
* Returns:
163163
* The value held previously by `val`.
164164
*/
165-
T atomicFetchAdd(MemoryOrder ms = MemoryOrder.seq, T)(ref T val, size_t mod) pure nothrow @nogc @trusted
165+
T atomicFetchAdd(MemoryOrder ms = MemoryOrder.seq, T)(return ref T val, size_t mod) pure nothrow @nogc @trusted
166166
if ((__traits(isIntegral, T) || is(T == U*, U)) && !is(T == shared))
167167
in (atomicValueIsProperlyAligned(val))
168168
{
@@ -173,7 +173,7 @@ in (atomicValueIsProperlyAligned(val))
173173
}
174174

175175
/// Ditto
176-
T atomicFetchAdd(MemoryOrder ms = MemoryOrder.seq, T)(ref shared T val, size_t mod) pure nothrow @nogc @trusted
176+
T atomicFetchAdd(MemoryOrder ms = MemoryOrder.seq, T)(return ref shared T val, size_t mod) pure nothrow @nogc @trusted
177177
if (__traits(isIntegral, T) || is(T == U*, U))
178178
in (atomicValueIsProperlyAligned(val))
179179
{
@@ -191,7 +191,7 @@ in (atomicValueIsProperlyAligned(val))
191191
* Returns:
192192
* The value held previously by `val`.
193193
*/
194-
T atomicFetchSub(MemoryOrder ms = MemoryOrder.seq, T)(ref T val, size_t mod) pure nothrow @nogc @trusted
194+
T atomicFetchSub(MemoryOrder ms = MemoryOrder.seq, T)(return ref T val, size_t mod) pure nothrow @nogc @trusted
195195
if ((__traits(isIntegral, T) || is(T == U*, U)) && !is(T == shared))
196196
in (atomicValueIsProperlyAligned(val))
197197
{
@@ -202,7 +202,7 @@ in (atomicValueIsProperlyAligned(val))
202202
}
203203

204204
/// Ditto
205-
T atomicFetchSub(MemoryOrder ms = MemoryOrder.seq, T)(ref shared T val, size_t mod) pure nothrow @nogc @trusted
205+
T atomicFetchSub(MemoryOrder ms = MemoryOrder.seq, T)(return ref shared T val, size_t mod) pure nothrow @nogc @trusted
206206
if (__traits(isIntegral, T) || is(T == U*, U))
207207
in (atomicValueIsProperlyAligned(val))
208208
{

src/core/demangle.d

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,7 @@ pure @safe:
20362036
* The demangled name or the original string if the name is not a mangled D
20372037
* name.
20382038
*/
2039-
char[] demangle( const(char)[] buf, char[] dst = null ) nothrow pure @safe
2039+
char[] demangle(return scope const(char)[] buf, return scope char[] dst = null ) nothrow pure @safe
20402040
{
20412041
auto d = Demangle!()(buf, dst);
20422042
// fast path (avoiding throwing & catching exception) for obvious
@@ -2075,7 +2075,7 @@ char[] demangleType( const(char)[] buf, char[] dst = null ) nothrow pure @safe
20752075
* Returns:
20762076
* The mangled name with deduplicated identifiers
20772077
*/
2078-
char[] reencodeMangled(const(char)[] mangled) nothrow pure @safe
2078+
char[] reencodeMangled(return scope const(char)[] mangled) nothrow pure @safe
20792079
{
20802080
static struct PrependHooks
20812081
{
@@ -2247,7 +2247,7 @@ char[] reencodeMangled(const(char)[] mangled) nothrow pure @safe
22472247
* The mangled name for a symbols of type T and the given fully
22482248
* qualified name.
22492249
*/
2250-
char[] mangle(T)(const(char)[] fqn, char[] dst = null) @safe pure nothrow
2250+
char[] mangle(T)(return scope const(char)[] fqn, return scope char[] dst = null) @safe pure nothrow
22512251
{
22522252
import core.internal.string : numDigits, unsignedToTempString;
22532253

@@ -2264,13 +2264,13 @@ char[] mangle(T)(const(char)[] fqn, char[] dst = null) @safe pure nothrow
22642264
return i == -1 ? s[0 .. $] : s[0 .. i];
22652265
}
22662266

2267-
void popFront()
2267+
void popFront() scope
22682268
{
22692269
immutable i = indexOfDot();
22702270
s = i == -1 ? s[$ .. $] : s[i+1 .. $];
22712271
}
22722272

2273-
private ptrdiff_t indexOfDot() const
2273+
private ptrdiff_t indexOfDot() const scope
22742274
{
22752275
foreach (i, c; s) if (c == '.') return i;
22762276
return -1;
@@ -2337,7 +2337,7 @@ char[] mangle(T)(const(char)[] fqn, char[] dst = null) @safe pure nothrow
23372337
* The mangled name for a function with function pointer type T and
23382338
* the given fully qualified name.
23392339
*/
2340-
char[] mangleFunc(T:FT*, FT)(const(char)[] fqn, char[] dst = null) @safe pure nothrow if (is(FT == function))
2340+
char[] mangleFunc(T:FT*, FT)(return scope const(char)[] fqn, return scope char[] dst = null) @safe pure nothrow if (is(FT == function))
23412341
{
23422342
static if (isExternD!FT)
23432343
{
@@ -2601,7 +2601,7 @@ unittest
26012601
{
26022602
char[] buf = new char[i];
26032603
auto ds = demangle(s, buf);
2604-
assert(ds == "pure nothrow @safe char[] core.demangle.demangle(const(char)[], char[])");
2604+
assert(ds == "pure nothrow @safe char[] core.demangle.demangle(scope return const(char)[], scope return char[])");
26052605
}
26062606
}
26072607

src/core/gc/gcinterface.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ interface GC
8686
/*
8787
*
8888
*/
89-
BlkInfo qalloc(size_t size, uint bits, const TypeInfo ti) nothrow;
89+
BlkInfo qalloc(size_t size, uint bits, const scope TypeInfo ti) nothrow;
9090

9191
/*
9292
*

src/core/internal/array/appending.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
module core.internal.array.appending;
1111

1212
/// See $(REF _d_arrayappendcTX, rt,lifetime,_d_arrayappendcTX)
13-
private extern (C) byte[] _d_arrayappendcTX(const TypeInfo ti, ref byte[] px, size_t n) @trusted pure nothrow;
13+
private extern (C) byte[] _d_arrayappendcTX(const TypeInfo ti, ref return scope byte[] px, size_t n) @trusted pure nothrow;
1414

1515
private enum isCopyingNothrow(T) = __traits(compiles, (ref T rhs) nothrow { T lhs = rhs; });
1616

src/core/internal/array/casting.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Params:
7272
Returns:
7373
`from` reinterpreted as `TTo[]`
7474
*/
75-
TTo[] __ArrayCast(TFrom, TTo)(TFrom[] from) @nogc pure @trusted
75+
TTo[] __ArrayCast(TFrom, TTo)(return scope TFrom[] from) @nogc pure @trusted
7676
{
7777
const fromSize = from.length * TFrom.sizeof;
7878
const toLength = fromSize / TTo.sizeof;

src/core/internal/array/concatenation.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
module core.internal.array.concatenation;
1010

1111
/// See $(REF _d_arraycatnTX, rt,lifetime)
12-
private extern (C) void[] _d_arraycatnTX(const TypeInfo ti, byte[][] arrs) pure nothrow;
12+
private extern (C) void[] _d_arraycatnTX(const TypeInfo ti, scope byte[][] arrs) pure nothrow;
1313

1414
/// Implementation of `_d_arraycatnTX` and `_d_arraycatnTXTrace`
1515
template _d_arraycatnTXImpl(Tarr : ResultArrT[], ResultArrT : T[], T)

src/core/internal/convert.d

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private ubyte[] ctfe_alloc(size_t n)
3333
}
3434

3535
@trusted pure nothrow @nogc
36-
const(ubyte)[] toUbyte(T)(const ref T val) if (__traits(isFloating, T) && (is(T : real) || is(T : ireal)))
36+
const(ubyte)[] toUbyte(T)(const scope ref T val) if (__traits(isFloating, T) && (is(T : real) || is(T : ireal)))
3737
{
3838
if (__ctfe)
3939
{
@@ -645,13 +645,13 @@ package template floatSize(T) if (is(T:real) || is(T:ireal))
645645

646646
// all toUbyte functions must be evaluable at compile time
647647
@trusted pure nothrow @nogc
648-
const(ubyte)[] toUbyte(T)(const T[] arr) if (T.sizeof == 1)
648+
const(ubyte)[] toUbyte(T)(return scope const T[] arr) if (T.sizeof == 1)
649649
{
650650
return cast(const(ubyte)[])arr;
651651
}
652652

653653
@trusted pure nothrow @nogc
654-
const(ubyte)[] toUbyte(T)(const T[] arr) if (T.sizeof > 1)
654+
const(ubyte)[] toUbyte(T)(return scope const T[] arr) if (T.sizeof > 1)
655655
{
656656
if (__ctfe)
657657
{
@@ -683,7 +683,7 @@ const(ubyte)[] toUbyte(T)(const T[] arr) if (T.sizeof > 1)
683683
}
684684

685685
@trusted pure nothrow @nogc
686-
const(ubyte)[] toUbyte(T)(const ref T val) if (__traits(isIntegral, T) && !is(T == enum) && !is(T == __vector))
686+
const(ubyte)[] toUbyte(T)(const ref scope T val) if (__traits(isIntegral, T) && !is(T == enum) && !is(T == __vector))
687687
{
688688
static if (T.sizeof == 1)
689689
{
@@ -720,7 +720,7 @@ const(ubyte)[] toUbyte(T)(const ref T val) if (__traits(isIntegral, T) && !is(T
720720
}
721721

722722
@trusted pure nothrow @nogc
723-
const(ubyte)[] toUbyte(T)(const ref T val) if (is(T == __vector))
723+
const(ubyte)[] toUbyte(T)(const ref scope T val) if (is(T == __vector))
724724
{
725725
if (!__ctfe)
726726
return (cast(const ubyte*) &val)[0 .. T.sizeof];
@@ -744,7 +744,7 @@ const(ubyte)[] toUbyte(T)(const ref T val) if (is(T == __vector))
744744
// @@@DEPRECATED_2022-02@@@
745745
deprecated
746746
@trusted pure nothrow @nogc
747-
const(ubyte)[] toUbyte(T)(const ref T val) if (__traits(isFloating, T) && is(T : creal))
747+
const(ubyte)[] toUbyte(T)(const ref return scope T val) if (__traits(isFloating, T) && is(T : creal))
748748
{
749749
if (__ctfe)
750750
{
@@ -764,7 +764,7 @@ const(ubyte)[] toUbyte(T)(const ref T val) if (__traits(isFloating, T) && is(T :
764764
}
765765

766766
@trusted pure nothrow @nogc
767-
const(ubyte)[] toUbyte(T)(const ref T val) if (is(T == enum))
767+
const(ubyte)[] toUbyte(T)(const ref return scope T val) if (is(T == enum))
768768
{
769769
if (__ctfe)
770770
{

src/core/internal/gc/impl/conservative/gc.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ class ConservativeGC : GC
398398
}
399399

400400

401-
BlkInfo qalloc( size_t size, uint bits, const TypeInfo ti) nothrow
401+
BlkInfo qalloc( size_t size, uint bits, const scope TypeInfo ti) nothrow
402402
{
403403

404404
if (!size)

src/core/internal/gc/impl/manual/gc.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class ManualGC : GC
111111
return p;
112112
}
113113

114-
BlkInfo qalloc(size_t size, uint bits, const TypeInfo ti) nothrow
114+
BlkInfo qalloc(size_t size, uint bits, const scope TypeInfo ti) nothrow
115115
{
116116
BlkInfo retval;
117117
retval.base = malloc(size, bits, ti);

src/core/internal/gc/impl/proto/gc.d

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ private
1818
extern (C) void gc_enable() nothrow;
1919
extern (C) void gc_disable() nothrow;
2020

21-
extern (C) void* gc_malloc( size_t sz, uint ba = 0, const TypeInfo = null ) pure nothrow;
22-
extern (C) void* gc_calloc( size_t sz, uint ba = 0, const TypeInfo = null ) pure nothrow;
23-
extern (C) BlkInfo gc_qalloc( size_t sz, uint ba = 0, const TypeInfo = null ) pure nothrow;
24-
extern (C) void* gc_realloc( void* p, size_t sz, uint ba = 0, const TypeInfo = null ) pure nothrow;
21+
extern (C) void* gc_malloc( size_t sz, uint ba = 0, const scope TypeInfo = null ) pure nothrow;
22+
extern (C) void* gc_calloc( size_t sz, uint ba = 0, const scope TypeInfo = null ) pure nothrow;
23+
extern (C) BlkInfo gc_qalloc( size_t sz, uint ba = 0, const scope TypeInfo = null ) pure nothrow;
24+
extern (C) void* gc_realloc(return scope void* p, size_t sz, uint ba = 0, const scope TypeInfo = null ) pure nothrow;
2525
extern (C) size_t gc_reserve( size_t sz ) nothrow;
2626

27-
extern (C) void gc_addRange(const void* p, size_t sz, const TypeInfo ti = null ) nothrow @nogc;
27+
extern (C) void gc_addRange(const void* p, size_t sz, const scope TypeInfo ti = null ) nothrow @nogc;
2828
extern (C) void gc_addRoot(const void* p ) nothrow @nogc;
2929
}
3030

@@ -99,31 +99,31 @@ class ProtoGC : GC
9999
return 0;
100100
}
101101

102-
void* malloc(size_t size, uint bits, const TypeInfo ti) nothrow
102+
void* malloc(size_t size, uint bits, const scope TypeInfo ti) nothrow
103103
{
104104
.gc_init_nothrow();
105105
return .gc_malloc(size, bits, ti);
106106
}
107107

108-
BlkInfo qalloc(size_t size, uint bits, const TypeInfo ti) nothrow
108+
BlkInfo qalloc(size_t size, uint bits, const scope TypeInfo ti) nothrow
109109
{
110110
.gc_init_nothrow();
111111
return .gc_qalloc(size, bits, ti);
112112
}
113113

114-
void* calloc(size_t size, uint bits, const TypeInfo ti) nothrow
114+
void* calloc(size_t size, uint bits, const scope TypeInfo ti) nothrow
115115
{
116116
.gc_init_nothrow();
117117
return .gc_calloc(size, bits, ti);
118118
}
119119

120-
void* realloc(void* p, size_t size, uint bits, const TypeInfo ti) nothrow
120+
void* realloc(void* p, size_t size, uint bits, const scope TypeInfo ti) nothrow
121121
{
122122
.gc_init_nothrow();
123123
return .gc_realloc(p, size, bits, ti);
124124
}
125125

126-
size_t extend(void* p, size_t minsize, size_t maxsize, const TypeInfo ti) nothrow
126+
size_t extend(void* p, size_t minsize, size_t maxsize, const scope TypeInfo ti) nothrow
127127
{
128128
return 0;
129129
}

0 commit comments

Comments
 (0)