Fix enum constructors
This commit is contained in:
parent
4789a993eb
commit
a5554dcb17
@ -729,14 +729,12 @@ fn fn_sig_for_enum_variant_constructor(db: &impl HirDatabase, def: EnumVariantId
|
||||
let var_data = &enum_data.variants[def.local_id];
|
||||
let fields = var_data.variant_data.fields();
|
||||
let resolver = def.parent.resolver(db);
|
||||
let ctx = TyLoweringContext::new(db, &resolver);
|
||||
let ctx = TyLoweringContext::new(db, &resolver)
|
||||
.with_type_param_mode(TypeParamLoweringMode::Variable);
|
||||
let params =
|
||||
fields.iter().map(|(_, field)| Ty::from_hir(&ctx, &field.type_ref)).collect::<Vec<_>>();
|
||||
let generics = generics(db, def.parent.into());
|
||||
let substs = Substs::bound_vars(&generics);
|
||||
let ret = type_for_adt(db, def.parent.into()).subst(&substs);
|
||||
let num_binders = generics.len();
|
||||
Binders::new(num_binders, FnSig::from_params_and_return(params, ret))
|
||||
let ret = type_for_adt(db, def.parent.into());
|
||||
Binders::new(ret.num_binders, FnSig::from_params_and_return(params, ret.value))
|
||||
}
|
||||
|
||||
/// Build the type of a tuple enum variant constructor.
|
||||
|
@ -1169,16 +1169,16 @@ fn test() {
|
||||
"#),
|
||||
@r###"
|
||||
[76; 184) '{ ...one; }': ()
|
||||
[82; 83) 'A': A<i32>(T) -> A<T>
|
||||
[82; 83) 'A': A<i32>(i32) -> A<i32>
|
||||
[82; 87) 'A(42)': A<i32>
|
||||
[84; 86) '42': i32
|
||||
[93; 94) 'A': A<u128>(T) -> A<T>
|
||||
[93; 94) 'A': A<u128>(u128) -> A<u128>
|
||||
[93; 102) 'A(42u128)': A<u128>
|
||||
[95; 101) '42u128': u128
|
||||
[108; 112) 'Some': Some<&str>(T) -> Option<T>
|
||||
[108; 112) 'Some': Some<&str>(&str) -> Option<&str>
|
||||
[108; 117) 'Some("x")': Option<&str>
|
||||
[113; 116) '"x"': &str
|
||||
[123; 135) 'Option::Some': Some<&str>(T) -> Option<T>
|
||||
[123; 135) 'Option::Some': Some<&str>(&str) -> Option<&str>
|
||||
[123; 140) 'Option...e("x")': Option<&str>
|
||||
[136; 139) '"x"': &str
|
||||
[146; 150) 'None': Option<{unknown}>
|
||||
|
@ -1322,7 +1322,7 @@ fn test() {
|
||||
[173; 175) '{}': ()
|
||||
[189; 308) '{ ... 1); }': ()
|
||||
[199; 200) 'x': Option<u32>
|
||||
[203; 215) 'Option::Some': Some<u32>(T) -> Option<T>
|
||||
[203; 215) 'Option::Some': Some<u32>(u32) -> Option<u32>
|
||||
[203; 221) 'Option...(1u32)': Option<u32>
|
||||
[216; 220) '1u32': u32
|
||||
[227; 228) 'x': Option<u32>
|
||||
|
Loading…
Reference in New Issue
Block a user