Skip to content

Instantly share code, notes, and snippets.

@Centril
Created June 5, 2019 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Centril/b0e62d31d4ae1849535c3e506e1fad64 to your computer and use it in GitHub Desktop.
Save Centril/b0e62d31d4ae1849535c3e506e1fad64 to your computer and use it in GitHub Desktop.
Old test for nested lifetimes in associated type bounds
// compile-fail
#![feature(associated_type_bounds)]
use std::fmt::Debug;
trait Lam<Binder> { type App; }
fn nested_bounds<_0, _1, _2, D>()
where
D: Clone + Iterator<Item: Send + for<'a> Iterator<Item: for<'b> Lam<&'a &'b u8, App = _0>>>,
//~^ ERROR nested quantification of lifetimes [E0316]
_0: Debug,
{}
fn nested_bounds_desugared<_0, _1, _2, D>()
where
D: Clone + Iterator<Item = _2>,
_2: Send + for<'a> Iterator,
for<'a> <_2 as Iterator>::Item: for<'b> Lam<&'a &'b u8, App = _0>,
//~^ ERROR nested quantification of lifetimes [E0316]
_0: Debug,
{}
fn main() {}
@Centril
Copy link
Author

Centril commented Jun 5, 2019

Alternative desugaring that might not error:

fn nested_bounds_desugared<_0, _1, _2, D>()
where
    D: Clone + Iterator<Item = _2>,
    _2: Send + for<'a> Iterator,
    for<'a, 'b> <_2 as Iterator>::Item: Lam<&'a &'b u8, App = _0>,
    //~^ ERROR nested quantification of lifetimes [E0316]
    _0: Debug,
{}

Should we allow nested lifetimes generally in the language e.g. when written explicitly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment