diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs index 006101f2f7c..25c894c9597 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 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::>(); - 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. diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs index b08355227d1..3803f5938cf 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() { "#), @r###" [76; 184) '{ ...one; }': () - [82; 83) 'A': A(T) -> A + [82; 83) 'A': A(i32) -> A [82; 87) 'A(42)': A [84; 86) '42': i32 - [93; 94) 'A': A(T) -> A + [93; 94) 'A': A(u128) -> A [93; 102) 'A(42u128)': A [95; 101) '42u128': u128 - [108; 112) 'Some': Some<&str>(T) -> Option + [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 + [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}> diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index eae6e96816c..9ff396ad568 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() { [173; 175) '{}': () [189; 308) '{ ... 1); }': () [199; 200) 'x': Option - [203; 215) 'Option::Some': Some(T) -> Option + [203; 215) 'Option::Some': Some(u32) -> Option [203; 221) 'Option...(1u32)': Option [216; 220) '1u32': u32 [227; 228) 'x': Option