diff options
author | Florian Diebold <[email protected]> | 2020-01-29 20:30:24 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2020-02-07 17:28:10 +0000 |
commit | a5554dcb17defd2cda729ce0ae732062990391db (patch) | |
tree | cf026e1d434840960343747132dd54612e679037 /crates/ra_hir_ty/src | |
parent | 4789a993eb26963a2411dcc3041733a3b034634a (diff) |
Fix enum constructors
Diffstat (limited to 'crates/ra_hir_ty/src')
-rw-r--r-- | crates/ra_hir_ty/src/lower.rs | 10 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/tests/simple.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/tests/traits.rs | 2 |
3 files changed, 9 insertions, 11 deletions
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs index 006101f2f..25c894c95 100644 --- a/crates/ra_hir_ty/src/lower.rs +++ b/crates/ra_hir_ty/src/lower.rs | |||
@@ -729,14 +729,12 @@ fn fn_sig_for_enum_variant_constructor(db: &impl HirDatabase, def: EnumVariantId | |||
729 | let var_data = &enum_data.variants[def.local_id]; | 729 | let var_data = &enum_data.variants[def.local_id]; |
730 | let fields = var_data.variant_data.fields(); | 730 | let fields = var_data.variant_data.fields(); |
731 | let resolver = def.parent.resolver(db); | 731 | let resolver = def.parent.resolver(db); |
732 | let ctx = TyLoweringContext::new(db, &resolver); | 732 | let ctx = TyLoweringContext::new(db, &resolver) |
733 | .with_type_param_mode(TypeParamLoweringMode::Variable); | ||
733 | let params = | 734 | let params = |
734 | fields.iter().map(|(_, field)| Ty::from_hir(&ctx, &field.type_ref)).collect::<Vec<_>>(); | 735 | fields.iter().map(|(_, field)| Ty::from_hir(&ctx, &field.type_ref)).collect::<Vec<_>>(); |
735 | let generics = generics(db, def.parent.into()); | 736 | let ret = type_for_adt(db, def.parent.into()); |
736 | let substs = Substs::bound_vars(&generics); | 737 | Binders::new(ret.num_binders, FnSig::from_params_and_return(params, ret.value)) |
737 | let ret = type_for_adt(db, def.parent.into()).subst(&substs); | ||
738 | let num_binders = generics.len(); | ||
739 | Binders::new(num_binders, FnSig::from_params_and_return(params, ret)) | ||
740 | } | 738 | } |
741 | 739 | ||
742 | /// Build the type of a tuple enum variant constructor. | 740 | /// Build the type of a tuple enum variant constructor. |
diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs index b08355227..3803f5938 100644 --- a/crates/ra_hir_ty/src/tests/simple.rs +++ b/crates/ra_hir_ty/src/tests/simple.rs | |||
@@ -1169,16 +1169,16 @@ fn test() { | |||
1169 | "#), | 1169 | "#), |
1170 | @r###" | 1170 | @r###" |
1171 | [76; 184) '{ ...one; }': () | 1171 | [76; 184) '{ ...one; }': () |
1172 | [82; 83) 'A': A<i32>(T) -> A<T> | 1172 | [82; 83) 'A': A<i32>(i32) -> A<i32> |
1173 | [82; 87) 'A(42)': A<i32> | 1173 | [82; 87) 'A(42)': A<i32> |
1174 | [84; 86) '42': i32 | 1174 | [84; 86) '42': i32 |
1175 | [93; 94) 'A': A<u128>(T) -> A<T> | 1175 | [93; 94) 'A': A<u128>(u128) -> A<u128> |
1176 | [93; 102) 'A(42u128)': A<u128> | 1176 | [93; 102) 'A(42u128)': A<u128> |
1177 | [95; 101) '42u128': u128 | 1177 | [95; 101) '42u128': u128 |
1178 | [108; 112) 'Some': Some<&str>(T) -> Option<T> | 1178 | [108; 112) 'Some': Some<&str>(&str) -> Option<&str> |
1179 | [108; 117) 'Some("x")': Option<&str> | 1179 | [108; 117) 'Some("x")': Option<&str> |
1180 | [113; 116) '"x"': &str | 1180 | [113; 116) '"x"': &str |
1181 | [123; 135) 'Option::Some': Some<&str>(T) -> Option<T> | 1181 | [123; 135) 'Option::Some': Some<&str>(&str) -> Option<&str> |
1182 | [123; 140) 'Option...e("x")': Option<&str> | 1182 | [123; 140) 'Option...e("x")': Option<&str> |
1183 | [136; 139) '"x"': &str | 1183 | [136; 139) '"x"': &str |
1184 | [146; 150) 'None': Option<{unknown}> | 1184 | [146; 150) 'None': Option<{unknown}> |
diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index eae6e9681..9ff396ad5 100644 --- a/crates/ra_hir_ty/src/tests/traits.rs +++ b/crates/ra_hir_ty/src/tests/traits.rs | |||
@@ -1322,7 +1322,7 @@ fn test() { | |||
1322 | [173; 175) '{}': () | 1322 | [173; 175) '{}': () |
1323 | [189; 308) '{ ... 1); }': () | 1323 | [189; 308) '{ ... 1); }': () |
1324 | [199; 200) 'x': Option<u32> | 1324 | [199; 200) 'x': Option<u32> |
1325 | [203; 215) 'Option::Some': Some<u32>(T) -> Option<T> | 1325 | [203; 215) 'Option::Some': Some<u32>(u32) -> Option<u32> |
1326 | [203; 221) 'Option...(1u32)': Option<u32> | 1326 | [203; 221) 'Option...(1u32)': Option<u32> |
1327 | [216; 220) '1u32': u32 | 1327 | [216; 220) '1u32': u32 |
1328 | [227; 228) 'x': Option<u32> | 1328 | [227; 228) 'x': Option<u32> |