Skip to content

Commit f42648e

Browse files
committed
internal: remove needless distinction between a carte and its root mod
1 parent dedf0ff commit f42648e

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

crates/ide/src/syntax_highlighting/highlight.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ pub(super) fn element(
111111
}
112112
};
113113
let h = match name_class {
114-
NameRefClass::ExternCrate(_) => SymbolKind::Module.into(),
115114
NameRefClass::Definition(def) => {
116115
if let Definition::Local(local) = &def {
117116
if let Some(name) = local.name(db) {

crates/ide/src/syntax_highlighting/test_data/highlight_extern_crate.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@
3838

3939
.unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
4040
</style>
41-
<pre><code><span class="keyword">extern</span> <span class="keyword">crate</span> <span class="module">std</span><span class="semicolon">;</span>
42-
<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>
41+
<pre><code><span class="keyword">extern</span> <span class="keyword">crate</span> <span class="module library">std</span><span class="semicolon">;</span>
42+
<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>
4343
</code></pre>

crates/ide_assists/src/handlers/add_turbo_fish.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<(
4141
let name_ref = ast::NameRef::cast(ident.parent()?)?;
4242
let def = match NameRefClass::classify(&ctx.sema, &name_ref)? {
4343
NameRefClass::Definition(def) => def,
44-
NameRefClass::ExternCrate(_) | NameRefClass::FieldShorthand { .. } => return None,
44+
NameRefClass::FieldShorthand { .. } => return None,
4545
};
4646
let fun = match def {
4747
Definition::ModuleDef(hir::ModuleDef::Function(it)) => it,

crates/ide_db/src/defs.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,16 +303,14 @@ impl NameClass {
303303
/// reference to point to two different defs.
304304
#[derive(Debug)]
305305
pub enum NameRefClass {
306-
ExternCrate(Crate),
307306
Definition(Definition),
308307
FieldShorthand { local_ref: Local, field_ref: Definition },
309308
}
310309

311310
impl NameRefClass {
312311
/// `Definition`, which this name refers to.
313-
pub fn referenced(self, db: &dyn HirDatabase) -> Definition {
312+
pub fn referenced(self, _db: &dyn HirDatabase) -> Definition {
314313
match self {
315-
NameRefClass::ExternCrate(krate) => Definition::ModuleDef(krate.root_module(db).into()),
316314
NameRefClass::Definition(def) => def,
317315
NameRefClass::FieldShorthand { local_ref, field_ref: _ } => {
318316
// FIXME: this is inherently ambiguous -- this name refers to
@@ -428,8 +426,9 @@ impl NameRefClass {
428426
}
429427

430428
let extern_crate = ast::ExternCrate::cast(parent)?;
431-
let resolved = sema.resolve_extern_crate(&extern_crate)?;
432-
Some(NameRefClass::ExternCrate(resolved))
429+
let krate = sema.resolve_extern_crate(&extern_crate)?;
430+
let root_module = krate.root_module(sema.db);
431+
Some(NameRefClass::Definition(Definition::ModuleDef(root_module.into())))
433432
}
434433

435434
pub fn classify_lifetime(

0 commit comments

Comments
 (0)