Conversation
4e8a431 to
c976221
Compare
|
Whoops the order is the same, I just wrote it wrong. It has the same length checks too - will update the OP. |
Just noting that we concluded in the discussion that |
3602635 to
d67f0b0
Compare
|
Additionally, per the |
Does deprecation mean replace with |
Doc comment. I think it's removal that either means outright deletion, or |
f8d1141 to
7f0001a
Compare
21b518e to
99eff11
Compare
7a4c39c to
fd577a8
Compare
|
I don't know what the aarch64-macos-debug CI issue is - it failed before and after a rebase for |
|
Looks like the aarch64-macos-debug CI issue is unrelated, there are other PRs that are having the same failure. |
|
macho linker bug filed at #23010 |
e406ad0 to
286afb5
Compare
|
I've rebased onto master (c06fecd) and enabled the 'allow edits by maintainers' option so you shouldn't hit that error again. |
|
Thanks! |
|
This is bikeshedy, but I do feel somewhat strongly here. While Given that using a wrong copy built-in can lead to subtle bugs, perhaps we can use a less legacy-inspired name here? I would prefer A less bikesheddy question is whether
Only 0.6 sure here, but it seems to me that the third use-case, where you don't know if slices overlap, is not a real use-case. Quick glance at So perhaps the right signature is fn @memmove(slice: []T, by: isize) voidThat is, we pass a signed shift distance: msg.notes = try sema.gpa.realloc(msg.notes, orig_notes + 1);
@memmove(msg.notes[1..][0..orig_notes], msg.notes[0..orig_notes]);
msg.notes[0] = .{
.src_loc = msg.src_loc,
.msg = msg.msg,
};-> msg.notes = try sema.gpa.realloc(msg.notes, orig_notes + 1);
@memmove(msg.notes[0..orig_notes], +1);
msg.notes[0] = .{
.src_loc = msg.src_loc,
.msg = msg.msg,
}; |
|
🤔 hm, the fn @memmove(slice: []T, subslice: []T, by: isize) void@memmove(msg.notes, msg.notes[0..orig_notes], +1);EDIT: another option is to use offset instead of signed difference, that is what Rust is doing: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.copy_within So, |
|
Another option could be to have a single |
This PR adds a new builtin
@memmove(dest: T, src: T) void. It is similar to@memcpyexcept it can be used for overlapping memory regions. The intended semantics are:srcanddestcan each be a slice, pointer to array, or many-item pointersrcanddestmust provide a length, and if they both do the lengths must be the sameunlike (the intended runtime, and current comptime) behaviour of@memcpy,@memmoverequires the element type ofsrcanddestto be coercible to each other in memory@memmove(dest, src)is thatdest[0..len]contains bytes as if a element-by-element loop copiedsrc[0..len]to an auxiliary buffer, and then a second loop copied from that buffer todest[0..len].This builtin is currently using up the last ZIR tag.
Related: #767