forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rustdoc-search: add impl disambiguator to duplicate assoc items
Helps with rust-lang#90929 This changes the search results, specifically, when there's more than one impl with an associated item with the same name. For example, the search queries `simd<i8> -> simd<i8>` and `simd<i64> -> simd<i64>` don't link to the same function, but most of the functions have the same names. This change should probably be FCP-ed, especially since it adds a new anchor link format for `main.js` to handle, so that URLs like `struct.Vec.html#impl-AsMut<[T]>-for-Vec<T,+A>/method.as_mut` redirect to `struct.Vec.html#method.as_mut-2`. It's a strange design, but there are a few reasons for it: * I'd like to avoid making the HTML bigger. Obviously, fixing this bug is going to add at least a little more data to the search index, but adding more HTML penalises viewers for the benefit of searchers. * Breaking `struct.Vec.html#method.len` would also be a disappointment. On the other hand: * The path-style anchors might be less prone to link rot than the numbered anchors. It's definitely less likely to have URLs that appear to "work", but silently point at the wrong thing. * This commit arranges the path-style anchor to redirect to the numbered anchor. Nothing stops rustdoc from doing the opposite, making path-style anchors the default and redirecting the "legacy" numbered ones.
- Loading branch information
Showing
11 changed files
with
292 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// ignore-tidy-linelength | ||
|
||
// Checks that, if a type has two methods with the same name, they both get | ||
// linked correctly. | ||
goto: "file://" + |DOC_PATH| + "/test_docs/index.html" | ||
|
||
// This should link to the inherent impl | ||
write: (".search-input", "ZyxwvutMethodDisambiguation -> bool") | ||
// To be SURE that the search will be run. | ||
press-key: 'Enter' | ||
// Waiting for the search results to appear... | ||
wait-for: "#search-tabs" | ||
// Check the disambiguated link. | ||
assert-count: ("a.result-method", 1) | ||
assert-attribute: ("a.result-method", { | ||
"href": "../test_docs/struct.ZyxwvutMethodDisambiguation.html#impl-ZyxwvutMethodDisambiguation/method.method_impl_disambiguation" | ||
}) | ||
click: "a.result-method" | ||
wait-for: "#impl-ZyxwvutMethodDisambiguation" | ||
assert-document-property: ({ | ||
"URL": "struct.ZyxwvutMethodDisambiguation.html#method.method_impl_disambiguation" | ||
}, ENDS_WITH) | ||
|
||
goto: "file://" + |DOC_PATH| + "/test_docs/index.html" | ||
|
||
// This should link to the trait impl | ||
write: (".search-input", "ZyxwvutMethodDisambiguation, usize -> usize") | ||
// To be SURE that the search will be run. | ||
press-key: 'Enter' | ||
// Waiting for the search results to appear... | ||
wait-for: "#search-tabs" | ||
// Check the disambiguated link. | ||
assert-count: ("a.result-method", 1) | ||
assert-attribute: ("a.result-method", { | ||
"href": "../test_docs/struct.ZyxwvutMethodDisambiguation.html#impl-ZyxwvutTrait-for-ZyxwvutMethodDisambiguation/method.method_impl_disambiguation" | ||
}) | ||
click: "a.result-method" | ||
wait-for: "#impl-ZyxwvutMethodDisambiguation" | ||
assert-document-property: ({ | ||
"URL": "struct.ZyxwvutMethodDisambiguation.html#method.method_impl_disambiguation-1" | ||
}, ENDS_WITH) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.