Merge #4957
4957: Fix substs in resolve_value_path for ImplSelf r=flodiebold a=Speedy37 Fixes #4953. This is the first fix I do in hir_ty, I hope I got it right :) Co-authored-by: Vincent Rouillé <vincent@speedy37.fr>
This commit is contained in:
commit
6654055308
crates/ra_hir_ty/src
@ -81,7 +81,7 @@ impl<'a> InferenceContext<'a> {
|
||||
let generics = crate::utils::generics(self.db.upcast(), impl_id.into());
|
||||
let substs = Substs::type_params_for_generics(&generics);
|
||||
let ty = self.db.impl_self_ty(impl_id).subst(&substs);
|
||||
if let Some((AdtId::StructId(struct_id), _)) = ty.as_adt() {
|
||||
if let Some((AdtId::StructId(struct_id), substs)) = ty.as_adt() {
|
||||
let ty = self.db.value_ty(struct_id.into()).subst(&substs);
|
||||
return Some(ty);
|
||||
} else {
|
||||
|
@ -633,3 +633,35 @@ where
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_4953() {
|
||||
assert_snapshot!(
|
||||
infer(r#"
|
||||
pub struct Foo(pub i64);
|
||||
impl Foo {
|
||||
fn test() -> Self { Self(0i64) }
|
||||
}
|
||||
"#),
|
||||
@r###"
|
||||
59..73 '{ Self(0i64) }': Foo
|
||||
61..65 'Self': Foo(i64) -> Foo
|
||||
61..71 'Self(0i64)': Foo
|
||||
66..70 '0i64': i64
|
||||
"###
|
||||
);
|
||||
assert_snapshot!(
|
||||
infer(r#"
|
||||
pub struct Foo<T>(pub T);
|
||||
impl Foo<i64> {
|
||||
fn test() -> Self { Self(0i64) }
|
||||
}
|
||||
"#),
|
||||
@r###"
|
||||
65..79 '{ Self(0i64) }': Foo<i64>
|
||||
67..71 'Self': Foo<i64>(i64) -> Foo<i64>
|
||||
67..77 'Self(0i64)': Foo<i64>
|
||||
72..76 '0i64': i64
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user