-
-
Notifications
You must be signed in to change notification settings - Fork 747
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
Conversation
|
Thanks for your pull request, @carblue! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Some tips to help speed things up:
Bear in mind that large or tricky changes may require multiple rounds of review and revision. Please see CONTRIBUTING.md for more information. Bugzilla references
|
wilzbach
left a comment
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.
I would suggest to cleanup the code to use stdx.allocator instead of slapping ugly @trusted over it.
| dchar opIndex(size_t index) const pure nothrow @nogc @trusted | ||
| { | ||
| assert(index < length); | ||
| return read24(isBig ? ptr_ : small_.ptr, index); |
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!
| ref opOpAssign(string op)(dchar ch) @trusted | ||
| { | ||
| static if (op == "~") | ||
| { |
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.
| } | ||
|
|
||
| this(this) pure @nogc nothrow | ||
| this(this) pure @nogc nothrow @trusted |
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.
This should use stdx.allocator.makeArray - it's @safe
import std.experimental.allocator.mallocator : Mallocator;
import std.experimental.allocator : makeArray;
auto p = Mallocator.instance.makeArray!ubyte(20);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.
Can't use it here because it's not pure.
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.
Use PR #6041 instead (this PR is included there and should be closed but isn't yet).
When I inject behind } on line 7579
pragma(msg, "std.uni.d:Grapheme.this(this):", LINE, " ", typeof(&Grapheme.__postblit));
the compiler emits: std.uni.d:Grapheme.this(this):7579 void function() pure nothrow @nogc @trusted
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.
pragma(msg, "std.uni.d:Grapheme.this(this):", __LINE__, " ", typeof(&Grapheme.__postblit));
| ~this() pure @nogc nothrow | ||
| ~this() pure @nogc nothrow @trusted | ||
| { | ||
| import core.memory : pureFree; |
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.
Go with dispose, instead:
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)
| } | ||
|
|
||
| void convertToBig() pure @nogc nothrow | ||
| void convertToBig() pure @nogc nothrow @trusted |
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.
stdx.allocator to the help!
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.
…preparation for -dip1000, issues #17961, #18110.
Changes apply to function signatures only and are trivial except referring to return attribute: Seems to be undocumented in DIP25/DIP1000, similar to https://dlang.org/spec/function.html#return-ref-parameters;
It's what template inference does for opSlice: "return attribute ensures the returned object will not outlive the Grapheme instance".
Without return, there are "-dip1000 errors" like this one: returning sliceOverIndexed(a, b, &this) escapes a reference to parameter this, perhaps annotate with return.