Created
November 24, 2014 22:29
-
-
Save japaric/18749abe5b8a3cfbc798 to your computer and use it in GitHub Desktop.
default_type_params inference failure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(default_type_params)] | |
enum Enum<L = (), R = ()> { | |
Both(L, R), | |
Left(L), | |
Right(R), | |
} | |
fn main() { | |
// I'm expecting the compiler to choose the type `Enum<u8, ()>` here | |
let left = Enum::Left(0u8); | |
//^~ error: unable to infer enough type information about `Enum<u8, _>`; type annotations required | |
// and the type `Enum<(), u8>` here, because `Enum` has default type parameters | |
let right = Enum::Right(0u8); | |
//^~ error: unable to infer enough type information about `Enum<_>`; type annotations required | |
// But instead, I need to hint the default type parameters... | |
let left: Enum<_, ()> = Enum::Left(0u8); // OK | |
let right: Enum<(), _> = Enum::Right(0u8); // OK | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment