-
-
Notifications
You must be signed in to change notification settings - Fork 763
std.uni struct Grapheme mem fun signatures: Replace some @trusted by @safe;... #6104
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7395,7 +7395,7 @@ if (isInputRange!Range && is(Unqual!(ElementType!Range) == dchar)) | |
|
|
||
| See_Also: $(LREF decodeGrapheme), $(LREF graphemeStride) | ||
| +/ | ||
| @trusted struct Grapheme | ||
| @safe struct Grapheme | ||
| { | ||
| import std.exception : enforce; | ||
| import std.traits : isDynamicArray; | ||
|
|
@@ -7417,7 +7417,7 @@ public: | |
| } | ||
|
|
||
| /// Gets a $(CODEPOINT) at the given index in this cluster. | ||
| dchar opIndex(size_t index) const pure nothrow @nogc | ||
| dchar opIndex(size_t index) const pure nothrow @nogc @trusted | ||
| { | ||
| assert(index < length); | ||
| return read24(isBig ? ptr_ : small_.ptr, index); | ||
|
|
@@ -7430,7 +7430,7 @@ public: | |
| Use of this facility may invalidate grapheme cluster, | ||
| see also $(LREF Grapheme.valid). | ||
| +/ | ||
| void opIndexAssign(dchar ch, size_t index) pure nothrow @nogc | ||
| void opIndexAssign(dchar ch, size_t index) pure nothrow @nogc @trusted | ||
| { | ||
| assert(index < length); | ||
| write24(isBig ? ptr_ : small_.ptr, ch, index); | ||
|
|
@@ -7453,13 +7453,13 @@ public: | |
| Warning: Invalidates when this Grapheme leaves the scope, | ||
| attempts to use it then would lead to memory corruption. | ||
| +/ | ||
| SliceOverIndexed!Grapheme opSlice(size_t a, size_t b) pure nothrow @nogc | ||
| SliceOverIndexed!Grapheme opSlice(size_t a, size_t b) pure nothrow @nogc return | ||
| { | ||
| return sliceOverIndexed(a, b, &this); | ||
| } | ||
|
|
||
| /// ditto | ||
| SliceOverIndexed!Grapheme opSlice() pure nothrow @nogc | ||
| SliceOverIndexed!Grapheme opSlice() pure nothrow @nogc return | ||
| { | ||
| return sliceOverIndexed(0, length, &this); | ||
| } | ||
|
|
@@ -7478,7 +7478,7 @@ public: | |
|
|
||
| See_Also: $(LREF Grapheme.valid) | ||
| +/ | ||
| ref opOpAssign(string op)(dchar ch) | ||
| ref opOpAssign(string op)(dchar ch) @trusted | ||
| { | ||
| static if (op == "~") | ||
| { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
@@ -7560,7 +7560,7 @@ public: | |
| return r.length == 0; | ||
| } | ||
|
|
||
| this(this) pure @nogc nothrow | ||
| this(this) pure @nogc nothrow @trusted | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should use stdx.allocator.makeArray - it's import std.experimental.allocator.mallocator : Mallocator;
import std.experimental.allocator : makeArray;
auto p = Mallocator.instance.makeArray!ubyte(20);
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't use it here because it's not
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use PR #6041 instead (this PR is included there and should be closed but isn't yet).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| { | ||
| import core.exception : onOutOfMemoryError; | ||
| import core.memory : pureMalloc; | ||
|
|
@@ -7578,7 +7578,7 @@ public: | |
| } | ||
| } | ||
|
|
||
| ~this() pure @nogc nothrow | ||
| ~this() pure @nogc nothrow @trusted | ||
| { | ||
| import core.memory : pureFree; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Go with import std.experimental.allocator.mallocator : Mallocator;
import std.experimental.allocator : makeArray, dispose;
alias alloc = Mallocator.instance;
auto p = alloc.makeArray!ubyte(20);
alloc.dispose(p);https://run.dlang.io/is/t2IMq2 but it needs to be fixed first (https://issues.dlang.org/show_bug.cgi?id=18347) |
||
| if (isBig) | ||
|
|
@@ -7612,7 +7612,7 @@ private: | |
| } | ||
| } | ||
|
|
||
| void convertToBig() pure @nogc nothrow | ||
| void convertToBig() pure @nogc nothrow @trusted | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. stdx.allocator to the help!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| { | ||
| import core.exception : onOutOfMemoryError; | ||
| import core.memory : pureMalloc; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it doesn't help here, are you aware of https://dlang.org/changelog/pending.html#ptr-safe-end-of-deprecation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep!