File tree 3 files changed +52
-7
lines changed
src/librustdoc/html/static/js
3 files changed +52
-7
lines changed Original file line number Diff line number Diff line change @@ -390,24 +390,30 @@ function preLoadCss(cssUrl) {
390
390
if ( splitAt !== - 1 ) {
391
391
const implId = savedHash . slice ( 0 , splitAt ) ;
392
392
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 (
397
402
`[id^="${ assocId } "]` ) ,
398
403
item => {
399
- const numbered = / ( [ ^ - ] + ) - ( [ 0 - 9 ] + ) / . exec ( item . id ) ;
404
+ const numbered = / ^ ( . + ? ) - ( [ 0 - 9 ] + ) $ / . exec ( item . id ) ;
400
405
if ( item . id === assocId || ( numbered && numbered [ 1 ] === assocId ) ) {
401
406
openParentDetails ( item ) ;
402
407
item . scrollIntoView ( ) ;
403
408
// Let the section expand itself before trying to highlight
404
409
setTimeout ( ( ) => {
405
410
window . location . replace ( "#" + item . id ) ;
406
411
} , 0 ) ;
412
+ return true ;
407
413
}
408
414
} ,
409
415
) ;
410
- }
416
+ } ) ;
411
417
}
412
418
}
413
419
}
Original file line number Diff line number Diff line change @@ -41,3 +41,24 @@ assert-document-property: ({
41
41
"URL": "struct.ZyxwvutMethodDisambiguation.html#method.method_impl_disambiguation-1"
42
42
}, ENDS_WITH)
43
43
assert: "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