File tree Expand file tree Collapse file tree 3 files changed +52
-7
lines changed
src/librustdoc/html/static/js Expand file tree Collapse file tree 3 files changed +52
-7
lines changed Original file line number Diff line number Diff line change @@ -390,24 +390,30 @@ function preLoadCss(cssUrl) {
390390 if ( splitAt !== - 1 ) {
391391 const implId = savedHash . slice ( 0 , splitAt ) ;
392392 const assocId = savedHash . slice ( splitAt + 1 ) ;
393- const implElem = document . getElementById ( implId ) ;
394- if ( implElem && implElem . parentElement . tagName === "SUMMARY" &&
395- implElem . parentElement . parentElement . tagName === "DETAILS" ) {
396- onEachLazy ( implElem . parentElement . parentElement . querySelectorAll (
393+ const implElems = document . querySelectorAll (
394+ `details > summary > section[id^="${ implId } "]` ,
395+ ) ;
396+ onEachLazy ( implElems , implElem => {
397+ const numbered = / ^ ( .+ ?) - ( [ 0 - 9 ] + ) $ / . exec ( implElem . id ) ;
398+ if ( implElem . id !== implId && ( ! numbered || numbered [ 1 ] !== implId ) ) {
399+ return false ;
400+ }
401+ return onEachLazy ( implElem . parentElement . parentElement . querySelectorAll (
397402 `[id^="${ assocId } "]` ) ,
398403 item => {
399- const numbered = / ( [ ^ - ] + ) - ( [ 0 - 9 ] + ) / . exec ( item . id ) ;
404+ const numbered = / ^ ( . + ? ) - ( [ 0 - 9 ] + ) $ / . exec ( item . id ) ;
400405 if ( item . id === assocId || ( numbered && numbered [ 1 ] === assocId ) ) {
401406 openParentDetails ( item ) ;
402407 item . scrollIntoView ( ) ;
403408 // Let the section expand itself before trying to highlight
404409 setTimeout ( ( ) => {
405410 window . location . replace ( "#" + item . id ) ;
406411 } , 0 ) ;
412+ return true ;
407413 }
408414 } ,
409415 ) ;
410- }
416+ } ) ;
411417 }
412418 }
413419 }
Original file line number Diff line number Diff line change @@ -41,3 +41,24 @@ assert-document-property: ({
4141 "URL": "struct.ZyxwvutMethodDisambiguation.html#method.method_impl_disambiguation-1"
4242}, ENDS_WITH)
4343assert: "section:target"
44+
45+ // Checks that, if a type has two methods with the same name,
46+ // and if it has multiple inherent impl blocks, that the numeric
47+ // impl block's disambiguator is also acted upon.
48+ go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=MultiImplBlockStruct->bool"
49+ wait-for: "#search-tabs"
50+ assert-count: ("a.result-method", 1)
51+ assert-attribute: ("a.result-method", {
52+ "href": "../lib2/another_mod/struct.MultiImplBlockStruct.html#impl-MultiImplBlockStruct/method.second_fn"
53+ })
54+ click: "a.result-method"
55+ wait-for: "details:has(summary > #impl-MultiImplBlockStruct-1) > div section[id='method.second_fn']:target"
56+
57+ go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=MultiImplBlockStruct->u32"
58+ wait-for: "#search-tabs"
59+ assert-count: ("a.result-method", 1)
60+ assert-attribute: ("a.result-method", {
61+ "href": "../lib2/another_mod/struct.MultiImplBlockStruct.html#impl-MultiImplBlockTrait-for-MultiImplBlockStruct/method.second_fn"
62+ })
63+ click: "a.result-method"
64+ wait-for: "details:has(summary > #impl-MultiImplBlockTrait-for-MultiImplBlockStruct) > div section[id='method.second_fn-1']:target"
Original file line number Diff line number Diff line change 1- pub fn tadam ( ) { }
1+ pub struct MultiImplBlockStruct ;
2+
3+ impl MultiImplBlockStruct {
4+ pub fn first_fn ( ) { }
5+ }
6+
7+ impl MultiImplBlockStruct {
8+ pub fn second_fn ( self ) -> bool { true }
9+ }
10+
11+ pub trait MultiImplBlockTrait {
12+ fn first_fn ( ) ;
13+ fn second_fn ( self ) -> u32 ;
14+ }
15+
16+ impl MultiImplBlockTrait for MultiImplBlockStruct {
17+ fn first_fn ( ) { }
18+ fn second_fn ( self ) -> u32 { 1 }
19+ }
You can’t perform that action at this time.
0 commit comments