Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a few scope related deprecation warnings #2778

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ref DictionaryList!Cookie cookies() return scope { 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((scope 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((scope 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
Loading