#![feature(prelude_import)] #[prelude_import] use std::prelude::rust_2021::*; #[macro_use] extern crate std; use with::{remote::*, *}; #[allow(dead_code)] #[path = "with.rs"] mod with { pub mod remote { pub struct Inner(pub Box<u8>); } pub mod remote_inner_heap_size { use heapsz::HeapSize; use super::remote; pub fn heap_size(t: &remote::Inner) -> usize { t.0.heap_size() } } pub struct With { #[heap_size(with = "remote_inner_heap_size")] pub inner: remote::Inner, } impl ::heapsz::HeapSize for With { fn heap_size(&self) -> usize { 0 + remote_inner_heap_size::heap_size(&self.inner) } } fn main() {} } pub enum Enum { A(#[heap_size] usize), B(#[heap_size] usize, usize), C(#[heap_size(with = "remote_inner_heap_size")] Inner, usize), D { #[heap_size(with = "remote_inner_heap_size")] inner: Inner, #[heap_size] size1: usize, size2: usize, }, } impl ::heapsz::HeapSize for Enum { fn heap_size(&self) -> usize { #[allow(unused_variables)] match self { Self::A(f_0) => 0 + ::heapsz::HeapSize::heap_size(f_0), Self::B(f_0, f_1) => 0 + ::heapsz::HeapSize::heap_size(f_0), Self::C(f_0, f_1) => 0 + remote_inner_heap_size::heap_size(f_0), Self::D { inner, size1, size2 } => { 0 + remote_inner_heap_size::heap_size(inner) + ::heapsz::HeapSize::heap_size(size1) } } } } #[heap_size] pub enum All { A(usize), B(usize, usize), C(#[heap_size(with = "remote_inner_heap_size")] Inner, usize), D { #[heap_size(with = "remote_inner_heap_size")] inner: Inner, size1: usize, size2: usize, }, } impl ::heapsz::HeapSize for All { fn heap_size(&self) -> usize { #[allow(unused_variables)] match self { Self::A(f_0) => 0 + ::heapsz::HeapSize::heap_size(f_0), Self::B(f_0, f_1) => { 0 + ::heapsz::HeapSize::heap_size(f_0) + ::heapsz::HeapSize::heap_size(f_1) } Self::C(f_0, f_1) => { 0 + remote_inner_heap_size::heap_size(f_0) + ::heapsz::HeapSize::heap_size(f_1) } Self::D { inner, size1, size2 } => { 0 + remote_inner_heap_size::heap_size(inner) + ::heapsz::HeapSize::heap_size(size1) + ::heapsz::HeapSize::heap_size(size2) } } } } #[heap_size] pub enum Skip { A(#[heap_size(skip)] Inner, usize), B { #[heap_size(skip)] inner: Inner, size1: usize, size2: usize }, #[heap_size(skip)] C { inner: Inner }, } impl ::heapsz::HeapSize for Skip { fn heap_size(&self) -> usize { #[allow(unused_variables)] match self { Self::A(f_0, f_1) => 0 + ::heapsz::HeapSize::heap_size(f_1), Self::B { inner, size1, size2 } => { 0 + ::heapsz::HeapSize::heap_size(size1) + ::heapsz::HeapSize::heap_size(size2) } Self::C { inner } => 0, } } } #[heap_size] pub enum Empty {} impl ::heapsz::HeapSize for Empty { fn heap_size(&self) -> usize { 0 } } #[heap_size] pub enum Numbers { A = 1, B = 2, } impl ::heapsz::HeapSize for Numbers { fn heap_size(&self) -> usize { #[allow(unused_variables)] match self { Self::A => 0, Self::B => 0, } } } fn main() {}