Move namespace rust::repr above namespace rust::detail

I'd like to use rust::repr::PtrLen in the implementation of a
rust::detail::Fail functor.
This commit is contained in:
David Tolnay 2022-10-15 13:57:47 -07:00
parent 41f662f02e
commit 202a02917b
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -205,6 +205,26 @@ pub(super) fn write(out: &mut OutFile) {
writeln!(out, "inline Slice<T>::Slice(uninit) noexcept {{}}");
}
out.begin_block(Block::Namespace("repr"));
if builtin.repr_fat {
include.array = true;
include.cstdint = true;
out.next_section();
writeln!(out, "using Fat = ::std::array<::std::uintptr_t, 2>;");
}
if builtin.ptr_len {
include.cstddef = true;
out.next_section();
writeln!(out, "struct PtrLen final {{");
writeln!(out, " void *ptr;");
writeln!(out, " ::std::size_t len;");
writeln!(out, "}};");
}
out.end_block(Block::Namespace("repr"));
out.begin_block(Block::Namespace("detail"));
if builtin.maybe_uninit {
@ -262,26 +282,6 @@ pub(super) fn write(out: &mut OutFile) {
writeln!(out, "}};");
}
out.begin_block(Block::Namespace("repr"));
if builtin.repr_fat {
include.array = true;
include.cstdint = true;
out.next_section();
writeln!(out, "using Fat = ::std::array<::std::uintptr_t, 2>;");
}
if builtin.ptr_len {
include.cstddef = true;
out.next_section();
writeln!(out, "struct PtrLen final {{");
writeln!(out, " void *ptr;");
writeln!(out, " ::std::size_t len;");
writeln!(out, "}};");
}
out.end_block(Block::Namespace("repr"));
out.begin_block(Block::AnonymousNamespace);
if builtin.rust_str_new_unchecked || builtin.rust_str_repr {