rustc cannot determine if a type is `Sized`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
use std::marker::PhantomData;
pub trait ForLt<'a> { type Ty: 'a; }
impl<'a, T: ForLt<'a> + ?Sized> ForLt<'a> for PhantomData<T> {
type Ty = T::Ty;
}
macro_rules! hkt {
(for<$lt:lifetime> $T:ty) => {
::core::marker::PhantomData<dyn for<$lt> ForLt<$lt, Ty = $T>>
};
($T:ty) => {
::core::marker::PhantomData<dyn for<'a> ForLt<'a, Ty = $T>>
};
}
pub trait ValueLike {}
pub trait Value<'a>: ValueLike {}
pub trait ComposableValue<'a>: ValueLike {}
pub struct Dummy;
impl ValueLike for Dummy {}
impl<'a> Value<'a> for Dummy {}
impl<'a> ComposableValue<'a> for Dummy {}
impl<A: ValueLike, B: ValueLike> ValueLike for (A, B) {}
impl<'a, A: ComposableValue<'a>, B: Value<'a>> Value<'a> for (A, B) {}
pub trait OpenTable {
type Table;
fn open() -> Self::Table;
}
pub trait TableDesc {
type Table;
}
pub struct RocksDbTable<M, K, V> {
pub(crate) _pd: PhantomData<(M, K, V)>,
}
impl<
M,
K: for<'a> ForLt<'a, Ty: Value<'a>>,
V: for<'a> ForLt<'a, Ty: Value<'a>>,
T: TableDesc<Table = RocksDbTable<M, K, V>>,
> OpenTable for T
{
type Table = <T as TableDesc>::Table;
fn open() -> Self::Table { unimplemented!() }
}
pub struct TableA;
impl TableDesc for TableA {
type Table = RocksDbTable<Self, hkt!(Dummy), hkt!((Dummy, Dummy))>;
}
fn issue() {
let table = <TableA as OpenTable>::open();
// Works if you change OpenTable to TableDesc on this line:
struct MyStruct(<TableA as OpenTable>::Table);
let my_struct = MyStruct(table);
}
I expected to see this happen: Compile successfully, because RocksDbTable has a static size and <TableA as OpenTable>::Table == <TableA as TableDesc>::Table
Instead, this happened: error[E0161]: cannot move a value of type 'MyStruct'
Meta
rustc --version --verbose:
1.94.1 (Rust Playground)
rustc 1.96.0-nightly (20f19f461 2026-03-21) (Locally)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by compiling the provided reproducer with the stable and nightly rustc versions listed, then compare the OpenTable projection with the TableDesc version that succeeds. Investigate the compiler's handling of the associated Table type and its Sized determination; done means explaining or correcting the E0161 result so the reproducer compiles as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100