2024-02-16 20:02:50 +00:00
|
|
|
//@ run-pass
|
2019-07-26 21:54:25 +00:00
|
|
|
|
2018-09-14 10:20:28 +00:00
|
|
|
#![allow(unused_imports)]
|
2017-03-17 18:10:00 +00: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 17:22:34 +00:00
|
|
|
|
2017-03-17 18:10:00 +00:00
|
|
|
use std::num::ParseIntError;
|
2016-08-11 09:06:39 +00:00
|
|
|
|
2017-03-17 18:10:00 +00:00
|
|
|
fn produce<T>() -> Result<&'static str, T> {
|
|
|
|
Ok("22")
|
2016-08-11 09:06:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2017-03-17 18:10:00 +00:00
|
|
|
let x: usize = produce()
|
|
|
|
.and_then(|x| x.parse())
|
|
|
|
.unwrap_or_else(|_| panic!());
|
|
|
|
println!("{}", x);
|
2016-08-11 09:06:39 +00:00
|
|
|
}
|