mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
Fix extern crate self having self unresolved
This commit is contained in:
parent
e5bb661b7a
commit
d460b7c9d1
@ -10,7 +10,10 @@ use hir_def::{
|
||||
resolver::{self, HasResolver, Resolver, TypeNs},
|
||||
AsMacroCall, FunctionId, TraitId, VariantId,
|
||||
};
|
||||
use hir_expand::{name::AsName, ExpansionInfo, MacroCallId};
|
||||
use hir_expand::{
|
||||
name::{known, AsName},
|
||||
ExpansionInfo, MacroCallId,
|
||||
};
|
||||
use hir_ty::Interner;
|
||||
use itertools::Itertools;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
@ -910,13 +913,14 @@ impl<'db> SemanticsImpl<'db> {
|
||||
|
||||
fn resolve_extern_crate(&self, extern_crate: &ast::ExternCrate) -> Option<Crate> {
|
||||
let krate = self.scope(extern_crate.syntax()).krate()?;
|
||||
krate.dependencies(self.db).into_iter().find_map(|dep| {
|
||||
if dep.name == extern_crate.name_ref()?.as_name() {
|
||||
Some(dep.krate)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
let name = extern_crate.name_ref()?.as_name();
|
||||
if name == known::SELF_PARAM {
|
||||
return Some(krate);
|
||||
}
|
||||
krate
|
||||
.dependencies(self.db)
|
||||
.into_iter()
|
||||
.find_map(|dep| (dep.name == name).then(|| dep.krate))
|
||||
}
|
||||
|
||||
fn resolve_variant(&self, record_lit: ast::RecordExpr) -> Option<VariantId> {
|
||||
|
@ -41,7 +41,7 @@ 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="unresolved_reference">self</span><span class="semicolon">;</span>
|
||||
<pre><code><span class="keyword">extern</span> <span class="keyword">crate</span> <span class="self_keyword crate_root">self</span><span class="semicolon">;</span>
|
||||
|
||||
<span class="keyword">use</span> <span class="keyword crate_root">crate</span><span class="semicolon">;</span>
|
||||
<span class="keyword">use</span> <span class="self_keyword crate_root">self</span><span class="semicolon">;</span>
|
||||
|
Loading…
Reference in New Issue
Block a user