about summary refs log tree commit diff
path: root/tests/ui/traits/next-solver/opaques/overflow-hr-fn-trait-sized-1.rs
blob: e35e48dfcecbdf27d1c0ae1931eded995a75d682 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//@ ignore-compare-mode-next-solver
//@ compile-flags: -Znext-solver
//@ check-pass

// Regression test for trait-system-refactor-initiative#220. Builtin `Fn`-trait
// candidates required `for<'latebound> Output<'latebound>: Sized` which ended
// up resulting in overflow if the return type is an opaque in the defining scope.
//
// We now eagerly instantiate the binder of the function definition which avoids
// that overflow by relating the lifetime of the opaque to something from the
// input.
fn flat_map<T, F, I, G>(_: F, _: G)
where
    F: FnOnce(T) -> I,
    I: Iterator,
    G: Fn(<I as Iterator>::Item) -> usize,
{
}

fn rarw<'a>(_: &'a ()) -> impl Iterator<Item = &'a str> {
    flat_map(rarw, |x| x.len());
    std::iter::empty()
}

fn main() {}