//! Test type inference in method chains with diverging fallback. //! Verifies that closure type in `unwrap_or_else` is properly inferred //! when chained with other combinators and contains a diverging path. //@ run-pass fn produce() -> Result<&'static str, T> { Ok("22") } fn main() { // The closure's error type `T` must unify with `ParseIntError`, // while the success type must be `usize` (from parse()) let x: usize = produce() .and_then(|x| x.parse::()) // Explicit turbofish for clarity .unwrap_or_else(|_| panic!()); // Diverging fallback assert_eq!(x, 22); }