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

normalizing opaques in outlives constraints allows more code compile #112

Open
lcnr opened this issue May 21, 2024 · 1 comment
Open

normalizing opaques in outlives constraints allows more code compile #112

lcnr opened this issue May 21, 2024 · 1 comment

Comments

@lcnr
Copy link
Contributor

lcnr commented May 21, 2024

#![feature(type_alias_impl_trait)]
use std::marker::PhantomData;
type Tait<'a> = impl Sized;

struct Outlives<'a, T: 'a>(PhantomData<&'a ()>, PhantomData<T>);

fn foo<'a, 'b>() -> Tait<'a> {
    let _: Outlives::<'b, Tait<'a>> = Outlives(PhantomData, PhantomData);
    ()
}

this fails with the old solver with

error: lifetime may not live long enough
 --> <source>:8:12
  |
7 | fn foo<'a, 'b>() -> Tait<'a> {
  |        --  -- lifetime `'b` defined here
  |        |
  |        lifetime `'a` defined here
8 |     let _: Outlives::<'b, Tait<'a>> = Outlives(PhantomData, PhantomData);
  |            ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'b`
  |
  = help: consider adding the following bound: `'a: 'b`
@compiler-errors
Copy link
Member

compiler-errors commented May 21, 2024

trait Captures<'a, 'b> {}
impl<T> Captures<'_, '_> for T {}

fn hello<'a: 'a, 'b: 'b>() -> impl Sized + Captures<'a, 'b> {
    fn outlives<'a>(_: impl Sized + 'a) {}
    outlives::<'a>(hello::<'a, 'b>());
    ()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants