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
Almost every error type in the standard library is named SomethingError, not SomethingErr. The one exception is LayoutErr, which is stable and so can’t easily be renamed. Although LayoutErr has more "proximity" to AllocErr (being in the same module) I think we should leave it as a lone inconsistency rather than make it a second naming pattern to follow.
Reacted by RustyYato, Tim Diekmann and Scott J Maddox
I think we should leave it as a lone inconsistency rather than make it a second naming pattern to follow.
As we are in the module alloc we should then rename it to Error to follow the naming pattern in std (io::Error and fmt::Error, not IoError and FmtError). Search results for Error
We should decide, if we want AllocErr to be renamed to Error or AllocError. Other modules like core::fmt also have the Error type and it's known pattern to rust users, that different Errors occurs in core/std. Anyway, we also have core::alloc::LayoutErr (stable) and this will not be moved until we use Layout outside of std::alloc (see #59 and rust-lang/rust#71856). However, AllocErr is the "main-error" type in core::alloc, which is an argument for renaming it to Error.
One other thing to consider is, that AllocError may occure alongside other errors more often as soon as a user decides to use a fallible allocation API.
We basically have to decide, if we want to go the old std-way or the explicit way here.
I think it makes the most sense to go with AllocError to be consistent with the majority of the other error types. Also, as Tim mentioned, AllocError will likely be used in code with other application specific error types so I don't think it makes sense to go down the std::alloc::Error path.
Also I think it would be nice if we could deprecate LayoutErr with LayoutError just for consistency.
Reacted by Erich Gubler, Lokathor, Tim Diekmann and Josh Triplett
Assuming this works, we should rename LayoutErr to LayoutError, add pub type LayoutErr = LayoutError, and do a crater-run just to be sure.
However, if LayoutErr will be renamed should be discussed in a separate issue, as this is way more complicated than renaming AllocErr (as LayoutErr is stable).
I'd go with @exrook suggestion and just rename AllocErr to AllocError
to be consistent with the majority of the other error types.
AllocError is by far not common enough to name it alloc::Error like fmt::Error or io::Error.
io::Error and fmt::Error are actually the ones that don't fit the style of the rest of the standard library. (In a world where we could rename everything, they'd probably get a rename too.)
Activity
TimDiekmann commentedon Apr 26, 2020
As we are in the module
allocwe should then rename it toErrorto follow the naming pattern in std (io::Errorandfmt::Error, notIoErrorandFmtError). Search results forErrorSimonSapin commentedon Apr 26, 2020
Maybe, though those modules only have one error type while
std::allocalso hasLayoutErr. I could still live with this.SimonSapin commentedon Apr 26, 2020
On a less serious note, we also have an
alloc::alloc::allocfunction ;)TimDiekmann commentedon Apr 26, 2020
AllocErroris the main error type inalloc. Personally I thinkLayout(Err)should live inmeminstead ofalloc, right next toalign_ofandsize_of.SimonSapin commentedon Apr 26, 2020
That… hadn’t occurred to me but it makes sense. It may even be worth making the move and having re-exports for compat.
TimDiekmann commentedon Apr 26, 2020
Actually I was just about posting a proposal... #59
TimDiekmann commentedon Sep 24, 2020
We should decide, if we want
AllocErrto be renamed toErrororAllocError. Other modules likecore::fmtalso have theErrortype and it's known pattern to rust users, that differentErrors occurs incore/std. Anyway, we also havecore::alloc::LayoutErr(stable) and this will not be moved until we useLayoutoutside ofstd::alloc(see #59 and rust-lang/rust#71856). However,AllocErris the "main-error" type incore::alloc, which is an argument for renaming it toError.One other thing to consider is, that
AllocErrormay occure alongside other errors more often as soon as a user decides to use a fallible allocation API.We basically have to decide, if we want to go the old
std-way or the explicit way here.Amanieu commentedon Sep 24, 2020
I don't mind the way it is right now, especially considering
LayoutErrandAllocErrare likely to be used together a lot.exrook commentedon Sep 24, 2020
Doing a quick survey of all the error types in std, we have:
Error
_ Error
_ Err
I think it makes the most sense to go with
AllocErrorto be consistent with the majority of the other error types. Also, as Tim mentioned,AllocErrorwill likely be used in code with other application specific error types so I don't think it makes sense to go down thestd::alloc::Errorpath.Also I think it would be nice if we could deprecate
LayoutErrwithLayoutErrorjust for consistency.Lokathor commentedon Sep 24, 2020
pub type LayoutError = LayoutErr;would solve a lotTimDiekmann commentedon Sep 24, 2020
Is it possible to write
and deprecate
LayoutErrwithout getting a warning when usingLayoutError?Is a type alias 100% backwards compatible when changing it to the actual struct? Or vice versa?
TimDiekmann commentedon Sep 24, 2020
Iff we change
LayoutErrtoLayoutError, do we still want it incore::allocor should we move it tocore::mem? Related: #59 and rust-lang/rust#71856JelteF commentedon Sep 24, 2020
You could also "soft deprecate" it, by simply writing a note in the docs about it.
I believe so
TimDiekmann commentedon Sep 24, 2020
Assuming this works, we should rename
LayoutErrtoLayoutError, addpub type LayoutErr = LayoutError, and do a crater-run just to be sure.However, if
LayoutErrwill be renamed should be discussed in a separate issue, as this is way more complicated than renamingAllocErr(asLayoutErris stable).I'd go with @exrook suggestion and just rename
AllocErrtoAllocErrorAllocErroris by far not common enough to name italloc::Errorlikefmt::Errororio::Error.Lokathor commentedon Sep 24, 2020
io::Error and fmt::Error are actually the ones that don't fit the style of the rest of the standard library. (In a world where we could rename everything, they'd probably get a rename too.)
Rollup merge of rust-lang#77315 - exrook:rename-allocerror, r=joshtri…
Rollup merge of rust-lang#77315 - exrook:rename-allocerror, r=joshtri…