Skip to content

Commit

Permalink
Small cleanup improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
juntyr committed Dec 8, 2023
1 parent 47f0e52 commit ac5ad2c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 0 additions & 4 deletions const-type-layout-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ use proc_macro2::Literal;
use quote::{quote, quote_spanned};
use syn::{parse_macro_input, spanned::Spanned};

// TODO:
// - wait for `const_heap` feature to be implemented for a workaround the graph
// size limitation: https://github.com/rust-lang/rust/issues/79597

#[proc_macro_error]
#[proc_macro_derive(TypeLayout, attributes(layout))]
pub fn derive_type_layout(input: TokenStream) -> TokenStream {
Expand Down
3 changes: 1 addition & 2 deletions src/impls/core/sync/atomic.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::{
impls::leak_uninit_ptr,
typeset::{tset, ComputeTypeSet, ExpandTypeSet, Set},
Field, MaybeUninhabited, TypeLayout, TypeLayoutInfo, TypeStructure,
};
Expand Down Expand Up @@ -119,7 +118,7 @@ macro_rules! impl_atomic_ptr_layout {

unsafe fn uninit() -> MaybeUninhabited<core::mem::MaybeUninit<Self>> {
MaybeUninhabited::Inhabited(core::mem::MaybeUninit::new(
Self::new(leak_uninit_ptr())
Self::new(core::ptr::NonNull::dangling().as_ptr())
))
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ pub unsafe trait TypeLayout: Sized {
unsafe fn uninit() -> MaybeUninhabited<core::mem::MaybeUninit<Self>>;
}

pub trait TypeGraphLayout: ~const TypeLayout {
#[const_trait]
pub trait TypeGraphLayout: ~const TypeLayout + typeset::ComputeTypeSet {
const TYPE_GRAPH: TypeLayoutGraph<'static>;
}

Expand Down
5 changes: 4 additions & 1 deletion try-crate/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ fn main() {

println!("{:#?}", <*const u8>::TYPE_GRAPH);
println!("{:#?}", <*mut u8>::TYPE_GRAPH);
println!("{:#?}", <core::ptr::NonNull<u8>>::TYPE_GRAPH);
println!("{:#?}", <core::sync::atomic::AtomicPtr<u8>>::TYPE_GRAPH);
println!("{:#?}", <&u8>::TYPE_GRAPH);
println!("{:#?}", <&mut u8>::TYPE_GRAPH);

Expand Down Expand Up @@ -264,7 +266,8 @@ fn non_static_ref<'a>(_val: &'a u128) {
println!("{:#?}", <Referencing<&'a u8>>::TYPE_GRAPH);
}

// const SERIALISED_LIST_U8_LAYOUT: [u8; const_type_layout::serialised_type_graph_len::<List<u8>>()] =
// const SERIALISED_LIST_U8_LAYOUT: [u8;
// const_type_layout::serialised_type_graph_len::<List<u8>>()] =
// const_type_layout::serialise_type_graph::<List<u8>>();

#[derive(
Expand Down

0 comments on commit ac5ad2c

Please sign in to comment.