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 
produce<T>() -> Result<&'static str, T>11 fn produce<T>() -> Result<&'static str, T> {
12     Ok("22")
13 }
14 
main()15 fn main() {
16     let x: usize = produce()
17         .and_then(|x| x.parse())
18         .unwrap_or_else(|_| panic!());
19     println!("{}", x);
20 }
21