Fix jump-to-def links broken by turbofish syntax#156727
Conversation
|
rustbot has assigned @GuillaumeGomez. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
|
|
||
| pub fn foo() { | ||
| // `PhantomData::<usize>` — `PhantomData` must be linked despite the turbofish. | ||
| //@ has - '//a[@href="{{channel}}/core/marker/struct.PhantomData.html"]' 'PhantomData' |
There was a problem hiding this comment.
The type appears 3 times, so the test is not really checking much. Use a type alias instead for the specific one that you need to be tested. For example:
type TheOne = PhantomData;
let _: TheOne::<usize> = PhantomData;The idea is to make TheOne appears only once. Then you can check like you did with //@ has - '//a[@href="{{channel}}/core/marker/struct.PhantomData.html"]' 'TheOne'.
There was a problem hiding this comment.
An alternative would be to use count but I think it'd be less robust (and readable).
There was a problem hiding this comment.
Switched to checking the local reference link since a type alias links to its own
definition rather than to struct.PhantomData.html.
|
Reminder, once the PR becomes ready for a review, use |
This comment has been minimized.
This comment has been minimized.
Handle turbofish syntax correctly in rustdoc jump-to-def links and add regression tests covering type aliases.
| // `PhantomData::<usize>` — `PhantomData` must be linked despite the turbofish. | ||
| type TheOne = PhantomData<()>; | ||
|
|
||
| //@ has - '//a[@href="#13"]' 'TheOne' |
There was a problem hiding this comment.
That doesn't fix anything. ^^'
There was a problem hiding this comment.
Is using an import alias fine
use std::marker::PhantomData as TheOne;
pub fn foo() {
//@ has - '//a[@href="{{channel}}/core/marker/struct.PhantomData.html"]' 'TheOne'
let _: TheOne::<usize>;
}cuz the idea you mentioned
use std::marker::PhantomData;
type TheOne = PhantomData<()>;
pub fn foo() {
//@ has - '//a[@href="{{channel}}/core/marker/struct.PhantomData.html"]' 'TheOne'
let _: TheOne::<usize> = PhantomData;
}it ends up genenrating this html
<a href="https://doc.rust-lang.org/nightly/core/marker/struct.PhantomData.html">std::marker::PhantomData</a>
'<a href="../../foo/fn.foo.html">foo</a>'
'<a href="https://doc.rust-lang.org/nightly/core/marker/struct.PhantomData.html">PhantomData</a>'
'<a href="#13">TheOne</a>'
'<a href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>'
'<a href="https://doc.rust-lang.org/nightly/core/marker/struct.PhantomData.html">PhantomData</a>'`There was a problem hiding this comment.
Ah yes, much better. An aliased import is much better!
|
Thanks! @bors r+ rollup |
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 4b97926 (parent) -> 1f8e04d (this PR) Test differencesShow 5 test diffsStage 1
Stage 2
Additionally, 3 doctest diffs were found. These are ignored, as they are noisy. Job group index
Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 1f8e04d34ab0c1fd9574840aa6db670e41593bfb --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (1f8e04d): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Our benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 0.2%, secondary -4.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary -0.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary -0.0%, secondary -0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 510.83s -> 509.888s (-0.18%) |
Fixes #156706