Skip to content

Commit 6654055

Browse files
bors[bot]Speedy37
andauthored
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>
2 parents 90a5c46 + c95bb0b commit 6654055

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

crates/ra_hir_ty/src/infer/path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl<'a> InferenceContext<'a> {
8181
let generics = crate::utils::generics(self.db.upcast(), impl_id.into());
8282
let substs = Substs::type_params_for_generics(&generics);
8383
let ty = self.db.impl_self_ty(impl_id).subst(&substs);
84-
if let Some((AdtId::StructId(struct_id), _)) = ty.as_adt() {
84+
if let Some((AdtId::StructId(struct_id), substs)) = ty.as_adt() {
8585
let ty = self.db.value_ty(struct_id.into()).subst(&substs);
8686
return Some(ty);
8787
} else {

crates/ra_hir_ty/src/tests/regression.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,3 +633,35 @@ where
633633
"###
634634
);
635635
}
636+
637+
#[test]
638+
fn issue_4953() {
639+
assert_snapshot!(
640+
infer(r#"
641+
pub struct Foo(pub i64);
642+
impl Foo {
643+
fn test() -> Self { Self(0i64) }
644+
}
645+
"#),
646+
@r###"
647+
59..73 '{ Self(0i64) }': Foo
648+
61..65 'Self': Foo(i64) -> Foo
649+
61..71 'Self(0i64)': Foo
650+
66..70 '0i64': i64
651+
"###
652+
);
653+
assert_snapshot!(
654+
infer(r#"
655+
pub struct Foo<T>(pub T);
656+
impl Foo<i64> {
657+
fn test() -> Self { Self(0i64) }
658+
}
659+
"#),
660+
@r###"
661+
65..79 '{ Self(0i64) }': Foo<i64>
662+
67..71 'Self': Foo<i64>(i64) -> Foo<i64>
663+
67..77 'Self(0i64)': Foo<i64>
664+
72..76 '0i64': i64
665+
"###
666+
);
667+
}

0 commit comments

Comments
 (0)