mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
parent
0948932145
commit
b49ecafd40
2 changed files with 49 additions and 24 deletions
|
@ -7,7 +7,7 @@ use crate::{
|
|||
visibility::Visibility,
|
||||
CrateId, ModuleDefId, ModuleId,
|
||||
};
|
||||
use hir_expand::name::{known, Name};
|
||||
use hir_expand::name::{known, AsName, Name};
|
||||
use test_utils::tested_by;
|
||||
|
||||
const MAX_PATH_LEN: usize = 15;
|
||||
|
@ -113,6 +113,11 @@ fn find_path_inner(
|
|||
}
|
||||
}
|
||||
|
||||
// - if the item is a builtin, it's in scope
|
||||
if let ItemInNs::Types(ModuleDefId::BuiltinType(builtin)) = item {
|
||||
return Some(ModPath::from_segments(PathKind::Plain, vec![builtin.as_name()]));
|
||||
}
|
||||
|
||||
// Recursive case:
|
||||
// - if the item is an enum variant, refer to it via the enum
|
||||
if let Some(ModuleDefId::EnumVariantId(variant)) = item.as_module_def_id() {
|
||||
|
@ -523,4 +528,18 @@ mod tests {
|
|||
"#;
|
||||
check_found_path(code, "megaalloc::Arc");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn builtins_are_in_scope() {
|
||||
let code = r#"
|
||||
//- /main.rs
|
||||
<|>
|
||||
|
||||
pub mod primitive {
|
||||
pub use u8;
|
||||
}
|
||||
"#;
|
||||
check_found_path(code, "u8");
|
||||
check_found_path(code, "u16");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue