Default type parameter not inferred: is it a bug?



I just started using Rust this week. I’m coming from C++ and C# and Rust seems to do so many things better.

I tried to compile this program, but I get an error saying it can’t infer the type:

use std::ops::*;

fn asd<T, T2 = f32>(x: T, y: T) -> T::Output
    where T : Add
    x + y

fn main()
    asd(1, 2);

src/ 15:8 error: unable to infer enough type information about `_`; type annotations or generic parameter binding required [E0282]
src/     asd(1, 2);

I’ve specified the default for T2, so I think it should compile fine.
What am I doing wrong?


Nothing (except that T2 is currently useless). This hasn’t been fully implemented:


It’s a coming feature.

#4 suggests that it works on nightly when using #![feature(default_type_parameter_fallback)].


Okey, thanks.

I just made a simple example, it’s not indended to do anything useful.