mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
More symbol usage
This commit is contained in:
parent
c30bdfcc84
commit
df5f1777b8
50 changed files with 388 additions and 303 deletions
|
@ -519,7 +519,7 @@ impl CompletionContext<'_> {
|
|||
I: hir::HasAttrs + Copy,
|
||||
{
|
||||
let attrs = item.attrs(self.db);
|
||||
attrs.doc_aliases().collect()
|
||||
attrs.doc_aliases().map(|it| it.as_str().into()).collect()
|
||||
}
|
||||
|
||||
/// Check if an item is `#[doc(hidden)]`.
|
||||
|
@ -543,7 +543,7 @@ impl CompletionContext<'_> {
|
|||
/// Whether the given trait is an operator trait or not.
|
||||
pub(crate) fn is_ops_trait(&self, trait_: hir::Trait) -> bool {
|
||||
match trait_.attrs(self.db).lang() {
|
||||
Some(lang) => OP_TRAIT_LANG_NAMES.contains(&lang),
|
||||
Some(lang) => OP_TRAIT_LANG_NAMES.contains(&lang.as_str()),
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
@ -643,7 +643,7 @@ impl CompletionContext<'_> {
|
|||
|
||||
pub(crate) fn doc_aliases_in_scope(&self, scope_def: ScopeDef) -> Vec<SmolStr> {
|
||||
if let Some(attrs) = scope_def.attrs(self.db) {
|
||||
attrs.doc_aliases().collect()
|
||||
attrs.doc_aliases().map(|it| it.as_str().into()).collect()
|
||||
} else {
|
||||
vec![]
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ pub(crate) mod type_alias;
|
|||
pub(crate) mod union_literal;
|
||||
pub(crate) mod variant;
|
||||
|
||||
use hir::{AsAssocItem, HasAttrs, HirDisplay, ImportPathConfig, ModuleDef, ScopeDef, Type};
|
||||
use hir::{sym, AsAssocItem, HasAttrs, HirDisplay, ImportPathConfig, ModuleDef, ScopeDef, Type};
|
||||
use ide_db::{
|
||||
documentation::{Documentation, HasDocs},
|
||||
helpers::item_name,
|
||||
|
@ -95,7 +95,7 @@ impl<'a> RenderContext<'a> {
|
|||
|
||||
fn is_deprecated(&self, def: impl HasAttrs) -> bool {
|
||||
let attrs = def.attrs(self.db());
|
||||
attrs.by_key("deprecated").exists()
|
||||
attrs.by_key(&sym::deprecated).exists()
|
||||
}
|
||||
|
||||
fn is_deprecated_assoc_item(&self, as_assoc_item: impl AsAssocItem) -> bool {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Code common to structs, unions, and enum variants.
|
||||
|
||||
use crate::context::CompletionContext;
|
||||
use hir::{db::HirDatabase, HasAttrs, HasCrate, HasVisibility, HirDisplay, StructKind};
|
||||
use hir::{db::HirDatabase, sym, HasAttrs, HasCrate, HasVisibility, HirDisplay, StructKind};
|
||||
use ide_db::SnippetCap;
|
||||
use itertools::Itertools;
|
||||
use syntax::SmolStr;
|
||||
|
@ -86,7 +86,7 @@ pub(crate) fn visible_fields(
|
|||
.copied()
|
||||
.collect::<Vec<_>>();
|
||||
let has_invisible_field = n_fields - fields.len() > 0;
|
||||
let is_foreign_non_exhaustive = item.attrs(ctx.db).by_key("non_exhaustive").exists()
|
||||
let is_foreign_non_exhaustive = item.attrs(ctx.db).by_key(&sym::non_exhaustive).exists()
|
||||
&& item.krate(ctx.db) != module.krate();
|
||||
let fields_omitted = has_invisible_field || is_foreign_non_exhaustive;
|
||||
Some((fields, fields_omitted))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue