Skip to content

Commit

Permalink
Fix a few scope related deprecation warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-ludwig committed Feb 10, 2024
1 parent c552198 commit b5cc51f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion http/vibe/http/common.d
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class HTTPResponse {
InetHeaderMap headers;

/// All cookies that shall be set on the client for this request
@property ref DictionaryList!Cookie cookies() { return m_cookies; }
@property scope ref DictionaryList!Cookie cookies() return { return m_cookies; }
}

scope:
Expand Down
2 changes: 1 addition & 1 deletion http/vibe/http/server.d
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,7 @@ scope:
logTrace("---------------------");

// write cookies
foreach (n, cookie; this.cookies.byKeyValue) {
foreach (n, cookie; () @trusted { return this.cookies.byKeyValue; } ()) {
dst.put("Set-Cookie: ");
cookie.writeString(() @trusted { return &dst; } (), n);
dst.put("\r\n");
Expand Down
12 changes: 6 additions & 6 deletions stream/vibe/stream/multicast.d
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ struct MulticastStream(OutputStreams...) {
if (m_tasks.length > 0) {
Exception ex;
foreach (i, T; OutputStreams[1 .. $])
m_tasks[i] = runTask({
try m_outputs[i+1].flush();
m_tasks[i] = runTask((MulticastStream _this) {
try _this.m_outputs[i+1].flush();
catch (Exception e) ex = e;
});
}, () @trusted { return this; } ());
m_outputs[0].flush();
foreach (t; m_tasks) t.join();
if (ex) throw ex;
Expand All @@ -95,10 +95,10 @@ struct MulticastStream(OutputStreams...) {
if (m_tasks.length > 0) {
Exception ex;
foreach (i, T; OutputStreams[1 .. $])
m_tasks[i] = runTask({
try m_outputs[i+1].write(bytes, mode);
m_tasks[i] = runTask((MulticastStream _this) {
try _this.m_outputs[i+1].write(bytes, mode);
catch (Exception e) ex = e;
});
}, () @trusted { return this; } ());
auto ret = m_outputs[0].write(bytes, mode);
foreach (t; m_tasks) t.join();
if (ex) throw ex;
Expand Down
2 changes: 1 addition & 1 deletion utils/vibe/utils/string.d
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ sizediff_t matchBracket(const(char)[] str, bool nested = true)
}

/// Same as std.string.format, just using an allocator.
string formatAlloc(ARGS...)(IAllocator alloc, string fmt, ARGS args)
string formatAlloc(ARGS...)(scope IAllocator alloc, string fmt, ARGS args)
{
auto app = AllocAppender!string(alloc);
formattedWrite(() @trusted { return &app; } (), fmt, args);
Expand Down
6 changes: 4 additions & 2 deletions web/vibe/web/common.d
Original file line number Diff line number Diff line change
Expand Up @@ -559,10 +559,12 @@ package void defaultSerialize (alias P, T, RT) (ref RT output_range, const scope
static struct R {
typeof(output_range) underlying;
void put(char ch) { underlying.put(ch); }
void put(const(char)[] ch) { underlying.put(cast(const(ubyte)[])ch); }
void put(scope const(char)[] ch) { underlying.put(cast(const(ubyte)[])ch); }
}
auto dst = R(output_range);
value.serializeWithPolicy!(JsonStringSerializer!R, P) (dst);
// NOTE: serializeWithPolicy does not take value as scope due to issues
// deeply buried in the standard library
() @trusted { return value; } ().serializeWithPolicy!(JsonStringSerializer!R, P) (dst);
}

package T defaultDeserialize (alias P, T, R) (R input_range)
Expand Down

0 comments on commit b5cc51f

Please sign in to comment.