Repository navigation
feat: new allocator features - #656
Conversation
|
well I think it makes more sense to invert the dependency dependencies of the two allocator ones and have the allocator-api2 as the default |
|
ah no, can't do that because the nightly one then will randomly download |
|
I've disabled one fuzzing operation because it magically failed to compile we have to remake fuzzing anyway so I'm not worried, see #657 |
|
I will fix the fuzzing stuff once #658 lands |
I've been able to get it to work by just exporting the macro from the pub use alloc::{
vec::Vec,
vec
};into pub use alloc::{
vec::{
self,
Vec
}
}; |
|
yeah that's exactly what I didn't want to do do we have any other alternative?? maybe #[rustfmt::skip]
pub use alloc::vec; |
|
Yeah I think that should work too. |
|
Does this PR mean you can only Given that the default would be |
|
that's a good point maybe by default we should disable all features and that's it honestly very few people use custom allocators yet anyway it'd also make CI simpler |
What did it complain about? |
|
actually I think it'll work now |
|
If we bring no features and want to use allocator-specific functions (such as Additionally, if we're under Closure on this is instrumental to implement #669 properly. As of now, it seems that I can only write tests that reliably compile for the nightly |
|
yeah version mismatch with |
|
This didn't answer my question - If I'm going to write a testing suite for custom allocators, surely they must pass with any and all flags, right? And so, they should adapt to each situation; As we should do anyway, independently of having this testing suite, as whatever can't compile in it also won't compile in real user code that attempts to use the same code and combination of features. As of now, it seems currently impossible for me to write custom allocator tests in the default case, with neither tl;dr - I can write tests that work with both I'm not sure on what would be the best solution but I believe this definitely shouldn't be as it is, as this means a) consumers might reach code that they can't use and b) I can't make a test case that will compile properly under all three circumstances. There's two different questions to tackle here. Perhaps a new issue or at least further, more detailed discussion in #669 is warranted. |
|
yeah the API is made so that without any features enabled, you can't use any allocator features. there's nothing to use anyway, it's just a dummy yes, with neither of the allocator features enabled I think the desired behavior should be that users can't simply touch allocator-related stuff. like it currently happens in I know about version sensitivity in I don't think the custom allocator testing suite should work when you can't literally access allocators, so maybe cfg it |
|
To compare with hashbrown, they don't seem to include the allocator API in any tests, aside from some doctests where they explicitly add a |
I can understand this, but then we just export and expose custom allocator functions that are impossible to use for the default use case? Is this what we want? Not that it's a no-op or that it panics or something similar, but that it's quite literally impossible to compile? Would it be possible to simply hide/not export these functions via a cfg or something?
I suppose so. I think this becomes a losing battle when we pick a given version of
This seems like a possibility. This would perhaps solve question b).
In other words they don't handle at all custom allocator tests? This makes me wonder on whether we should in the first place. At least in this point in time. |
I understand that it would be much more difficult than that since the Perhaps the way right now is to simply let the compile errors show up and only write these tests for the case of either of the two features? Or not write these tests at all as of now (@bolshoytoster's note made me wonder this)? What do you think? |
I like that idea
I don't think we can, so we can just make the educated guess that the downstream crate uses the latest version of
I think we should anyway, I think there's probably UB / failures around there. not testing it is not an option for us what we can also do is choose to export |
|
wait if we export we should only hide if no allocator feature is enabled and internals is disabled |
this PR revamps the allocator features
feature hierarchy
the allocator-api2 implies allocator-api, to make sure no weird case of both together when they should be disjoint exists
exported types
each of the three modes internally exports three types:
Global,VecandBoxwhich are then used in the rest of the API
that means that all conversions only happen to and from those types, not others
this is relevant to #649, though allocator-handling is a bit fucked up in the base case, so I'm not sure if it'd be easy to handle it there. and it unblocks #644
closes #655
closes #631
note: there is a regression in
from_elembecause I couldn't use thevecmacro anymore without doing macro wizardry, so it now uses iterators again