Skip to content

Commit cd73892

Browse files
dkorpeldlang-bot
authored andcommitted
Add explicit return to inout functions
1 parent c0a8bd6 commit cd73892

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

std/file.d

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ version (Windows) private ulong makeUlong(DWORD dwLow, DWORD dwHigh) @safe pure
11241124
}
11251125

11261126
version (Posix) private extern (C) pragma(mangle, stat.mangleof)
1127-
int trustedStat(const(FSChar)* namez, ref stat_t buf) @nogc nothrow @trusted;
1127+
int trustedStat(scope const(FSChar)* namez, ref stat_t buf) @nogc nothrow @trusted;
11281128

11291129
/**
11301130
Get size of file `name` in bytes.
@@ -1928,7 +1928,7 @@ if (isConvertibleToString!R)
19281928
assert(!f.exists);
19291929
}
19301930

1931-
private bool existsImpl(const(FSChar)* namez) @trusted nothrow @nogc
1931+
private bool existsImpl(scope const(FSChar)* namez) @trusted nothrow @nogc
19321932
{
19331933
version (Windows)
19341934
{
@@ -2010,7 +2010,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) &&
20102010
version (Windows)
20112011
{
20122012
auto namez = name.tempCString!FSChar();
2013-
static auto trustedGetFileAttributesW(const(FSChar)* namez) @trusted
2013+
static auto trustedGetFileAttributesW(scope const(FSChar)* namez) @trusted
20142014
{
20152015
return GetFileAttributesW(namez);
20162016
}
@@ -2220,7 +2220,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) &&
22202220
version (Windows)
22212221
{
22222222
auto namez = name.tempCString!FSChar();
2223-
static auto trustedSetFileAttributesW(const(FSChar)* namez, uint dwFileAttributes) @trusted
2223+
static auto trustedSetFileAttributesW(scope const(FSChar)* namez, uint dwFileAttributes) @trusted
22242224
{
22252225
return SetFileAttributesW(namez, dwFileAttributes);
22262226
}
@@ -2233,7 +2233,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) &&
22332233
else version (Posix)
22342234
{
22352235
auto namez = name.tempCString!FSChar();
2236-
static auto trustedChmod(const(FSChar)* namez, mode_t mode) @trusted
2236+
static auto trustedChmod(scope const(FSChar)* namez, mode_t mode) @trusted
22372237
{
22382238
return chmod(namez, mode);
22392239
}
@@ -2868,14 +2868,14 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) &&
28682868

28692869
version (Windows)
28702870
{
2871-
static auto trustedChdir(const(FSChar)* pathz) @trusted
2871+
static auto trustedChdir(scope const(FSChar)* pathz) @trusted
28722872
{
28732873
return SetCurrentDirectoryW(pathz);
28742874
}
28752875
}
28762876
else version (Posix)
28772877
{
2878-
static auto trustedChdir(const(FSChar)* pathz) @trusted
2878+
static auto trustedChdir(scope const(FSChar)* pathz) @trusted
28792879
{
28802880
return core.sys.posix.unistd.chdir(pathz) == 0;
28812881
}
@@ -2939,7 +2939,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) &&
29392939

29402940
version (Windows)
29412941
{
2942-
static auto trustedCreateDirectoryW(const(FSChar)* pathz) @trusted
2942+
static auto trustedCreateDirectoryW(scope const(FSChar)* pathz) @trusted
29432943
{
29442944
return CreateDirectoryW(pathz, null);
29452945
}
@@ -2953,7 +2953,7 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) &&
29532953
{
29542954
import std.conv : octal;
29552955

2956-
static auto trustedMkdir(const(FSChar)* pathz, mode_t mode) @trusted
2956+
static auto trustedMkdir(scope const(FSChar)* pathz, mode_t mode) @trusted
29572957
{
29582958
return core.sys.posix.sys.stat.mkdir(pathz, mode);
29592959
}
@@ -3143,14 +3143,14 @@ if (isInputRange!R && !isInfinite!R && isSomeChar!(ElementEncodingType!R) &&
31433143

31443144
version (Windows)
31453145
{
3146-
static auto trustedRmdir(const(FSChar)* pathz) @trusted
3146+
static auto trustedRmdir(scope const(FSChar)* pathz) @trusted
31473147
{
31483148
return RemoveDirectoryW(pathz);
31493149
}
31503150
}
31513151
else version (Posix)
31523152
{
3153-
static auto trustedRmdir(const(FSChar)* pathz) @trusted
3153+
static auto trustedRmdir(scope const(FSChar)* pathz) @trusted
31543154
{
31553155
return core.sys.posix.unistd.rmdir(pathz) == 0;
31563156
}

std/internal/cstring.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ private struct TempCStringBuffer(To = char)
227227
@disable this(this);
228228
alias ptr this; /// implicitly covert to raw pointer
229229

230-
@property inout(To)* buffPtr() inout
230+
@property inout(To)* buffPtr() return inout
231231
{
232232
return _ptr == useStack ? _buff.ptr : _ptr;
233233
}

std/json.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ struct JSONValue
321321
(*a)[0] = "world"; // segmentation fault
322322
---
323323
*/
324-
@property ref inout(JSONValue[]) array() inout pure @system
324+
@property ref inout(JSONValue[]) array() return scope inout pure @system
325325
{
326326
enforce!JSONException(type == JSONType.array,
327327
"JSONValue is not an array");

std/process.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4385,6 +4385,7 @@ else version (Posix)
43854385

43864386
void browse(scope const(char)[] url) nothrow @nogc @safe
43874387
{
4388+
const buffer = url.tempCString(); // Retain buffer until end of scope
43884389
const(char)*[3] args;
43894390

43904391
// Trusted because it's called with a zero-terminated literal
@@ -4408,7 +4409,6 @@ else version (Posix)
44084409
}
44094410
}
44104411

4411-
const buffer = url.tempCString(); // Retain buffer until end of scope
44124412
args[1] = buffer;
44134413
args[2] = null;
44144414

std/stdio.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4650,7 +4650,7 @@ if ((isInputRange!R1 && isSomeChar!(ElementEncodingType!R1) || isSomeString!R1)
46504650
auto namez = name.tempCString!FSChar();
46514651
auto modez = mode.tempCString!FSChar();
46524652

4653-
static _fopenImpl(const(FSChar)* namez, const(FSChar)* modez) @trusted nothrow @nogc
4653+
static _fopenImpl(scope const(FSChar)* namez, scope const(FSChar)* modez) @trusted nothrow @nogc
46544654
{
46554655
version (Windows)
46564656
{

std/uni/package.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,8 +1987,8 @@ pure:
19871987
{
19881988
return this[0] == val[0] && this[1] == val[1];
19891989
}
1990-
@property ref inout(uint) a() inout { return _tuple[0]; }
1991-
@property ref inout(uint) b() inout { return _tuple[1]; }
1990+
@property ref inout(uint) a() return inout { return _tuple[0]; }
1991+
@property ref inout(uint) b() return inout { return _tuple[1]; }
19921992
}
19931993

19941994
/**

0 commit comments

Comments
 (0)