Open
Description
Code
pub trait Functor
{
type With<T>: Functor;
}
pub struct IdFunctor<T>(T);
impl<T> Functor for IdFunctor<T> {
type With<T2> = IdFunctor<T2>;
}
impl<T> Functor for Vec<T> {
type With<T2> = Vec<T2>;
}
impl<T> Functor for Box<T> {
type With<T2> = Box<T2>;
}
pub struct Compose<F1, F2, T>(F1::With<F2::With<T>>)
where
F1: Functor,
F2: Functor;
impl<F1, F2, T> Functor for Compose<F1, F2, T>
where
F1: Functor,
F2: Functor
{
type With<T2> = F1::With<F2::With<T2>>;
}
pub enum Value<F, FVEC>
where
F: Functor,
FVEC: Functor,
{
UnsignedInt(F::With<u64>),
Array(Box<Value<FVEC, Compose<F, FVEC, ()>>>),
}
fn main() {
let x: Value<IdFunctor<()>, Compose<IdFunctor<()>, Vec<()>, ()>> = Value::UnsignedInt(IdFunctor(1));
}
Affected release channels
- Previous Stable
- Current Stable
- Current Beta
- Current Nightly
Rust Version
rustc 1.66.1 (90743e729 2023-01-10)
binary: rustc
commit-hash: 90743e7298aca107ddaa0c202a4d3604e29bfeb6
commit-date: 2023-01-10
host: x86_64-unknown-linux-gnu
release: 1.66.1
LLVM version: 15.0.2
Current error output
>>> RUSTFLAGS="-A unused" cargo test --color=always -- --nocapture --test-threads=1
Compiling traceevent v0.1.0 (lisa/tools/analysis/traceevent)
error: could not compile `traceevent`
Caused by:
process didn't exit successfully: `rustc --crate-name traceevent --edition=2021 traceevent/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --test -C metadata=a2a838ea58b05a7f -C extra-filename=-a2a838ea58b05a7f --out-dir lisa/tools/analysis/target/debug/deps -C incremental=lisa/tools/analysis/target/debug/incremental -L dependency=lisa/tools/analysis/target/debug/deps --extern memmap2=lisa/tools/analysis/target/debug/deps/libmemmap2-39be61c96f5d1d0c.rlib --extern nom=lisa/tools/analysis/target/debug/deps/libnom-ff2be7353b7bf974.rlib --extern nom_locate=lisa/tools/analysis/target/debug/deps/libnom_locate-4ec40cb54fefc4c1.rlib --extern smartstring=lisa/tools/analysis/target/debug/deps/libsmartstring-b065da3210ea89f5.rlib --extern thiserror=lisa/tools/analysis/target/debug/deps/libthiserror-5bdf89cac3d44f1d.rlib -A unused` (signal: 11, SIGSEGV: invalid memory reference)
Backtrace
No backtrace:
(signal: 11, SIGSEGV: invalid memory reference)
Anything else?
This happened while tinkering with a code similar to this issue:
#107362
The difference is that I "manually unrolled" one level of Compose<F, Vec>
into FVEC, so the type of Value<FVEC, Compose<F, FVEC, ()>>
is now (possibly) an infinite chain of mutually recursive F and FVEC instead of a directly recursive chain of F
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
Area: Generic associated types (GATs)Area: Trait systemCategory: This is a bug.Issue: Problems and improvements with respect to memory usage during compilation.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.High priorityRelevant to the types team, which will review and decide on the PR/issue.