mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-28 10:39:45 +00:00
fix: Do not show safety hints for extern items lacking semantics
This commit is contained in:
parent
8aa4ae5e69
commit
e0814742f0
10 changed files with 97 additions and 31 deletions
|
|
@ -31,9 +31,9 @@ pub mod keys {
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
dyn_map::{DynMap, Policy},
|
dyn_map::{DynMap, Policy},
|
||||||
BlockId, ConstId, EnumId, EnumVariantId, ExternCrateId, FieldId, FunctionId, ImplId,
|
BlockId, ConstId, EnumId, EnumVariantId, ExternBlockId, ExternCrateId, FieldId, FunctionId,
|
||||||
LifetimeParamId, Macro2Id, MacroRulesId, ProcMacroId, StaticId, StructId, TraitAliasId,
|
ImplId, LifetimeParamId, Macro2Id, MacroRulesId, ProcMacroId, StaticId, StructId,
|
||||||
TraitId, TypeAliasId, TypeOrConstParamId, UnionId, UseId,
|
TraitAliasId, TraitId, TypeAliasId, TypeOrConstParamId, UnionId, UseId,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub type Key<K, V> = crate::dyn_map::Key<AstPtr<K>, V, AstPtrPolicy<K, V>>;
|
pub type Key<K, V> = crate::dyn_map::Key<AstPtr<K>, V, AstPtrPolicy<K, V>>;
|
||||||
|
|
@ -44,6 +44,7 @@ pub mod keys {
|
||||||
pub const STATIC: Key<ast::Static, StaticId> = Key::new();
|
pub const STATIC: Key<ast::Static, StaticId> = Key::new();
|
||||||
pub const TYPE_ALIAS: Key<ast::TypeAlias, TypeAliasId> = Key::new();
|
pub const TYPE_ALIAS: Key<ast::TypeAlias, TypeAliasId> = Key::new();
|
||||||
pub const IMPL: Key<ast::Impl, ImplId> = Key::new();
|
pub const IMPL: Key<ast::Impl, ImplId> = Key::new();
|
||||||
|
pub const EXTERN_BLOCK: Key<ast::ExternBlock, ExternBlockId> = Key::new();
|
||||||
pub const TRAIT: Key<ast::Trait, TraitId> = Key::new();
|
pub const TRAIT: Key<ast::Trait, TraitId> = Key::new();
|
||||||
pub const TRAIT_ALIAS: Key<ast::TraitAlias, TraitAliasId> = Key::new();
|
pub const TRAIT_ALIAS: Key<ast::TraitAlias, TraitAliasId> = Key::new();
|
||||||
pub const STRUCT: Key<ast::Struct, StructId> = Key::new();
|
pub const STRUCT: Key<ast::Struct, StructId> = Key::new();
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ use crate::{
|
||||||
db::DefDatabase,
|
db::DefDatabase,
|
||||||
per_ns::{Item, MacrosItem, PerNs, TypesItem, ValuesItem},
|
per_ns::{Item, MacrosItem, PerNs, TypesItem, ValuesItem},
|
||||||
visibility::{Visibility, VisibilityExplicitness},
|
visibility::{Visibility, VisibilityExplicitness},
|
||||||
AdtId, BuiltinType, ConstId, ExternCrateId, FxIndexMap, HasModule, ImplId, LocalModuleId,
|
AdtId, BuiltinType, ConstId, ExternBlockId, ExternCrateId, FxIndexMap, HasModule, ImplId,
|
||||||
Lookup, MacroId, ModuleDefId, ModuleId, TraitId, UseId,
|
LocalModuleId, Lookup, MacroId, ModuleDefId, ModuleId, TraitId, UseId,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
|
|
@ -158,6 +158,8 @@ pub struct ItemScope {
|
||||||
declarations: Vec<ModuleDefId>,
|
declarations: Vec<ModuleDefId>,
|
||||||
|
|
||||||
impls: Vec<ImplId>,
|
impls: Vec<ImplId>,
|
||||||
|
#[allow(clippy::box_collection)]
|
||||||
|
extern_blocks: Option<Box<Vec<ExternBlockId>>>,
|
||||||
unnamed_consts: Vec<ConstId>,
|
unnamed_consts: Vec<ConstId>,
|
||||||
/// Traits imported via `use Trait as _;`.
|
/// Traits imported via `use Trait as _;`.
|
||||||
unnamed_trait_imports: FxHashMap<TraitId, Item<()>>,
|
unnamed_trait_imports: FxHashMap<TraitId, Item<()>>,
|
||||||
|
|
@ -319,6 +321,10 @@ impl ItemScope {
|
||||||
self.extern_crate_decls.iter().copied()
|
self.extern_crate_decls.iter().copied()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn extern_blocks(&self) -> impl Iterator<Item = ExternBlockId> + '_ {
|
||||||
|
self.extern_blocks.iter().flat_map(|it| it.iter()).copied()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn use_decls(&self) -> impl ExactSizeIterator<Item = UseId> + '_ {
|
pub fn use_decls(&self) -> impl ExactSizeIterator<Item = UseId> + '_ {
|
||||||
self.use_decls.iter().copied()
|
self.use_decls.iter().copied()
|
||||||
}
|
}
|
||||||
|
|
@ -469,6 +475,10 @@ impl ItemScope {
|
||||||
self.impls.push(imp);
|
self.impls.push(imp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn define_extern_block(&mut self, extern_block: ExternBlockId) {
|
||||||
|
self.extern_blocks.get_or_insert_default().push(extern_block);
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn define_extern_crate_decl(&mut self, extern_crate: ExternCrateId) {
|
pub(crate) fn define_extern_crate_decl(&mut self, extern_crate: ExternCrateId) {
|
||||||
self.extern_crate_decls.push(extern_crate);
|
self.extern_crate_decls.push(extern_crate);
|
||||||
}
|
}
|
||||||
|
|
@ -806,7 +816,11 @@ impl ItemScope {
|
||||||
use_imports_types,
|
use_imports_types,
|
||||||
use_imports_macros,
|
use_imports_macros,
|
||||||
macro_invocations,
|
macro_invocations,
|
||||||
|
extern_blocks,
|
||||||
} = self;
|
} = self;
|
||||||
|
if let Some(it) = extern_blocks {
|
||||||
|
it.shrink_to_fit();
|
||||||
|
}
|
||||||
types.shrink_to_fit();
|
types.shrink_to_fit();
|
||||||
values.shrink_to_fit();
|
values.shrink_to_fit();
|
||||||
macros.shrink_to_fit();
|
macros.shrink_to_fit();
|
||||||
|
|
|
||||||
|
|
@ -1759,16 +1759,20 @@ impl ModCollector<'_, '_> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ModItem::ExternBlock(block) => self.collect(
|
ModItem::ExternBlock(block) => {
|
||||||
&self.item_tree[block].children,
|
let extern_block_id = ExternBlockLoc {
|
||||||
ItemContainerId::ExternBlockId(
|
container: module,
|
||||||
ExternBlockLoc {
|
id: ItemTreeId::new(self.tree_id, block),
|
||||||
container: module,
|
}
|
||||||
id: ItemTreeId::new(self.tree_id, block),
|
.intern(db);
|
||||||
}
|
self.def_collector.def_map.modules[self.module_id]
|
||||||
.intern(db),
|
.scope
|
||||||
),
|
.define_extern_block(extern_block_id);
|
||||||
),
|
self.collect(
|
||||||
|
&self.item_tree[block].children,
|
||||||
|
ItemContainerId::ExternBlockId(extern_block_id),
|
||||||
|
)
|
||||||
|
}
|
||||||
ModItem::MacroCall(mac) => self.collect_macro_call(&self.item_tree[mac], container),
|
ModItem::MacroCall(mac) => self.collect_macro_call(&self.item_tree[mac], container),
|
||||||
ModItem::MacroRules(id) => self.collect_macro_rules(id, module),
|
ModItem::MacroRules(id) => self.collect_macro_rules(id, module),
|
||||||
ModItem::Macro2(id) => self.collect_macro_def(id, module),
|
ModItem::Macro2(id) => self.collect_macro_def(id, module),
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ from_id![
|
||||||
(hir_def::LifetimeParamId, crate::LifetimeParam),
|
(hir_def::LifetimeParamId, crate::LifetimeParam),
|
||||||
(hir_def::MacroId, crate::Macro),
|
(hir_def::MacroId, crate::Macro),
|
||||||
(hir_def::ExternCrateId, crate::ExternCrateDecl),
|
(hir_def::ExternCrateId, crate::ExternCrateDecl),
|
||||||
|
(hir_def::ExternBlockId, crate::ExternBlock),
|
||||||
];
|
];
|
||||||
|
|
||||||
impl From<AdtId> for Adt {
|
impl From<AdtId> for Adt {
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,8 @@ use hir_def::{
|
||||||
resolver::{HasResolver, Resolver},
|
resolver::{HasResolver, Resolver},
|
||||||
type_ref::TypesSourceMap,
|
type_ref::TypesSourceMap,
|
||||||
AdtId, AssocItemId, AssocItemLoc, AttrDefId, CallableDefId, ConstId, ConstParamId,
|
AdtId, AssocItemId, AssocItemLoc, AttrDefId, CallableDefId, ConstId, ConstParamId,
|
||||||
CrateRootModuleId, DefWithBodyId, EnumId, EnumVariantId, ExternCrateId, FunctionId,
|
CrateRootModuleId, DefWithBodyId, EnumId, EnumVariantId, ExternBlockId, ExternCrateId,
|
||||||
GenericDefId, GenericParamId, HasModule, ImplId, InTypeConstId, ItemContainerId,
|
FunctionId, GenericDefId, GenericParamId, HasModule, ImplId, InTypeConstId, ItemContainerId,
|
||||||
LifetimeParamId, LocalFieldId, Lookup, MacroExpander, MacroId, ModuleId, StaticId, StructId,
|
LifetimeParamId, LocalFieldId, Lookup, MacroExpander, MacroId, ModuleId, StaticId, StructId,
|
||||||
SyntheticSyntax, TraitAliasId, TupleId, TypeAliasId, TypeOrConstParamId, TypeParamId, UnionId,
|
SyntheticSyntax, TraitAliasId, TupleId, TypeAliasId, TypeOrConstParamId, TypeParamId, UnionId,
|
||||||
};
|
};
|
||||||
|
|
@ -2327,6 +2327,13 @@ impl Function {
|
||||||
db.function_data(self.id).is_async()
|
db.function_data(self.id).is_async()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn extern_block(self, db: &dyn HirDatabase) -> Option<ExternBlock> {
|
||||||
|
match self.id.lookup(db.upcast()).container {
|
||||||
|
ItemContainerId::ExternBlockId(id) => Some(ExternBlock { id }),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn returns_impl_future(self, db: &dyn HirDatabase) -> bool {
|
pub fn returns_impl_future(self, db: &dyn HirDatabase) -> bool {
|
||||||
if self.is_async(db) {
|
if self.is_async(db) {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -2761,6 +2768,13 @@ impl Static {
|
||||||
Type::from_value_def(db, self.id)
|
Type::from_value_def(db, self.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn extern_block(self, db: &dyn HirDatabase) -> Option<ExternBlock> {
|
||||||
|
match self.id.lookup(db.upcast()).container {
|
||||||
|
ItemContainerId::ExternBlockId(id) => Some(ExternBlock { id }),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Evaluate the static initializer.
|
/// Evaluate the static initializer.
|
||||||
pub fn eval(self, db: &dyn HirDatabase) -> Result<EvaluatedConst, ConstEvalError> {
|
pub fn eval(self, db: &dyn HirDatabase) -> Result<EvaluatedConst, ConstEvalError> {
|
||||||
db.const_eval(self.id.into(), Substitution::empty(Interner), None)
|
db.const_eval(self.id.into(), Substitution::empty(Interner), None)
|
||||||
|
|
@ -2928,6 +2942,17 @@ impl HasVisibility for TypeAlias {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
pub struct ExternBlock {
|
||||||
|
pub(crate) id: ExternBlockId,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ExternBlock {
|
||||||
|
pub fn module(self, db: &dyn HirDatabase) -> Module {
|
||||||
|
Module { id: self.id.module(db.upcast()) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
pub struct StaticLifetime;
|
pub struct StaticLifetime;
|
||||||
|
|
||||||
|
|
@ -6180,9 +6205,15 @@ impl HasContainer for TraitAlias {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl HasContainer for ExternBlock {
|
||||||
|
fn container(&self, db: &dyn HirDatabase) -> ItemContainer {
|
||||||
|
ItemContainer::Module(Module { id: self.id.lookup(db.upcast()).container })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn container_id_to_hir(c: ItemContainerId) -> ItemContainer {
|
fn container_id_to_hir(c: ItemContainerId) -> ItemContainer {
|
||||||
match c {
|
match c {
|
||||||
ItemContainerId::ExternBlockId(_id) => ItemContainer::ExternBlock(),
|
ItemContainerId::ExternBlockId(id) => ItemContainer::ExternBlock(ExternBlock { id }),
|
||||||
ItemContainerId::ModuleId(id) => ItemContainer::Module(Module { id }),
|
ItemContainerId::ModuleId(id) => ItemContainer::Module(Module { id }),
|
||||||
ItemContainerId::ImplId(id) => ItemContainer::Impl(Impl { id }),
|
ItemContainerId::ImplId(id) => ItemContainer::Impl(Impl { id }),
|
||||||
ItemContainerId::TraitId(id) => ItemContainer::Trait(Trait { id }),
|
ItemContainerId::TraitId(id) => ItemContainer::Trait(Trait { id }),
|
||||||
|
|
@ -6194,7 +6225,7 @@ pub enum ItemContainer {
|
||||||
Trait(Trait),
|
Trait(Trait),
|
||||||
Impl(Impl),
|
Impl(Impl),
|
||||||
Module(Module),
|
Module(Module),
|
||||||
ExternBlock(),
|
ExternBlock(ExternBlock),
|
||||||
Crate(CrateId),
|
Crate(CrateId),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1998,6 +1998,7 @@ to_def_impls![
|
||||||
(crate::Adt, ast::Adt, adt_to_def),
|
(crate::Adt, ast::Adt, adt_to_def),
|
||||||
(crate::ExternCrateDecl, ast::ExternCrate, extern_crate_to_def),
|
(crate::ExternCrateDecl, ast::ExternCrate, extern_crate_to_def),
|
||||||
(crate::InlineAsmOperand, ast::AsmOperandNamed, asm_operand_to_def),
|
(crate::InlineAsmOperand, ast::AsmOperandNamed, asm_operand_to_def),
|
||||||
|
(crate::ExternBlock, ast::ExternBlock, extern_block_to_def),
|
||||||
(MacroCallId, ast::MacroCall, macro_call_to_macro_call),
|
(MacroCallId, ast::MacroCall, macro_call_to_macro_call),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,9 @@ impl ChildBySource for ItemScope {
|
||||||
fn child_by_source_to(&self, db: &dyn DefDatabase, res: &mut DynMap, file_id: HirFileId) {
|
fn child_by_source_to(&self, db: &dyn DefDatabase, res: &mut DynMap, file_id: HirFileId) {
|
||||||
self.declarations().for_each(|item| add_module_def(db, res, file_id, item));
|
self.declarations().for_each(|item| add_module_def(db, res, file_id, item));
|
||||||
self.impls().for_each(|imp| insert_item_loc(db, res, file_id, imp, keys::IMPL));
|
self.impls().for_each(|imp| insert_item_loc(db, res, file_id, imp, keys::IMPL));
|
||||||
|
self.extern_blocks().for_each(|extern_block| {
|
||||||
|
insert_item_loc(db, res, file_id, extern_block, keys::EXTERN_BLOCK)
|
||||||
|
});
|
||||||
self.extern_crate_decls()
|
self.extern_crate_decls()
|
||||||
.for_each(|ext| insert_item_loc(db, res, file_id, ext, keys::EXTERN_CRATE));
|
.for_each(|ext| insert_item_loc(db, res, file_id, ext, keys::EXTERN_CRATE));
|
||||||
self.use_decls().for_each(|ext| insert_item_loc(db, res, file_id, ext, keys::USE));
|
self.use_decls().for_each(|ext| insert_item_loc(db, res, file_id, ext, keys::USE));
|
||||||
|
|
|
||||||
|
|
@ -92,10 +92,10 @@ use hir_def::{
|
||||||
DynMap,
|
DynMap,
|
||||||
},
|
},
|
||||||
hir::{BindingId, Expr, LabelId},
|
hir::{BindingId, Expr, LabelId},
|
||||||
AdtId, BlockId, ConstId, ConstParamId, DefWithBodyId, EnumId, EnumVariantId, ExternCrateId,
|
AdtId, BlockId, ConstId, ConstParamId, DefWithBodyId, EnumId, EnumVariantId, ExternBlockId,
|
||||||
FieldId, FunctionId, GenericDefId, GenericParamId, ImplId, LifetimeParamId, Lookup, MacroId,
|
ExternCrateId, FieldId, FunctionId, GenericDefId, GenericParamId, ImplId, LifetimeParamId,
|
||||||
ModuleId, StaticId, StructId, TraitAliasId, TraitId, TypeAliasId, TypeParamId, UnionId, UseId,
|
Lookup, MacroId, ModuleId, StaticId, StructId, TraitAliasId, TraitId, TypeAliasId, TypeParamId,
|
||||||
VariantId,
|
UnionId, UseId, VariantId,
|
||||||
};
|
};
|
||||||
use hir_expand::{
|
use hir_expand::{
|
||||||
attrs::AttrId, name::AsName, ExpansionInfo, HirFileId, HirFileIdExt, InMacroFile, MacroCallId,
|
attrs::AttrId, name::AsName, ExpansionInfo, HirFileId, HirFileIdExt, InMacroFile, MacroCallId,
|
||||||
|
|
@ -308,6 +308,12 @@ impl SourceToDefCtx<'_, '_> {
|
||||||
) -> Option<ExternCrateId> {
|
) -> Option<ExternCrateId> {
|
||||||
self.to_def(src, keys::EXTERN_CRATE)
|
self.to_def(src, keys::EXTERN_CRATE)
|
||||||
}
|
}
|
||||||
|
pub(super) fn extern_block_to_def(
|
||||||
|
&mut self,
|
||||||
|
src: InFile<&ast::ExternBlock>,
|
||||||
|
) -> Option<ExternBlockId> {
|
||||||
|
self.to_def(src, keys::EXTERN_BLOCK)
|
||||||
|
}
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub(super) fn use_to_def(&mut self, src: InFile<&ast::Use>) -> Option<UseId> {
|
pub(super) fn use_to_def(&mut self, src: InFile<&ast::Use>) -> Option<UseId> {
|
||||||
self.to_def(src, keys::USE)
|
self.to_def(src, keys::USE)
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ impl Definition {
|
||||||
ItemContainer::Trait(it) => Some(it.into()),
|
ItemContainer::Trait(it) => Some(it.into()),
|
||||||
ItemContainer::Impl(it) => Some(it.into()),
|
ItemContainer::Impl(it) => Some(it.into()),
|
||||||
ItemContainer::Module(it) => Some(it.into()),
|
ItemContainer::Module(it) => Some(it.into()),
|
||||||
ItemContainer::ExternBlock() | ItemContainer::Crate(_) => None,
|
ItemContainer::ExternBlock(_) | ItemContainer::Crate(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match self {
|
match self {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use crate::{InlayHint, InlayHintsConfig};
|
||||||
|
|
||||||
pub(super) fn extern_block_hints(
|
pub(super) fn extern_block_hints(
|
||||||
acc: &mut Vec<InlayHint>,
|
acc: &mut Vec<InlayHint>,
|
||||||
FamousDefs(_sema, _): &FamousDefs<'_, '_>,
|
FamousDefs(sema, _): &FamousDefs<'_, '_>,
|
||||||
config: &InlayHintsConfig,
|
config: &InlayHintsConfig,
|
||||||
_file_id: EditionedFileId,
|
_file_id: EditionedFileId,
|
||||||
extern_block: ast::ExternBlock,
|
extern_block: ast::ExternBlock,
|
||||||
|
|
@ -16,6 +16,7 @@ pub(super) fn extern_block_hints(
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let abi = extern_block.abi()?;
|
let abi = extern_block.abi()?;
|
||||||
|
sema.to_def(&extern_block)?;
|
||||||
acc.push(InlayHint {
|
acc.push(InlayHint {
|
||||||
range: abi.syntax().text_range(),
|
range: abi.syntax().text_range(),
|
||||||
position: crate::InlayHintPosition::Before,
|
position: crate::InlayHintPosition::Before,
|
||||||
|
|
@ -33,7 +34,7 @@ pub(super) fn extern_block_hints(
|
||||||
|
|
||||||
pub(super) fn fn_hints(
|
pub(super) fn fn_hints(
|
||||||
acc: &mut Vec<InlayHint>,
|
acc: &mut Vec<InlayHint>,
|
||||||
FamousDefs(_sema, _): &FamousDefs<'_, '_>,
|
FamousDefs(sema, _): &FamousDefs<'_, '_>,
|
||||||
config: &InlayHintsConfig,
|
config: &InlayHintsConfig,
|
||||||
_file_id: EditionedFileId,
|
_file_id: EditionedFileId,
|
||||||
fn_: &ast::Fn,
|
fn_: &ast::Fn,
|
||||||
|
|
@ -43,14 +44,16 @@ pub(super) fn fn_hints(
|
||||||
if !implicit_unsafe {
|
if !implicit_unsafe {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let fn_ = fn_.fn_token()?;
|
let fn_token = fn_.fn_token()?;
|
||||||
acc.push(item_hint(config, extern_block, fn_));
|
if sema.to_def(fn_).is_some_and(|def| def.extern_block(sema.db).is_some()) {
|
||||||
|
acc.push(item_hint(config, extern_block, fn_token));
|
||||||
|
}
|
||||||
Some(())
|
Some(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn static_hints(
|
pub(super) fn static_hints(
|
||||||
acc: &mut Vec<InlayHint>,
|
acc: &mut Vec<InlayHint>,
|
||||||
FamousDefs(_sema, _): &FamousDefs<'_, '_>,
|
FamousDefs(sema, _): &FamousDefs<'_, '_>,
|
||||||
config: &InlayHintsConfig,
|
config: &InlayHintsConfig,
|
||||||
_file_id: EditionedFileId,
|
_file_id: EditionedFileId,
|
||||||
static_: &ast::Static,
|
static_: &ast::Static,
|
||||||
|
|
@ -60,8 +63,10 @@ pub(super) fn static_hints(
|
||||||
if !implicit_unsafe {
|
if !implicit_unsafe {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let static_ = static_.static_token()?;
|
let static_token = static_.static_token()?;
|
||||||
acc.push(item_hint(config, extern_block, static_));
|
if sema.to_def(static_).is_some_and(|def| def.extern_block(sema.db).is_some()) {
|
||||||
|
acc.push(item_hint(config, extern_block, static_token));
|
||||||
|
}
|
||||||
Some(())
|
Some(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue