-
Notifications
You must be signed in to change notification settings - Fork 39
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 scope warnings, fix #196 #197
base: master
Are you sure you want to change the base?
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 |
---|---|---|
|
@@ -242,9 +242,9 @@ struct HashMap(K, V, Allocator = Mallocator, alias hashFunction = generateHash!K | |
/** | ||
* Returns: a range of the keys in this map. | ||
*/ | ||
auto byKey(this This)() inout @trusted | ||
auto byKey(this This)() inout @safe return scope | ||
{ | ||
return MapRange!(This, IterType.key)(cast(Unqual!(This)*) &this); | ||
return MapRange!(This, IterType.key)((() @trusted => cast(Unqual!(This)*) &this)()); | ||
} | ||
|
||
/** | ||
|
@@ -271,9 +271,9 @@ struct HashMap(K, V, Allocator = Mallocator, alias hashFunction = generateHash!K | |
/** | ||
* Returns: a range of the values in this map. | ||
*/ | ||
auto byValue(this This)() inout @trusted | ||
auto byValue(this This)() inout @safe return scope | ||
{ | ||
return MapRange!(This, IterType.value)(cast(Unqual!(This)*) &this); | ||
return MapRange!(This, IterType.value)((() @trusted => cast(Unqual!(This)*) &this)()); | ||
Comment on lines
+274
to
+276
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. Same here. |
||
} | ||
|
||
/// ditto | ||
|
@@ -303,9 +303,9 @@ struct HashMap(K, V, Allocator = Mallocator, alias hashFunction = generateHash!K | |
* Returns: a range of the kev/value pairs in this map. The element type of | ||
* this range is a struct with `key` and `value` fields. | ||
*/ | ||
auto byKeyValue(this This)() inout @trusted | ||
auto byKeyValue(this This)() inout @safe return scope | ||
{ | ||
return MapRange!(This, IterType.both)(cast(Unqual!(This)*) &this); | ||
return MapRange!(This, IterType.both)((() @trusted => cast(Unqual!(This)*) &this)()); | ||
Comment on lines
+306
to
+308
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. Same here. |
||
} | ||
|
||
/** | ||
|
@@ -431,7 +431,7 @@ private: | |
|
||
private: | ||
|
||
this(Unqual!(MapType)* hm) | ||
this(Unqual!(MapType)* hm) @safe | ||
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. The compiler should be able to infer this. |
||
{ | ||
this.hm = hm; | ||
this.bucketIndex = 0; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -899,7 +899,7 @@ private: | |
return r; | ||
} | ||
|
||
void rotateLeft(ref Node* root, AllocatorType allocator) @safe | ||
void rotateLeft(ref Node* root, AllocatorType allocator) @trusted | ||
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. Why does this need to be |
||
{ | ||
Node* newRoot; | ||
if (right.left !is null && right.right is null) | ||
|
@@ -927,7 +927,7 @@ private: | |
cleanup(newRoot, root, allocator); | ||
} | ||
|
||
void rotateRight(ref Node* root, AllocatorType allocator) @safe | ||
void rotateRight(ref Node* root, AllocatorType allocator) @trusted | ||
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. Same here. |
||
{ | ||
Node* newRoot; | ||
if (left.right !is null && left.left is null) | ||
|
@@ -959,10 +959,12 @@ private: | |
{ | ||
if (newRoot.parent !is null) | ||
{ | ||
if (newRoot.parent.right is &this) | ||
newRoot.parent.right = newRoot; | ||
else | ||
newRoot.parent.left = newRoot; | ||
(() @trusted { | ||
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. Same here. |
||
if (newRoot.parent.right is &this) | ||
newRoot.parent.right = newRoot; | ||
else | ||
newRoot.parent.left = newRoot; | ||
})(); | ||
} | ||
else | ||
root = newRoot; | ||
|
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.
You're returning
&this
, notthis
, so the correct lifetime annotation here isreturn ref
(i.e.,return
, since theref
onthis
is implicit), notreturn scope
.