-
Notifications
You must be signed in to change notification settings - Fork 13.3k
'unsafe impl<A> Allocator for &A where A: Allocator' is problematic #98232
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
See also #94069, #94114 (comment); there're other reasons that this blanket implementation is problematic. I'd personally be fine removing the impl for the short-to-medium term at least. Long-term/stable needs a bit more consideration at least, though. |
Remove accidental uses of `&A: Allocator` Cc rust-lang#98232 Fixes rust-lang#98176 (for real this time)
Remove accidental uses of `&A: Allocator` Cc rust-lang#98232 Fixes rust-lang#98176 (for real this time)
@CAD97 I don't think it's problematic if we fix the wording on the |
The impl can be made sound via doc clarifications (which should certainly happen even without the impl provided), yes; I was just noting the issue as a related incidental complexity of the impl. |
Remove accidental uses of `&A: Allocator` Cc rust-lang/rust#98232 Fixes rust-lang/rust#98176 (for real this time)
We have a general
Allocator
instance for&A
whereA: Allocator
. I think that is a problem. In #98178 I fixed a problem whereBTreeMap<T, Global>
would actually use&Global
as allocator, which leads to performance regression. Or at least, I thought I had fixed that problem -- I just realized that there are some places where it still adds an indirection and therefore adds an unnecessary reference that will be copied around:rust/library/alloc/src/collections/btree/map.rs
Line 1647 in 3a1e114
I found this by removing the
unsafe impl<A> Allocator for &A where A: Allocator + ?Sized
instance. I don't know of another way to avoid accidentally introducing such performance regressions.So maybe that instance should be removed?
Cc @rust-lang/wg-allocators
The text was updated successfully, but these errors were encountered: