You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Output on rustc 1.66.0-nightly (0ca356586 2022-10-06), almost the same as on 1.64.0:
error[E0275]: overflow evaluating the requirement `Expression:DataSize`
--> src/lib.rs:3:10
|
3 | #[derive(DataSize)]
| ^^^^^^^^
|
= note: required because of the requirements on the impl of `DataSize` for `Box<Expression>`
= help:see issue #48214
= note: this error originates in the derive macro `DataSize` (in Nightlybuilds, run with -Z macro-backtrace for more info)For more information about this error, try `rustc --explain E0275`.
struct example:
use datasize::DataSize;#[derive(DataSize)]structBinaryTree{data:u32,// or somethingleft:Option<Box<Self>>,right:Option<Box<Self>>,}
error[E0391]: cycle detected when elaborating drops for `<implat src/lib.rs:3:10:3:18>::IS_DYNAMIC`
--> src/lib.rs:3:10
|
3 | #[derive(DataSize)]
| ^^^^^^^^
|
note: ...which requires const-evaluating + checking `<core::option::Option<T>as datasize::DataSize>::IS_DYNAMIC`...
--> /Users/simon/.cargo/registry/src/github.com-1ecc6299db9ec823/datasize-0.2.10/src/lib.rs:423:5
|
423 | constIS_DYNAMIC: bool = (T::IS_DYNAMIC || T::STATIC_HEAP_SIZE > 0);
| ^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating + checking `<core::option::Option<T>as datasize::DataSize>::IS_DYNAMIC`...
--> /Users/simon/.cargo/registry/src/github.com-1ecc6299db9ec823/datasize-0.2.10/src/lib.rs:423:5
|
423 | constIS_DYNAMIC: bool = (T::IS_DYNAMIC || T::STATIC_HEAP_SIZE > 0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating + checking `datasize::std::<impl datasize::DataSizefor alloc::boxed::Box<T>>::IS_DYNAMIC`...
--> /Users/simon/.cargo/registry/src/github.com-1ecc6299db9ec823/datasize-0.2.10/src/std.rs:24:5
|
24 | constIS_DYNAMIC: bool = T::IS_DYNAMIC;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating + checking `<implat src/lib.rs:3:10:3:18>::IS_DYNAMIC`...
--> src/lib.rs:3:10
|
3 | #[derive(DataSize)]
| ^^^^^^^^
note: ...which requires caching mir of `<impl at src/lib.rs:3:10:3:18>::IS_DYNAMIC` forCTFE...
--> src/lib.rs:3:10
|
3 | #[derive(DataSize)]
| ^^^^^^^^
= note: ...which again requires elaborating drops for `<impl at src/lib.rs:3:10:3:18>::IS_DYNAMIC`, completing the cycle
= note: cycle used when running analysis passes on this crate
= note: this error originates in the derive macro `DataSize` (in Nightly builds, run with -Z macro-backtrace for more info)For more information about this error, try `rustc --explain E0391`.
The text was updated successfully, but these errors were encountered:
Good point, I think this needs an explicit check for recursion to break.
It's also a bit of a footgun, since recursive types have to be walked one-by-one, in general the goal of the crate is to avoid these as much as possible as to not accidentally introduce a lot of resource usage simply by connecting memory usage metrics :/
Some data structures are inherently tree-shaped. Even if traversing them has non-trivial cost it may still be useful in an off-by-default code path to helps debug memory usage issues.
enum example:
Output on rustc 1.66.0-nightly (0ca356586 2022-10-06), almost the same as on 1.64.0:
struct example:
The text was updated successfully, but these errors were encountered: