aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/find_path.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/find_path.rs')
-rw-r--r--crates/ra_hir_def/src/find_path.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/crates/ra_hir_def/src/find_path.rs b/crates/ra_hir_def/src/find_path.rs
index d58ac6ba5..81eff5bfe 100644
--- a/crates/ra_hir_def/src/find_path.rs
+++ b/crates/ra_hir_def/src/find_path.rs
@@ -7,7 +7,7 @@ use crate::{
7 visibility::Visibility, 7 visibility::Visibility,
8 CrateId, ModuleDefId, ModuleId, 8 CrateId, ModuleDefId, ModuleId,
9}; 9};
10use hir_expand::name::{known, Name}; 10use hir_expand::name::{known, AsName, Name};
11use test_utils::tested_by; 11use test_utils::tested_by;
12 12
13const MAX_PATH_LEN: usize = 15; 13const MAX_PATH_LEN: usize = 15;
@@ -113,6 +113,11 @@ fn find_path_inner(
113 } 113 }
114 } 114 }
115 115
116 // - if the item is a builtin, it's in scope
117 if let ItemInNs::Types(ModuleDefId::BuiltinType(builtin)) = item {
118 return Some(ModPath::from_segments(PathKind::Plain, vec![builtin.as_name()]));
119 }
120
116 // Recursive case: 121 // Recursive case:
117 // - if the item is an enum variant, refer to it via the enum 122 // - if the item is an enum variant, refer to it via the enum
118 if let Some(ModuleDefId::EnumVariantId(variant)) = item.as_module_def_id() { 123 if let Some(ModuleDefId::EnumVariantId(variant)) = item.as_module_def_id() {
@@ -523,4 +528,18 @@ mod tests {
523 "#; 528 "#;
524 check_found_path(code, "megaalloc::Arc"); 529 check_found_path(code, "megaalloc::Arc");
525 } 530 }
531
532 #[test]
533 fn builtins_are_in_scope() {
534 let code = r#"
535 //- /main.rs
536 <|>
537
538 pub mod primitive {
539 pub use u8;
540 }
541 "#;
542 check_found_path(code, "u8");
543 check_found_path(code, "u16");
544 }
526} 545}