-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Hide allocator details from TryReserveError #87408
Conversation
r? @kennytm (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
9f06923
to
d1d266e
Compare
This comment has been minimized.
This comment has been minimized.
d1d266e
to
8acf740
Compare
This comment has been minimized.
This comment has been minimized.
🤔 i'll defer this to T-libs-api to consider. r? @rust-lang/libs-api |
8acf740
to
a294aa8
Compare
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.
I don't love how every match against a TryReserveError needs an explicit map_err
to get the kind now before matching, but as far as I can tell it wouldn't be backwards incompatible to switch the opaque struct back to an enum in the future to enable direct convenient matching once we're confident we know the representation we want internally.
+1 from me but I'll wait until after today's libs-api team meeting before approving since it's already nominated.
Everyone seemed amenable to this change in the libs-api meeting, though we didn't go into a particularly detailed discussion about it. The expectation being that such a discussion would happen during follow up stabilization discussions. @bors r+ |
📌 Commit a294aa8 has been approved by |
☀️ Test successful - checks-actions |
Just a quick heads up: For some reason, this PR seems to have regressed the html5ever-opt benchmark: 4.24% more instructions:u, and 8.16% more max-rss. I'm not sure why this PR would cause that change, and it seems somewhat isolated to html5ever-opt. Skimming over the max-rss graphs, we cna see that html5-ever-opt is somewhat noisy, but it seems like a ~5% bump in max-rss can be potentially attributed to this PR. (At the same time, it isn't a broad regression across many benchmarks. So it probably isn't worth investing much time looking into this. I just wanted to post a heads up.) |
#87843 might address the regression. |
TryReserveErrorKind tests and inline A small follow-up to rust-lang#87408
I think there's no need for TryReserveError to carry detailed information, but I wouldn't want that issue to delay stabilization of the
try_reserve
feature.So I'm proposing to stabilize
try_reserve
with aTryReserveError
as an opaque structure, and if needed, expose error details later.This PR moves the
enum
to an unstable innerTryReserveErrorKind
that lives under a separate feature flag.TryReserveErrorKind
could possibly be left as an implementation detail forever, and theTryReserveError
get methods such asallocation_size() -> Option<usize>
orlayout() -> Option<Layout>
instead, or the details could be dropped completely to make try-reserve errors just a unit struct, and thus smaller and cheaper.