mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
unqualfied_path completions aren't responsible for pattern completions
This commit is contained in:
parent
5f6d71cf0c
commit
4a0ab832f3
3 changed files with 120 additions and 120 deletions
|
@ -6,24 +6,6 @@ use itertools::Itertools;
|
|||
|
||||
use crate::{item::CompletionKind, render::RenderContext, CompletionItem, CompletionItemKind};
|
||||
|
||||
fn visible_fields(
|
||||
ctx: &RenderContext<'_>,
|
||||
fields: &[hir::Field],
|
||||
item: impl HasAttrs,
|
||||
) -> Option<(Vec<hir::Field>, bool)> {
|
||||
let module = ctx.completion.scope.module()?;
|
||||
let n_fields = fields.len();
|
||||
let fields = fields
|
||||
.into_iter()
|
||||
.filter(|field| field.is_visible_from(ctx.db(), module))
|
||||
.copied()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let fields_omitted =
|
||||
n_fields - fields.len() > 0 || item.attrs(ctx.db()).by_key("non_exhaustive").exists();
|
||||
Some((fields, fields_omitted))
|
||||
}
|
||||
|
||||
pub(crate) fn render_struct_pat(
|
||||
ctx: RenderContext<'_>,
|
||||
strukt: hir::Struct,
|
||||
|
@ -148,3 +130,21 @@ fn render_tuple_as_pat(fields: &[hir::Field], name: &str, fields_omitted: bool)
|
|||
name = name
|
||||
)
|
||||
}
|
||||
|
||||
fn visible_fields(
|
||||
ctx: &RenderContext<'_>,
|
||||
fields: &[hir::Field],
|
||||
item: impl HasAttrs,
|
||||
) -> Option<(Vec<hir::Field>, bool)> {
|
||||
let module = ctx.completion.scope.module()?;
|
||||
let n_fields = fields.len();
|
||||
let fields = fields
|
||||
.into_iter()
|
||||
.filter(|field| field.is_visible_from(ctx.db(), module))
|
||||
.copied()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let fields_omitted =
|
||||
n_fields - fields.len() > 0 || item.attrs(ctx.db()).by_key("non_exhaustive").exists();
|
||||
Some((fields, fields_omitted))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue