2023-01-15 16:31:58 -06:00
|
|
|
// Nested impl-traits can impose different member constraints on the same region variable.
|
|
|
|
|
|
|
|
// check-pass
|
|
|
|
|
|
|
|
trait Cap<'a> {}
|
|
|
|
impl<T> Cap<'_> for T {}
|
|
|
|
|
2023-04-21 19:08:38 -05:00
|
|
|
// Assuming the hidden type is `[&'?15 u8; 1]`, we have two distinct member constraints:
|
|
|
|
// - '?15 member ['static, 'a, 'b] // from outer impl-trait
|
|
|
|
// - '?15 member ['static, 'a] // from inner impl-trait
|
2023-01-15 16:31:58 -06:00
|
|
|
// To satisfy both we can only choose 'a.
|
|
|
|
fn pass_early_bound<'s, 'a, 'b>(a: &'s u8) -> impl IntoIterator<Item = impl Cap<'a>> + Cap<'b>
|
|
|
|
where
|
|
|
|
's: 'a,
|
|
|
|
's: 'b,
|
|
|
|
{
|
|
|
|
[a]
|
|
|
|
}
|
|
|
|
|
|
|
|
// Same as the above but with late-bound regions.
|
|
|
|
fn pass_late_bound<'s, 'a, 'b>(
|
|
|
|
a: &'s u8,
|
|
|
|
_: &'a &'s u8,
|
|
|
|
_: &'b &'s u8,
|
|
|
|
) -> impl IntoIterator<Item = impl Cap<'a>> + Cap<'b> {
|
|
|
|
[a]
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|