mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-25 11:17:13 +00:00
Merge pull request #20384 from vxpm/fix-external-docs
fix external docs for exported macros
This commit is contained in:
commit
75436532df
@ -390,7 +390,8 @@ fn get_doc_links(
|
||||
|
||||
let (mut web_url, mut local_url) = get_doc_base_urls(db, target, target_dir, sysroot);
|
||||
|
||||
if let Some(path) = mod_path_of_def(db, target) {
|
||||
let append_mod = !matches!(def, Definition::Macro(m) if m.is_macro_export(db));
|
||||
if append_mod && let Some(path) = mod_path_of_def(db, target) {
|
||||
web_url = join_url(web_url, &path);
|
||||
local_url = join_url(local_url, &path);
|
||||
}
|
||||
|
@ -414,6 +414,30 @@ fn foo() {
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn external_docs_macro_export() {
|
||||
check_external_docs(
|
||||
r#"
|
||||
//- /lib.rs crate:foo
|
||||
pub mod inner {
|
||||
#[macro_export]
|
||||
macro_rules! my_macro {
|
||||
() => {};
|
||||
}
|
||||
}
|
||||
|
||||
//- /main.rs crate:bar deps:foo
|
||||
fn main() {
|
||||
foo::my_m$0acro!();
|
||||
}
|
||||
"#,
|
||||
Some("/home/user/project"),
|
||||
Some(expect![[r#"https://docs.rs/foo/*/foo/macro.my_macro.html"#]]),
|
||||
Some(expect![[r#"file:///home/user/project/doc/foo/macro.my_macro.html"#]]),
|
||||
Some("/sysroot"),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn doc_links_items_simple() {
|
||||
check_doc_links(
|
||||
|
Loading…
x
Reference in New Issue
Block a user