Skip to content
Merged
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
10 changes: 5 additions & 5 deletions std/digest/digest.d
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ interface Digest
*/
@trusted nothrow ubyte[] finish();
///ditto
nothrow ubyte[] finish(scope ubyte[] buf);
nothrow ubyte[] finish(ubyte[] buf);
//@@@BUG@@@ http://d.puremagic.com/issues/show_bug.cgi?id=6549
/*in
{
Expand All @@ -608,7 +608,7 @@ interface Digest
/**
* This is a convenience function to calculate the hash of a value using the OOP API.
*/
final @trusted nothrow ubyte[] digest(scope const(void[])[] data...)
final @trusted nothrow ubyte[] digest(const(void[])[] data...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one doesn't look wrong. It calls put on the individual void[]s. put's parameter is scope, so it guarantees not to escape the void[]. finish can't have a reference into data then which it could escape.

This hinges on put's scope being correct, I guess.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's wrong because the implementation is returning its argument. It's exactly the sort of thing scope does not allow.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's wrong because the implementation is returning its argument.

But it doesn't. It returns this.finish().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made a PR to revert this line as I think this was a mistake. #4552

{
this.reset();
foreach (datum; data)
Expand Down Expand Up @@ -909,7 +909,7 @@ class WrapperDigest(T) if (isDigest!T) : Digest
* //length
* --------
*/
nothrow ubyte[] finish(scope ubyte[] buf)
nothrow ubyte[] finish(ubyte[] buf)
in
{
assert(buf.length >= this.length);
Expand Down Expand Up @@ -939,13 +939,13 @@ class WrapperDigest(T) if (isDigest!T) : Digest
*
* These functions are only available if $(D hasPeek!T) is true.
*/
@trusted ubyte[] peek(scope ubyte[] buf) const;
@trusted ubyte[] peek(ubyte[] buf) const;
///ditto
@trusted ubyte[] peek() const;
}
else static if (hasPeek!T)
{
@trusted ubyte[] peek(scope ubyte[] buf) const
@trusted ubyte[] peek(ubyte[] buf) const
in
{
assert(buf.length >= this.length);
Expand Down