rustdoc-search: add impl disambiguator to duplicate assoc items
Helps with #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.
2023-03-20 23:02:51 +00:00
|
|
|
// ignore-tidy-linelength
|
|
|
|
|
|
|
|
// Checks that, if a type has two methods with the same name, they both get
|
|
|
|
// linked correctly.
|
2023-07-13 17:53:21 +00:00
|
|
|
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
rustdoc-search: add impl disambiguator to duplicate assoc items
Helps with #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.
2023-03-20 23:02:51 +00:00
|
|
|
|
|
|
|
// 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)
|
2023-03-21 17:38:24 +00:00
|
|
|
assert: "section:target"
|
rustdoc-search: add impl disambiguator to duplicate assoc items
Helps with #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.
2023-03-20 23:02:51 +00:00
|
|
|
|
2023-07-13 17:53:21 +00:00
|
|
|
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
rustdoc-search: add impl disambiguator to duplicate assoc items
Helps with #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.
2023-03-20 23:02:51 +00:00
|
|
|
|
|
|
|
// 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)
|
2023-03-21 17:38:24 +00:00
|
|
|
assert: "section:target"
|