aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Pullar-Strecker <[email protected]>2020-09-05 05:58:04 +0100
committerZac Pullar-Strecker <[email protected]>2020-10-08 03:04:57 +0100
commit6cae6b8f3cf284f9f386ea8ce7e347043fe9a040 (patch)
tree175ef2dd4d79327de904c313144ccf978bc2f1e6
parent37a4d060a7709da42a67fe1631d5786f7e106884 (diff)
Fix namespace detection & function test
-rw-r--r--crates/ide/src/doc_links.rs8
1 files changed, 2 insertions, 6 deletions
diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs
index b9d53bcd4..101466014 100644
--- a/crates/ide/src/doc_links.rs
+++ b/crates/ide/src/doc_links.rs
@@ -112,7 +112,6 @@ pub fn get_doc_link<T: Resolvable + Clone>(db: &dyn HirDatabase, definition: &T)
112// version of import map which follows the same process as rustdoc. Otherwise there'll always be some 112// version of import map which follows the same process as rustdoc. Otherwise there'll always be some
113// edge cases where we select the wrong import path. 113// edge cases where we select the wrong import path.
114fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option<String> { 114fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option<String> {
115 eprintln!("enter");
116 // Get the outermost definition for the moduledef. This is used to resolve the public path to the type, 115 // Get the outermost definition for the moduledef. This is used to resolve the public path to the type,
117 // then we can join the method, field, etc onto it if required. 116 // then we can join the method, field, etc onto it if required.
118 let target_def: ModuleDef = match definition { 117 let target_def: ModuleDef = match definition {
@@ -127,7 +126,7 @@ fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option<String> {
127 _ => return None, 126 _ => return None,
128 }; 127 };
129 128
130 let ns = ItemInNs::Types(target_def.clone().into()); 129 let ns = ItemInNs::from(target_def.clone());
131 130
132 let module = definition.module(db)?; 131 let module = definition.module(db)?;
133 let krate = module.krate(); 132 let krate = module.krate();
@@ -153,7 +152,6 @@ fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option<String> {
153 Definition::Field(field) => get_symbol_fragment(db, &FieldOrAssocItem::Field(field)), 152 Definition::Field(field) => get_symbol_fragment(db, &FieldOrAssocItem::Field(field)),
154 _ => None, 153 _ => None,
155 }; 154 };
156 eprintln!("end-ish");
157 155
158 get_doc_url(db, &krate) 156 get_doc_url(db, &krate)
159 .and_then(|url| url.join(&base).ok()) 157 .and_then(|url| url.join(&base).ok())
@@ -456,14 +454,13 @@ pub struct Fo<|>o;
456 ); 454 );
457 } 455 }
458 456
459 // TODO: Fix this test. Fails on `import_map.path_of(ns)`
460 #[test] 457 #[test]
461 fn test_doc_url_fn() { 458 fn test_doc_url_fn() {
462 check( 459 check(
463 r#" 460 r#"
464pub fn fo<|>o() {} 461pub fn fo<|>o() {}
465"#, 462"#,
466 expect![[r#""#]], 463 expect![[r##"https://docs.rs/test/*/test/fn.foo.html#method.foo"##]],
467 ); 464 );
468 } 465 }
469 466
@@ -508,7 +505,6 @@ pub trait Foo {
508 ); 505 );
509 } 506 }
510 507
511
512 #[test] 508 #[test]
513 fn test_doc_url_field() { 509 fn test_doc_url_field() {
514 check( 510 check(