Skip to content

Commit

Permalink
Fix namespace detection & function test
Browse files Browse the repository at this point in the history
  • Loading branch information
zacps committed Sep 5, 2020
1 parent 71174ff commit 6709c16
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions crates/ide/src/doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ pub fn rewrite_links(db: &RootDatabase, markdown: &str, definition: &Definition)
// 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 {
Expand All @@ -84,7 +83,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();
Expand All @@ -110,7 +109,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())
Expand Down Expand Up @@ -413,14 +411,13 @@ pub struct Fo<|>o;
);
}

// 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"##]],
);
}

Expand Down Expand Up @@ -465,7 +462,6 @@ pub trait Foo {
);
}


#[test]
fn test_doc_url_field() {
check(
Expand Down

0 comments on commit 6709c16

Please sign in to comment.