Skip to content

Commit

Permalink
Move namespace rust::repr above namespace rust::detail
Browse files Browse the repository at this point in the history
I'd like to use rust::repr::PtrLen in the implementation of a
rust::detail::Fail functor.
  • Loading branch information
dtolnay committed Oct 15, 2022
1 parent 41f662f commit 202a029
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions gen/src/builtin.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 202a029

Please sign in to comment.