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