Skip to content

handle extern crate in name resolution #523

Closed
@killercup

Description

@killercup

Currently, std::sync::Arc cannot be resolved.

In #522 (comment), @flodiebold speculates:

std::sync gets properly resolved, but it reexports Arc from alloc_crate, which is an extern crate rename: extern crate alloc as alloc_crate. I guess that's the problem.


Here's a simple test case:

diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs
index 2968b807..2ca1d6d9 100644
--- a/crates/ra_ide_api/src/hover.rs
+++ b/crates/ra_ide_api/src/hover.rs
@@ -230,6 +230,20 @@ mod tests {
         assert_eq!("u32", &type_name);
     }
 
+    #[test]
+    fn test_type_of_arc() {
+        let (analysis, position) = single_file_with_position(
+            r"
+            use std::sync::A<|>rc;
+
+            fn main() {}
+            ",
+        );
+
+        let hover = analysis.hover(position).unwrap().unwrap();
+        assert!(!hover.info.contains("Failed to exactly resolve"));
+    }
+
     // FIXME: improve type_of to make this work
     #[test]
     fn test_type_of_for_expr_1() {

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-has-instructionsIssue has some instructions and pointers to code to get startedE-medium

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions