You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Migrated] core::mem::swap used to work, then broke (and later accidentally got unbroken again). #117
Issue automatically imported from old repo: EmbarkStudios/rust-gpu#804 Old labels: t: bug,a: rust-lang,t: external,s: qptr may fix Originally creatd by hatoo on 2021-11-21T13:05:53Z
Comment from eddyb (CONTRIBUTOR) on 2021-11-22T14:33:16Z 👍: 1
In #716 we updated to a version that supports mem::replace again, thanks to rust-lang/rust#87827, but mem::swap indeed did not get fixed the same way - if someone wants to try and land upstream something like that PR but for mem::swap, feel free to.
I gave up on it because of how rare mem::swap is compared to mem::replace (which gets used everywhere in core, e.g. Option::take(self) is mem::replace(self, None) and range iterators also depend on it).
There's a more general fix at rust-lang/rust#86699 but it requires a bunch of unstable feature-gating stuff I haven't gone back to for.
Now I'm worried that people may be relying on it, since it works, but I'm not sure how to check. core itself seems to mostly use for sorting/partitioning-like tasks.
Activity
rust-gpu-bot commentedon Nov 13, 2024
Comment from eddyb (CONTRIBUTOR) on 2021-11-22T14:33:16Z 👍: 1
In #716 we updated to a version that supports
mem::replaceagain, thanks to rust-lang/rust#87827, butmem::swapindeed did not get fixed the same way - if someone wants to try and land upstream something like that PR but formem::swap, feel free to.I gave up on it because of how rare
mem::swapis compared tomem::replace(which gets used everywhere incore, e.g.Option::take(self)ismem::replace(self, None)and range iterators also depend on it).There's a more general fix at rust-lang/rust#86699 but it requires a bunch of unstable feature-gating stuff I haven't gone back to for.
rust-gpu-bot commentedon Nov 13, 2024
Comment from oisyn (CONTRIBUTOR) on 2023-03-29T13:32:12Z
Closing as won't fix, it's very unlikely we will address this in the forseeable future.
rust-gpu-bot commentedon Nov 13, 2024
Comment from eddyb (CONTRIBUTOR) on 2023-10-01T17:15:11Z
This actually works in Rust-GPU 0.4, and more specifically since
nightly-2022-02-28, thanks to:(the function being modified there,
swap_simple, is always used on SPIR-V, and the change that actually unblocked it wasptr::copy_nonoverlapping(y, x, 1)being replaced with aptr::{read,write}pair)But at the same time, I wanted to propose to upstream that they can remove the
target_arch = "spirv"hack, as it got brought up in this issue:Now I'm worried that people may be relying on it, since it works, but I'm not sure how to check.coreitself seems to mostly use for sorting/partitioning-like tasks.Oh, according to sourcegraph, it's definitely gotten used, oh well.
So we might want to do nothing for now, and only remove the upstream hack if
qptrcan supersede it.Update Add Example & Getting Started (Rust-GPU#117)