From bfc2e568dd862827b987ef979f4b2f04638beb7a Mon Sep 17 00:00:00 2001 From: Johann Hemmann Date: Tue, 9 Jan 2024 14:52:40 +0100 Subject: [PATCH] Add tests for intra-doc links The first one succeeds because the functionality is already implemented. The second one fails and represents the functionality to be implemented in this PR. --- crates/ide/src/doc_links/tests.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/crates/ide/src/doc_links/tests.rs b/crates/ide/src/doc_links/tests.rs index e1f5ccc228..37da3d6514 100644 --- a/crates/ide/src/doc_links/tests.rs +++ b/crates/ide/src/doc_links/tests.rs @@ -664,3 +664,29 @@ pub struct $0Foo; expect![["[`foo`]"]], ); } + +#[test] +fn rewrite_intra_doc_link() { + check_rewrite( + r#" + //- minicore: eq, derive + //- /main.rs crate:foo + //! $0[PartialEq] + fn main() {} + "#, + expect!["[PartialEq](https://doc.rust-lang.org/stable/core/cmp/trait.PartialEq.html)"], + ); +} + +#[test] +fn rewrite_intra_doc_link_with_anchor() { + check_rewrite( + r#" + //- minicore: eq, derive + //- /main.rs crate:foo + //! $0[PartialEq#derivable] + fn main() {} + "#, + expect!["[PartialEq#derivable](https://doc.rust-lang.org/stable/core/cmp/trait.PartialEq.html#derivable)"], + ); +}