internal: remove needless distinction between a carte and its root mod
This commit is contained in:
parent
dedf0ff7c5
commit
f42648e305
crates
ide/src/syntax_highlighting
ide_assists/src/handlers
ide_db/src
@ -111,7 +111,6 @@ pub(super) fn element(
|
||||
}
|
||||
};
|
||||
let h = match name_class {
|
||||
NameRefClass::ExternCrate(_) => SymbolKind::Module.into(),
|
||||
NameRefClass::Definition(def) => {
|
||||
if let Definition::Local(local) = &def {
|
||||
if let Some(name) = local.name(db) {
|
||||
|
@ -38,6 +38,6 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||
|
||||
.unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
|
||||
</style>
|
||||
<pre><code><span class="keyword">extern</span> <span class="keyword">crate</span> <span class="module">std</span><span class="semicolon">;</span>
|
||||
<span class="keyword">extern</span> <span class="keyword">crate</span> <span class="module">alloc</span> <span class="keyword">as</span> <span class="module">abc</span><span class="semicolon">;</span>
|
||||
<pre><code><span class="keyword">extern</span> <span class="keyword">crate</span> <span class="module library">std</span><span class="semicolon">;</span>
|
||||
<span class="keyword">extern</span> <span class="keyword">crate</span> <span class="module library">alloc</span> <span class="keyword">as</span> <span class="module">abc</span><span class="semicolon">;</span>
|
||||
</code></pre>
|
@ -41,7 +41,7 @@ pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<(
|
||||
let name_ref = ast::NameRef::cast(ident.parent()?)?;
|
||||
let def = match NameRefClass::classify(&ctx.sema, &name_ref)? {
|
||||
NameRefClass::Definition(def) => def,
|
||||
NameRefClass::ExternCrate(_) | NameRefClass::FieldShorthand { .. } => return None,
|
||||
NameRefClass::FieldShorthand { .. } => return None,
|
||||
};
|
||||
let fun = match def {
|
||||
Definition::ModuleDef(hir::ModuleDef::Function(it)) => it,
|
||||
|
@ -303,16 +303,14 @@ impl NameClass {
|
||||
/// reference to point to two different defs.
|
||||
#[derive(Debug)]
|
||||
pub enum NameRefClass {
|
||||
ExternCrate(Crate),
|
||||
Definition(Definition),
|
||||
FieldShorthand { local_ref: Local, field_ref: Definition },
|
||||
}
|
||||
|
||||
impl NameRefClass {
|
||||
/// `Definition`, which this name refers to.
|
||||
pub fn referenced(self, db: &dyn HirDatabase) -> Definition {
|
||||
pub fn referenced(self, _db: &dyn HirDatabase) -> Definition {
|
||||
match self {
|
||||
NameRefClass::ExternCrate(krate) => Definition::ModuleDef(krate.root_module(db).into()),
|
||||
NameRefClass::Definition(def) => def,
|
||||
NameRefClass::FieldShorthand { local_ref, field_ref: _ } => {
|
||||
// FIXME: this is inherently ambiguous -- this name refers to
|
||||
@ -428,8 +426,9 @@ impl NameRefClass {
|
||||
}
|
||||
|
||||
let extern_crate = ast::ExternCrate::cast(parent)?;
|
||||
let resolved = sema.resolve_extern_crate(&extern_crate)?;
|
||||
Some(NameRefClass::ExternCrate(resolved))
|
||||
let krate = sema.resolve_extern_crate(&extern_crate)?;
|
||||
let root_module = krate.root_module(sema.db);
|
||||
Some(NameRefClass::Definition(Definition::ModuleDef(root_module.into())))
|
||||
}
|
||||
|
||||
pub fn classify_lifetime(
|
||||
|
Loading…
x
Reference in New Issue
Block a user