From c32428571c3fbf12bd4a4187c797488355416a18 Mon Sep 17 00:00:00 2001 From: Aramis Razzaghipour Date: Mon, 24 May 2021 09:42:06 +1000 Subject: Remove hir krate methods --- crates/ide/src/inlay_hints.rs | 2 +- crates/ide/src/runnables.rs | 2 +- crates/ide/src/syntax_highlighting/highlight.rs | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'crates/ide/src') diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs index 960d169f4..0ada3f92b 100644 --- a/crates/ide/src/inlay_hints.rs +++ b/crates/ide/src/inlay_hints.rs @@ -219,7 +219,7 @@ fn hint_iterator( ) -> Option { 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; } diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs index f76715d84..ce1c76f37 100644 --- a/crates/ide/src/runnables.rs +++ b/crates/ide/src/runnables.rs @@ -227,7 +227,7 @@ pub(crate) fn runnable_fn(sema: &Semantics, 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 diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs index 2d6d8d100..574a14429 100644 --- a/crates/ide/src/syntax_highlighting/highlight.rs +++ b/crates/ide/src/syntax_highlighting/highlight.rs @@ -287,7 +287,7 @@ fn highlight_def(db: &RootDatabase, krate: Option, 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, 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, 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, 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, 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, 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, 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, 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, def: Definition) h |= HlMod::Unsafe; } - if s.krate(db) != krate { + if Some(s.module(db).krate()) != krate { h |= HlMod::Foreign; } -- cgit v1.2.3