Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
compiler-errors opened this issue Mar 22, 2023 · 0 comments · Fixed by #112611
Closed
Assignees
Labels
C-bug Category: This is a bug. F-return_position_impl_trait_in_trait `#![feature(return_position_impl_trait_in_trait)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@compiler-errors
Copy link
Member

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.

@compiler-errors compiler-errors added C-bug Category: This is a bug. F-return_position_impl_trait_in_trait `#![feature(return_position_impl_trait_in_trait)]` labels Mar 22, 2023
@compiler-errors compiler-errors self-assigned this Mar 22, 2023
@Noratrieb Noratrieb added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 5, 2023
@bors bors closed this as completed in 8aff112 Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-return_position_impl_trait_in_trait `#![feature(return_position_impl_trait_in_trait)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
Development

Successfully merging a pull request may close this issue.

2 participants