-
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
Consider moving std::error::Error to alloc
#62502
Comments
I think that longer term offering it in |
@clarfon core doesn't have Box |
true, but Box is only used for |
It would require changes to how the language works, yes. But it'd be doable long term. |
Hi, as a user I want to say that this would really help our projects, especially if it is adopted in I think it ( |
Moving to liballoc should be fine. Lines 5 to 14 in c7d4df0
|
Given Error::backtrace and Backtrace, it's pretty clear that doing this would need something akin to an RFC -- we need to decide how to expose Backtrace to no_std users: an opaque blob, always an empty backtrace, or something else? Given that, closing. |
@Mark-Simulacrum it was suggested in #64017 that it can be a zero-width type, presumably with no contents |
It's possible that's the right decision. I don't think it answers all the questions. I would suggest opening a PR to this repository after implementing this; if you're interested in discussing how to do so I believe internals is the right place for that. |
I don't think I have bandwidth to do that right at this moment, but yeah i'm probably interested If you think an RFC is the right way to go I'm also potentially interested in driving that process or participating in it, though I've never done that before |
Doesn't the https://github.com/rust-lang/backtrace-rs/blob/3804dac/src/lib.rs#L67 |
|
@shepmaster well, regardless of whether it's possible to capture a backtrace or not (that's something that can always be fixed in the future), it'd be nice to be able to use its
Unfortunately I just confirmed one problem: the That said, it seems like with a little work it should be possible to support the |
reconsidering attempting this related convo: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/error.20in.20core |
Triage: Error was moved to core in #99917 (🎉 ). Closing this as fixed. |
See #103765 for actually stabilizing the move. |
Now that
alloc
is stable, this is a somewhat visible omission fromno_std
contexts.In practice, it being in
std
means that library crates that would otherwise beno_std
(+alloc
) compatible which expose some sort of error type have to either:std::error::Error
for their error type, giving up error ergonomics for users regardless of whether or not they care about no_stdstd::error::Error
behind a feature, which is awkward.alloc
behind a feature, now you end up with separatealloc
andstd
features (which is the option I took in one of my crates, and is mostly why I'm filing this) but is tedious, and makes your library have a larger configuration surface than feels necessary.Bummers, all of them.
If Error is moved to
alloc
, while not ideal [1], it would make things easier for the relatively common case of library crates that could otherwise beno_std
+alloc
, but don't want to give up error handling ergonomics.[1]: I think having
Error
incore
makes more sense, but IIUC it can't: #33149 (my read of this, which is probably wrong in some way, is that it's more or less becauseError::downcast
needs to be able to return aBox<T>
)As far as I know nothing prevents it from being in
alloc
(since Box is present inalloc
), but I could easily be missing something important.anyway thx for coming to my ted talk
The text was updated successfully, but these errors were encountered: