]> git.lizzy.rs Git - rust.git/blob - tests/ui/never_type/fallback-closure-ret.rs
Rollup merge of #107615 - notriddle:notriddle/nbsp, r=GuillaumeGomez
[rust.git] / tests / ui / never_type / fallback-closure-ret.rs
1 // This test verifies that never type fallback preserves the following code in a
2 // compiling state. This pattern is fairly common in the wild, notably seen in
3 // wasmtime v0.16. Typically this is some closure wrapper that expects a
4 // collection of 'known' signatures, and -> ! is not included in that set.
5 //
6 // This test is specifically targeted by the unit type fallback when
7 // encountering a set of obligations like `?T: Foo` and `Trait::Projection =
8 // ?T`. In the code below, these are `R: Bar` and `Fn::Output = R`.
9 //
10 // revisions: nofallback fallback
11 // check-pass
12
13 #![cfg_attr(fallback, feature(never_type_fallback))]
14
15 trait Bar { }
16 impl Bar for () {  }
17 impl Bar for u32 {  }
18
19 fn foo<R: Bar>(_: impl Fn() -> R) {}
20
21 fn main() {
22     foo(|| panic!());
23 }