8

Make outlives::{components,verify} agree by aliemjay · Pull Request #97406 · rus...

 3 years ago
source link: https://github.com/rust-lang/rust/pull/97406
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Contributor

oli-obk commented on May 27

Nominating for T-types discussion:

fn opaque<F>(_: F) -> impl Iterator { b"".iter() }
fn assert_static<T: 'static>(_: T) {}

fn good_generic_fn<T>() {
    // proving `<OpaqueTy<type_of(async {})> as Iterator>::Item: 'static`
    // somehow requires `T: 'static`.
    assert_static(opaque(async {}).next());
    assert_static(opaque(|| {}).next());
    assert_static(opaque(opaque(async {}).next()).next());
}

does not compile right now, because the T of good_generic_fn is inherited by generators and closures, even if they do not capture any types that relate to T. This PR does not change that, but it instead adjusts the algorithm figuring out which types and lifetimes must be considered for an outlives bound to only look at captured things in the generators or closures.

This scheme already works on stable for simpler cases, but in associated types it breaks down. Thus I nominate for T-types instead of T-lang, since imo this is just-an-impl-bug and the behaviour intended by the lang team.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK