]> git.lizzy.rs Git - rust.git/blob - src/test/ui/diverging-fallback-method-chain.rs
Rollup merge of #105983 - compiler-errors:issue-105981, r=tmiasko
[rust.git] / src / test / ui / diverging-fallback-method-chain.rs
1 // run-pass
2
3 #![allow(unused_imports)]
4 // Test a regression found when building compiler. The `produce()`
5 // error type `T` winds up getting unified with result of `x.parse()`;
6 // the type of the closure given to `unwrap_or_else` needs to be
7 // inferred to `usize`.
8
9 use std::num::ParseIntError;
10
11 fn produce<T>() -> Result<&'static str, T> {
12     Ok("22")
13 }
14
15 fn main() {
16     let x: usize = produce()
17         .and_then(|x| x.parse())
18         .unwrap_or_else(|_| panic!());
19     println!("{}", x);
20 }