Skip to content

We don't perform sized elaboration for impl-Trait-in-bindings (trait ascription) #144135

@fmease

Description

@fmease

I expected impl …-in-binding to get elaborated to impl Sized + … unless contains ?Sized because that's what we do for all other kinds of impl-Trait (APIT, RPIT(IT), TAIT, ATPIT). However, we don't seem to do that right now.

I expected the code below to fail but it compiled successfully:

#![feature(impl_trait_in_bindings)]

fn main() {
    let _: &impl std::fmt::Debug = &[0u8][..];
}

The &impl std::fmt::Debug above should actually elaborate to &(impl std::fmt::Debug + Sized) and therefore the code should fail due to an unfulfilled [u8]: Sized obligation/goal.

As in other places, users need to actually write &(impl std::fmt::Debug + ?Sized) if they want the code above to work like on master.

Metadata

Metadata

Labels

A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.F-impl_trait_in_bindings`#![feature(impl_trait_in_bindings)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions