Add infer for generic default type

This commit is contained in:
Edwin Cheng
2019-05-19 21:08:16 +08:00
parent e74d8f148b
commit d4dc879415
4 changed files with 80 additions and 15 deletions

View File

@@ -1448,6 +1448,35 @@ fn test() {
);
}
#[test]
fn infer_associated_method_generics_with_default_param() {
assert_snapshot_matches!(
infer(r#"
struct Gen<T=u32> {
val: T
}
impl<T> Gen<T> {
pub fn make() -> Gen<T> {
loop { }
}
}
fn test() {
let a = Gen::make();
}
"#),
@r###"
[80; 104) '{ ... }': !
[90; 98) 'loop { }': !
[95; 98) '{ }': ()
[118; 146) '{ ...e(); }': ()
[128; 129) 'a': Gen<u32>
[132; 141) 'Gen::make': fn make<u32>() -> Gen<T>
[132; 143) 'Gen::make()': Gen<u32>"###
);
}
#[test]
fn infer_associated_method_generics_without_args() {
assert_snapshot_matches!(