mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Merge #11753
11753: feat: Complete assoc const patterns on builtin types r=jonas-schievink a=jonas-schievink followup to https://github.com/rust-analyzer/rust-analyzer/pull/11713 bors r+ Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
This commit is contained in:
commit
97c7321cfa
2 changed files with 28 additions and 3 deletions
|
@ -141,7 +141,8 @@ fn pattern_path_completion(
|
||||||
| hir::PathResolution::SelfType(_)
|
| hir::PathResolution::SelfType(_)
|
||||||
| hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Struct(_)))
|
| hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Struct(_)))
|
||||||
| hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Enum(_)))
|
| hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Enum(_)))
|
||||||
| hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Union(_)))) => {
|
| hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Union(_)))
|
||||||
|
| hir::PathResolution::Def(hir::ModuleDef::BuiltinType(_))) => {
|
||||||
let ty = match res {
|
let ty = match res {
|
||||||
hir::PathResolution::TypeParam(param) => param.ty(ctx.db),
|
hir::PathResolution::TypeParam(param) => param.ty(ctx.db),
|
||||||
hir::PathResolution::SelfType(impl_def) => impl_def.self_ty(ctx.db),
|
hir::PathResolution::SelfType(impl_def) => impl_def.self_ty(ctx.db),
|
||||||
|
@ -158,6 +159,13 @@ fn pattern_path_completion(
|
||||||
hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Union(u))) => {
|
hir::PathResolution::Def(hir::ModuleDef::Adt(hir::Adt::Union(u))) => {
|
||||||
u.ty(ctx.db)
|
u.ty(ctx.db)
|
||||||
}
|
}
|
||||||
|
hir::PathResolution::Def(hir::ModuleDef::BuiltinType(ty)) => {
|
||||||
|
let module = match ctx.module {
|
||||||
|
Some(m) => m,
|
||||||
|
None => return,
|
||||||
|
};
|
||||||
|
ty.ty(ctx.db, module)
|
||||||
|
}
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -493,7 +493,6 @@ fn f(e: MyEnum) {
|
||||||
|
|
||||||
check_empty(
|
check_empty(
|
||||||
r#"
|
r#"
|
||||||
#[repr(C)]
|
|
||||||
union U {
|
union U {
|
||||||
i: i32,
|
i: i32,
|
||||||
f: f32,
|
f: f32,
|
||||||
|
@ -515,5 +514,23 @@ fn f(u: U) {
|
||||||
ct C pub const C: i32
|
ct C pub const C: i32
|
||||||
ct D pub const D: i32
|
ct D pub const D: i32
|
||||||
"#]],
|
"#]],
|
||||||
)
|
);
|
||||||
|
|
||||||
|
check_empty(
|
||||||
|
r#"
|
||||||
|
#[lang = "u32"]
|
||||||
|
impl u32 {
|
||||||
|
pub const MIN: Self = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn f(v: u32) {
|
||||||
|
match v {
|
||||||
|
u32::$0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
ct MIN pub const MIN: Self
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue