Skip to content

Unconstrained lifetimes are allowed on return-position-impl-trait-in-trait impl methods #109468

Closed
@compiler-errors

Description

@compiler-errors

I tried this code:

#![feature(return_position_impl_trait_in_trait)]

trait Foo {
    fn test() -> impl Sized;
}

impl<'a, T> Foo for T {
    fn test() -> &'a () { &() }
}

I expected to see this happen: Fails saying something about unconstrained lifetime parameters

Instead, this happened: Passes 😢


We'll just have to generalize enforce_impl_params_are_constrained to check RPITITs too.

I haven't made a test that actually turns this into an unsoundness, or even really thought if it's unsound, but if conceptually RPITITs are supposed to act like anonymous associated types, this probably shouldn't pass.

Metadata

Metadata

Labels

C-bugCategory: This is a bug.F-return_position_impl_trait_in_trait`#![feature(return_position_impl_trait_in_trait)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions