mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
Auto merge of #13053 - lowr:fix/pat-sole-Self, r=Veykril
fix: resolve path `Self` alone in value namespace Fixes #12968
This commit is contained in:
commit
0a33d04a3d
2 changed files with 37 additions and 0 deletions
|
@ -734,6 +734,7 @@ impl<'a> InferenceContext<'a> {
|
||||||
let ty = self.insert_type_vars(ty.substitute(Interner, &substs));
|
let ty = self.insert_type_vars(ty.substitute(Interner, &substs));
|
||||||
return (ty, Some(strukt.into()));
|
return (ty, Some(strukt.into()));
|
||||||
}
|
}
|
||||||
|
ValueNs::ImplSelf(impl_id) => (TypeNs::SelfType(impl_id), None),
|
||||||
_ => return (self.err_ty(), None),
|
_ => return (self.err_ty(), None),
|
||||||
},
|
},
|
||||||
Some(ResolveValueResult::Partial(typens, unresolved)) => (typens, Some(unresolved)),
|
Some(ResolveValueResult::Partial(typens, unresolved)) => (typens, Some(unresolved)),
|
||||||
|
|
|
@ -488,6 +488,42 @@ fn infer_adt_pattern() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn tuple_struct_destructured_with_self() {
|
||||||
|
check_infer(
|
||||||
|
r#"
|
||||||
|
struct Foo(usize,);
|
||||||
|
impl Foo {
|
||||||
|
fn f() {
|
||||||
|
let Self(s,) = &Foo(0,);
|
||||||
|
let Self(s,) = &mut Foo(0,);
|
||||||
|
let Self(s,) = Foo(0,);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
42..151 '{ ... }': ()
|
||||||
|
56..64 'Self(s,)': Foo
|
||||||
|
61..62 's': &usize
|
||||||
|
67..75 '&Foo(0,)': &Foo
|
||||||
|
68..71 'Foo': Foo(usize) -> Foo
|
||||||
|
68..75 'Foo(0,)': Foo
|
||||||
|
72..73 '0': usize
|
||||||
|
89..97 'Self(s,)': Foo
|
||||||
|
94..95 's': &mut usize
|
||||||
|
100..112 '&mut Foo(0,)': &mut Foo
|
||||||
|
105..108 'Foo': Foo(usize) -> Foo
|
||||||
|
105..112 'Foo(0,)': Foo
|
||||||
|
109..110 '0': usize
|
||||||
|
126..134 'Self(s,)': Foo
|
||||||
|
131..132 's': usize
|
||||||
|
137..140 'Foo': Foo(usize) -> Foo
|
||||||
|
137..144 'Foo(0,)': Foo
|
||||||
|
141..142 '0': usize
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn enum_variant_through_self_in_pattern() {
|
fn enum_variant_through_self_in_pattern() {
|
||||||
check_infer(
|
check_infer(
|
||||||
|
|
Loading…
Reference in a new issue