]> git.lizzy.rs Git - rust.git/commitdiff
Fix namespace detection & function test
authorZac Pullar-Strecker <zacmps@gmail.com>
Sat, 5 Sep 2020 04:58:04 +0000 (16:58 +1200)
committerZac Pullar-Strecker <zacmps@gmail.com>
Thu, 8 Oct 2020 02:04:57 +0000 (15:04 +1300)
crates/ide/src/doc_links.rs

index b9d53bcd49ac073fcf4e80e1ef8747bb85c43f05..1014660146e70286dc0126c139062b5945647762 100644 (file)
@@ -112,7 +112,6 @@ pub fn get_doc_link<T: Resolvable + Clone>(db: &dyn HirDatabase, definition: &T)
 // version of import map which follows the same process as rustdoc. Otherwise there'll always be some
 // edge cases where we select the wrong import path.
 fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option<String> {
-    eprintln!("enter");
     // Get the outermost definition for the moduledef. This is used to resolve the public path to the type,
     // then we can join the method, field, etc onto it if required.
     let target_def: ModuleDef = match definition {
@@ -127,7 +126,7 @@ fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option<String> {
         _ => return None,
     };
 
-    let ns = ItemInNs::Types(target_def.clone().into());
+    let ns = ItemInNs::from(target_def.clone());
 
     let module = definition.module(db)?;
     let krate = module.krate();
@@ -153,7 +152,6 @@ fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option<String> {
         Definition::Field(field) => get_symbol_fragment(db, &FieldOrAssocItem::Field(field)),
         _ => None,
     };
-    eprintln!("end-ish");
 
     get_doc_url(db, &krate)
         .and_then(|url| url.join(&base).ok())
@@ -456,14 +454,13 @@ fn test_doc_url_struct() {
         );
     }
 
-    // TODO: Fix this test. Fails on `import_map.path_of(ns)`
     #[test]
     fn test_doc_url_fn() {
         check(
             r#"
 pub fn fo<|>o() {}
 "#,
-            expect![[r#""#]],
+            expect![[r##"https://docs.rs/test/*/test/fn.foo.html#method.foo"##]],
         );
     }
 
@@ -508,7 +505,6 @@ pub trait Foo {
         );
     }
 
-
     #[test]
     fn test_doc_url_field() {
         check(