mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
Remove hir krate methods
This commit is contained in:
parent
4fd5248749
commit
c32428571c
4 changed files with 11 additions and 59 deletions
|
@ -552,10 +552,6 @@ impl Struct {
|
|||
Module { id: self.id.lookup(db.upcast()).container }
|
||||
}
|
||||
|
||||
pub fn krate(self, db: &dyn HirDatabase) -> Option<Crate> {
|
||||
Some(self.module(db).krate())
|
||||
}
|
||||
|
||||
pub fn name(self, db: &dyn HirDatabase) -> Name {
|
||||
db.struct_data(self.id).name.clone()
|
||||
}
|
||||
|
@ -640,10 +636,6 @@ impl Enum {
|
|||
Module { id: self.id.lookup(db.upcast()).container }
|
||||
}
|
||||
|
||||
pub fn krate(self, db: &dyn HirDatabase) -> Option<Crate> {
|
||||
Some(self.module(db).krate())
|
||||
}
|
||||
|
||||
pub fn name(self, db: &dyn HirDatabase) -> Name {
|
||||
db.enum_data(self.id).name.clone()
|
||||
}
|
||||
|
@ -674,10 +666,6 @@ impl Variant {
|
|||
self.parent.module(db)
|
||||
}
|
||||
|
||||
pub fn krate(self, db: &dyn HirDatabase) -> Crate {
|
||||
self.module(db).krate()
|
||||
}
|
||||
|
||||
pub fn parent_enum(self, _db: &dyn HirDatabase) -> Enum {
|
||||
self.parent
|
||||
}
|
||||
|
@ -734,10 +722,6 @@ impl Adt {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn krate(self, db: &dyn HirDatabase) -> Crate {
|
||||
self.module(db).krate()
|
||||
}
|
||||
|
||||
pub fn name(self, db: &dyn HirDatabase) -> Name {
|
||||
match self {
|
||||
Adt::Struct(s) => s.name(db),
|
||||
|
@ -772,10 +756,6 @@ impl VariantDef {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn krate(self, db: &dyn HirDatabase) -> Crate {
|
||||
self.module(db).krate()
|
||||
}
|
||||
|
||||
pub fn name(&self, db: &dyn HirDatabase) -> Name {
|
||||
match self {
|
||||
VariantDef::Struct(s) => s.name(db),
|
||||
|
@ -830,10 +810,6 @@ impl Function {
|
|||
self.id.lookup(db.upcast()).module(db.upcast()).into()
|
||||
}
|
||||
|
||||
pub fn krate(self, db: &dyn HirDatabase) -> Option<Crate> {
|
||||
Some(self.module(db).krate())
|
||||
}
|
||||
|
||||
pub fn name(self, db: &dyn HirDatabase) -> Name {
|
||||
db.function_data(self.id).name.clone()
|
||||
}
|
||||
|
@ -1023,10 +999,6 @@ impl Const {
|
|||
Module { id: self.id.lookup(db.upcast()).module(db.upcast()) }
|
||||
}
|
||||
|
||||
pub fn krate(self, db: &dyn HirDatabase) -> Option<Crate> {
|
||||
Some(self.module(db).krate())
|
||||
}
|
||||
|
||||
pub fn name(self, db: &dyn HirDatabase) -> Option<Name> {
|
||||
db.const_data(self.id).name.clone()
|
||||
}
|
||||
|
@ -1054,10 +1026,6 @@ impl Static {
|
|||
Module { id: self.id.lookup(db.upcast()).module(db.upcast()) }
|
||||
}
|
||||
|
||||
pub fn krate(self, db: &dyn HirDatabase) -> Option<Crate> {
|
||||
Some(self.module(db).krate())
|
||||
}
|
||||
|
||||
pub fn name(self, db: &dyn HirDatabase) -> Option<Name> {
|
||||
db.static_data(self.id).name.clone()
|
||||
}
|
||||
|
@ -1083,10 +1051,6 @@ impl Trait {
|
|||
Module { id: self.id.lookup(db.upcast()).container }
|
||||
}
|
||||
|
||||
pub fn krate(self, db: &dyn HirDatabase) -> Crate {
|
||||
self.module(db).krate()
|
||||
}
|
||||
|
||||
pub fn name(self, db: &dyn HirDatabase) -> Name {
|
||||
db.trait_data(self.id).name.clone()
|
||||
}
|
||||
|
@ -1125,10 +1089,6 @@ impl TypeAlias {
|
|||
Module { id: self.id.lookup(db.upcast()).module(db.upcast()) }
|
||||
}
|
||||
|
||||
pub fn krate(self, db: &dyn HirDatabase) -> Crate {
|
||||
self.module(db).krate()
|
||||
}
|
||||
|
||||
pub fn type_ref(self, db: &dyn HirDatabase) -> Option<TypeRef> {
|
||||
db.type_alias_data(self.id).type_ref.as_deref().cloned()
|
||||
}
|
||||
|
@ -1191,10 +1151,6 @@ impl MacroDef {
|
|||
Some(Module { id: def_map.module_id(module_id) })
|
||||
}
|
||||
|
||||
pub fn krate(self, db: &dyn HirDatabase) -> Option<Crate> {
|
||||
self.module(db).map(Module::krate)
|
||||
}
|
||||
|
||||
/// XXX: this parses the file
|
||||
pub fn name(self, db: &dyn HirDatabase) -> Option<Name> {
|
||||
match self.source(db)?.value {
|
||||
|
@ -1684,10 +1640,6 @@ impl Impl {
|
|||
self.id.lookup(db.upcast()).container.into()
|
||||
}
|
||||
|
||||
pub fn krate(self, db: &dyn HirDatabase) -> Crate {
|
||||
Crate { id: self.module(db).id.krate() }
|
||||
}
|
||||
|
||||
pub fn is_builtin_derive(self, db: &dyn HirDatabase) -> Option<InFile<ast::Attr>> {
|
||||
let src = self.source(db)?;
|
||||
let item = src.file_id.is_builtin_derive(db.upcast())?;
|
||||
|
|
|
@ -219,7 +219,7 @@ fn hint_iterator(
|
|||
) -> Option<SmolStr> {
|
||||
let db = sema.db;
|
||||
let strukt = ty.strip_references().as_adt()?;
|
||||
let krate = strukt.krate(db);
|
||||
let krate = strukt.module(db).krate();
|
||||
if krate != famous_defs.core()? {
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -227,7 +227,7 @@ pub(crate) fn runnable_fn(sema: &Semantics<RootDatabase>, def: hir::Function) ->
|
|||
let func = def.source(sema.db)?;
|
||||
let name_string = def.name(sema.db).to_string();
|
||||
|
||||
let root = def.krate(sema.db)?.root_module(sema.db);
|
||||
let root = def.module(sema.db).krate().root_module(sema.db);
|
||||
|
||||
let kind = if name_string == "main" && def.module(sema.db) == root {
|
||||
RunnableKind::Bin
|
||||
|
|
|
@ -287,7 +287,7 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
|
|||
Definition::Macro(m) => {
|
||||
let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Macro));
|
||||
|
||||
if m.krate(db) != krate {
|
||||
if m.module(db).map(hir::Module::krate) != krate {
|
||||
h |= HlMod::Foreign;
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
|
|||
Definition::Field(field) => {
|
||||
let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Field));
|
||||
|
||||
if Some(field.parent_def(db).krate(db)) != krate {
|
||||
if Some(field.parent_def(db).module(db).krate()) != krate {
|
||||
h |= HlMod::Foreign;
|
||||
}
|
||||
|
||||
|
@ -335,7 +335,7 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
|
|||
if func.is_async(db) {
|
||||
h |= HlMod::Async;
|
||||
}
|
||||
if func.krate(db) != krate {
|
||||
if Some(func.module(db).krate()) != krate {
|
||||
h |= HlMod::Foreign;
|
||||
}
|
||||
return h;
|
||||
|
@ -348,7 +348,7 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
|
|||
};
|
||||
let mut h = Highlight::new(h);
|
||||
|
||||
if Some(adt.krate(db)) != krate {
|
||||
if Some(adt.module(db).krate()) != krate {
|
||||
h |= HlMod::Foreign;
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
|
|||
hir::ModuleDef::Variant(variant) => {
|
||||
let mut h = Highlight::new(HlTag::Symbol(SymbolKind::Variant));
|
||||
|
||||
if Some(variant.krate(db)) != krate {
|
||||
if Some(variant.module(db).krate()) != krate {
|
||||
h |= HlMod::Foreign;
|
||||
}
|
||||
|
||||
|
@ -380,7 +380,7 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
|
|||
}
|
||||
}
|
||||
|
||||
if konst.krate(db) != krate {
|
||||
if Some(konst.module(db).krate()) != krate {
|
||||
h |= HlMod::Foreign;
|
||||
}
|
||||
|
||||
|
@ -393,7 +393,7 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
|
|||
h |= HlMod::Unsafe;
|
||||
}
|
||||
|
||||
if Some(trait_.krate(db)) != krate {
|
||||
if Some(trait_.module(db).krate()) != krate {
|
||||
h |= HlMod::Foreign;
|
||||
}
|
||||
|
||||
|
@ -416,7 +416,7 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
|
|||
}
|
||||
}
|
||||
|
||||
if Some(type_.krate(db)) != krate {
|
||||
if Some(type_.module(db).krate()) != krate {
|
||||
h |= HlMod::Foreign;
|
||||
}
|
||||
|
||||
|
@ -431,7 +431,7 @@ fn highlight_def(db: &RootDatabase, krate: Option<hir::Crate>, def: Definition)
|
|||
h |= HlMod::Unsafe;
|
||||
}
|
||||
|
||||
if s.krate(db) != krate {
|
||||
if Some(s.module(db).krate()) != krate {
|
||||
h |= HlMod::Foreign;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue