Closed
Description
trait Foo {}
impl Foo for () {}
impl Foo for i32 {}
struct Error;
impl Error {
fn foo(&self) -> ! { loop {} }
}
fn bar<T: Foo>() -> Result<T, Error> { loop {} }
fn main() {
// what type does `_` have? is it `()` or is it `i32`?
let _ = bar().unwrap_or_else(|e| e.foo());
}
This code compiles, but I find it somewhat surprising as I have no type annotations on _
so the compiler shouldn't know what type it is (I presume it selects one of ()
or i32
perhaps).
This issue is motivated by docopt/docopt.rs#89 and isn't necessarily a bug per se, but it does seem somewhat surprising so I just want to make sure it is intended.