-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix external docs for exported macros #20384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Please add a test. |
I'm not very familiar with the fixtures used in rust-analyzer's tests so I might be doing something wrong here, but the following test returns no links at all: #[test]
fn external_docs_macro_export() {
check_external_docs(
r#"
//- /main.rs crate:foo
pub mod inner {
#[macro_export]
macro_rules my_macro! {
() => {};
}
}
fn main() {
inner::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"),
);
} Seeing as there are no other tests in the file which define |
You made two mistakes: misplaced the #[test]
fn external_docs_macro_export() {
check_external_docs(
r#"
//- /main.rs crate:foo
pub mod inner {
#[macro_export]
macro_rules! my_macro {
() => {};
}
}
fn main() {
my_macro$0!();
}
"#,
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"),
);
} And yeah, I agree that debugging incorrect code in our tests is harder that it should be (although the highlighting helps - if it isn't highlighted correctly, there's probably an error somewhere). |
oops - |
Can you squash please? |
done! |
Thanks! |
macros annotated with
#[macro_export]
are documented at the root of the crate, yetexternalDocs
was returning a path which considered it to be documented at the module it's defined in. this PR fixes that.example:
externalDocs
forprintln!
was returninghttps://doc.rust-lang.org/nightly/std/macros/macro.println.html
externalDocs
forprintln!
returnshttps://doc.rust-lang.org/nightly/std/macro.println.html