summaryrefslogtreecommitdiffstats
path: root/src/test/ui/diverging-fallback-method-chain.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/diverging-fallback-method-chain.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/ui/diverging-fallback-method-chain.rs b/src/test/ui/diverging-fallback-method-chain.rs
new file mode 100644
index 000000000..ba9f05c64
--- /dev/null
+++ b/src/test/ui/diverging-fallback-method-chain.rs
@@ -0,0 +1,20 @@
+// run-pass
+
+#![allow(unused_imports)]
+// 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`.
+
+use std::num::ParseIntError;
+
+fn produce<T>() -> Result<&'static str, T> {
+ Ok("22")
+}
+
+fn main() {
+ let x: usize = produce()
+ .and_then(|x| x.parse())
+ .unwrap_or_else(|_| panic!());
+ println!("{}", x);
+}