Skip to content

Commit c2aa141

Browse files
committed
Add ignored test to demonstrate ImportMap bug
1 parent 6709c16 commit c2aa141

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

crates/ide/src/doc_links.rs

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,6 @@ pub fn rewrite_links(db: &RootDatabase, markdown: &str, definition: &Definition)
6060
out
6161
}
6262

63-
// FIXME:
64-
// BUG: For Option::Some
65-
// Returns https://doc.rust-lang.org/nightly/core/prelude/v1/enum.Option.html#variant.Some
66-
// Instead of https://doc.rust-lang.org/nightly/core/option/enum.Option.html
67-
// This could be worked around by turning the `EnumVariant` into `Enum` before attempting resolution,
68-
// but it's really just working around the problem. Ideally we need to implement a slightly different
69-
// version of import map which follows the same process as rustdoc. Otherwise there'll always be some
70-
// edge cases where we select the wrong import path.
7163
fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option<String> {
7264
// Get the outermost definition for the moduledef. This is used to resolve the public path to the type,
7365
// then we can join the method, field, etc onto it if required.
@@ -396,7 +388,7 @@ mod tests {
396388

397389
fn check(ra_fixture: &str, expect: Expect) {
398390
let (analysis, position) = analysis_and_position(ra_fixture);
399-
let url = analysis.external_docs(position).unwrap().unwrap();
391+
let url = analysis.external_docs(position).unwrap().expect("could not find url for symbol");
400392

401393
expect.assert_eq(&url)
402394
}
@@ -474,4 +466,29 @@ pub struct Foo {
474466
expect![[r##"https://docs.rs/test/*/test/struct.Foo.html#structfield.field"##]],
475467
);
476468
}
469+
470+
// FIXME: ImportMap will return re-export paths instead of public module
471+
// paths. The correct path to documentation will never be a re-export.
472+
// This problem stops us from resolving stdlib items included in the prelude
473+
// such as `Option::Some` correctly.
474+
#[ignore = "ImportMap may return re-exports"]
475+
#[test]
476+
fn test_reexport_order() {
477+
check(
478+
r#"
479+
pub mod wrapper {
480+
pub use module::Item;
481+
482+
pub mod module {
483+
pub struct Item;
484+
}
485+
}
486+
487+
fn foo() {
488+
let bar: wrapper::It<|>em;
489+
}
490+
"#,
491+
expect![[r#"https://docs.rs/test/*/test/wrapper/module/struct.Item.html"#]],
492+
)
493+
}
477494
}

0 commit comments

Comments
 (0)