Fix error when using "extern crate self as"
This commit is contained in:
parent
2472851ccf
commit
e52589e3a7
@ -14,6 +14,7 @@
|
||||
|
||||
use base_db::Edition;
|
||||
use hir_expand::name::Name;
|
||||
use hir_expand::name;
|
||||
use test_utils::mark;
|
||||
|
||||
use crate::{
|
||||
@ -63,6 +64,11 @@ fn with(
|
||||
|
||||
impl DefMap {
|
||||
pub(super) fn resolve_name_in_extern_prelude(&self, name: &Name) -> PerNs {
|
||||
if name == &name!(self) {
|
||||
return PerNs::types(ModuleId { krate: self.krate, local_id: self.root }.into(),
|
||||
Visibility::Public,
|
||||
);
|
||||
}
|
||||
self.extern_prelude
|
||||
.get(name)
|
||||
.map_or(PerNs::none(), |&it| PerNs::types(it, Visibility::Public))
|
||||
|
@ -61,6 +61,21 @@ fn unresolved_extern_crate() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extern_crate_self_as() {
|
||||
check_diagnostics(
|
||||
r"
|
||||
//- /lib.rs
|
||||
extern crate doesnotexist;
|
||||
//^^^^^^^^^^^^^^^^^^^^^^^^^^ unresolved extern crate
|
||||
// Should not error.
|
||||
extern crate self as foo;
|
||||
struct Foo;
|
||||
use foo::Foo as Bar;
|
||||
",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dedup_unresolved_import_from_unresolved_crate() {
|
||||
check_diagnostics(
|
||||
|
Loading…
Reference in New Issue
Block a user