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

TAIT: "hidden type captures lifetime" even if it's static, inside closure #105303

Open
Dirbaio opened this issue Dec 5, 2022 · 0 comments
Open
Labels
F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]`

Comments

@Dirbaio
Copy link
Contributor

Dirbaio commented Dec 5, 2022

    let x: &'static u32 = &0;
    let _closure = move || {
        type T = impl Sized;
        let x: T = x;
    };

This code fails to compile playground with:

error[[E0700]](https://doc.rust-lang.org/nightly/error-index.html#E0700): hidden type for `T` captures lifetime that does not appear in bounds
 --> src/lib.rs:7:20
  |
7 |         let x: T = x;
  |                    ^
  |
  = note: hidden type `&u32` captures lifetime '_#8r

even though x is 'static, so it shouldn't require adding any lifetime to T's bounds.

If you move x inside the closure then it works:

    let _closure = move || {
        let x: &'static u32 = &0;
        type T = impl Sized;
        let x: T = x;
    };

Seems like x having to go through the closure captures makes TAIT not able to use the staticness of it somehow.

Nightly version: 1.67.0-nightly (2022-12-04 53e4b9d)
@rustbot label F-type_alias_impl_trait

@rustbot rustbot added the F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` label Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]`
Projects
None yet
Development

No branches or pull requests

2 participants