Closed TimDiekmann closed 4 years ago
@rust-lang/libs Any thoughts on this, since it’s about stable APIs?
Adding those two types to core::mem
makes sense to me!
Regarding renaming to LayoutError
: I'd be uncomfortable with having the same type being available with two different names. I see two viable options:
LayoutErr
in std::mem
(although that would be unfortunate, yes), or core::mem::LayoutError
, reexport it as alloc::alloc::LayoutError
and reexport it as alloc::alloc::LayoutErr
, but soft deprecate the latter. We could add a doc comment to the reexport with a soft-deprecate warning or even hide alloc::LayoutErr
in the docs completely. Or even actually hard deprecating it (if #[deprecated]
on reexports is even supported).Regarding renaming to
AllocError
: I'd be uncomfortable with having the same type being available with two different names.
I think you meant LayoutError
?
When deprecating core::alloc::LayoutErr
is an option, why even reexport as core::alloc::LayoutError
? Should the reexport of Layout
also be marked as deprecated?
This works fine:
#[stable(feature = "alloc_layout", since = "1.28.0")]
#[rustc_deprecated(since = "1.45.0", reason = "Use `core::mem::Layout` instead")]
pub use crate::mem::Layout;
#[stable(feature = "alloc_layout", since = "1.28.0")]
#[rustc_deprecated(since = "1.45.0", reason = "Use `core::mem::LayoutError` instead")]
pub use crate::mem::LayoutError as LayoutErr;
At least it compiles. I tried to build the docs but x.py
decided to recompile LLVM which will take a while...
I think you meant
LayoutError
?
Oh, yes, sorry. Fixed.
Which #[stable]
attribute core::mem::Layout
should receive? since = "1.45.0"
? While it's confusing, that Layout
is introduced in "1.45" it would not compile on older versions.
Neither #[rustc_deprecated]
nor documenting a reexport is working. #[rustc_deprecated]
does not emit any warning and neither generate any hints in the documentation. The best bet is to use #[doc(no_inline)]
to express that this is a reexport. Maybe we could (soft-)deprecate it later when rustc/rustdoc supports this.
Layout
is basically a wrapper aroundmem::size_of
andmem::align_of
(batteries included) and should live in the same module. For compatibility,Layout
(and its Error) have to be reexported tocore::alloc
.NB: As the discussion just came up (#57), it would also be possible to rename
LayoutErr
toLayoutError
incore::mem
and reexport it incore::alloc
asLayoutErr
.