mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Fix namespace detection & function test
This commit is contained in:
parent
37a4d060a7
commit
6cae6b8f3c
1 changed files with 2 additions and 6 deletions
|
@ -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
|
// 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.
|
// edge cases where we select the wrong import path.
|
||||||
fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option<String> {
|
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,
|
// 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.
|
// then we can join the method, field, etc onto it if required.
|
||||||
let target_def: ModuleDef = match definition {
|
let target_def: ModuleDef = match definition {
|
||||||
|
@ -127,7 +126,7 @@ fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option<String> {
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let ns = ItemInNs::Types(target_def.clone().into());
|
let ns = ItemInNs::from(target_def.clone());
|
||||||
|
|
||||||
let module = definition.module(db)?;
|
let module = definition.module(db)?;
|
||||||
let krate = module.krate();
|
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)),
|
Definition::Field(field) => get_symbol_fragment(db, &FieldOrAssocItem::Field(field)),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
eprintln!("end-ish");
|
|
||||||
|
|
||||||
get_doc_url(db, &krate)
|
get_doc_url(db, &krate)
|
||||||
.and_then(|url| url.join(&base).ok())
|
.and_then(|url| url.join(&base).ok())
|
||||||
|
@ -456,14 +454,13 @@ pub struct Fo<|>o;
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Fix this test. Fails on `import_map.path_of(ns)`
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_doc_url_fn() {
|
fn test_doc_url_fn() {
|
||||||
check(
|
check(
|
||||||
r#"
|
r#"
|
||||||
pub fn fo<|>o() {}
|
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]
|
#[test]
|
||||||
fn test_doc_url_field() {
|
fn test_doc_url_field() {
|
||||||
check(
|
check(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue