2019-07-26 16:54:25 -05:00
|
|
|
//@ run-pass
|
|
|
|
|
2018-09-14 05:20:28 -05:00
|
|
|
#![allow(unused_imports)]
|
2017-03-17 13:10:00 -05:00
|
|
|
// Test a regression found when building compiler. The `produce()`
|
|
|
|
// error type `T` winds up getting unified with result of `x.parse()`;
|
|
|
|
// the type of the closure given to `unwrap_or_else` needs to be
|
|
|
|
// inferred to `usize`.
|
2016-08-11 12:22:34 -05:00
|
|
|
|
2017-03-17 13:10:00 -05:00
|
|
|
use std::num::ParseIntError;
|
2016-08-11 04:06:39 -05:00
|
|
|
|
2017-03-17 13:10:00 -05:00
|
|
|
fn produce<T>() -> Result<&'static str, T> {
|
|
|
|
Ok("22")
|
2016-08-11 04:06:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2017-03-17 13:10:00 -05:00
|
|
|
let x: usize = produce()
|
|
|
|
.and_then(|x| x.parse())
|
|
|
|
.unwrap_or_else(|_| panic!());
|
|
|
|
println!("{}", x);
|
2016-08-11 04:06:39 -05:00
|
|
|
}
|