Preserve fn and {} for start_fn so that rustdoc generates correct links#341
Conversation
|
I want to mention that I fixed a typo in |
|
Seems like the failing CIs are caused by unused function lints in the sandbox/benchmark. Not sure what to do with them though. |
|
Jobs in Lines 37 to 47 in c0e4356 Tests in |
|
Merged unstable CI fixes #342. If you push any new commit or rebase the branch, CI should start using the updated version of code in master |
|
I've made a merge commit to update my branch |
|
I've done a rewrite of my implementation. It now only preserves a |
|
Just checked the CI results, seems like I blocked out |
|
Seems like part of This seems to not be the case in the MSRV versions where Should I add |
|
I've managed to make it so that before Rust version Edit: Seems like the lifetime elision errors aren't just generated by |
Looks like CI is green now. Are you sure there are any more lint problems left? |
|
I don't actually think that the lints were triggered by I tested with a few more examples and it seems like the issues are caused by internal clippy bugs (link to github issues page with relevant tags) making the lint trigger on some false positives. The lint issues I mentioned were my own (local) test cases which was why they triggered the niche false positives. We don't need to do anything for the lint problems I mentioned, the CI is right. Edit: Forgot to mention that the false positives are already fixed on stable. |
|
Seems like this PR is ready. Any things that still need changing? |
|
Alright, thank you for the contribution! I'll create a new patch with this after merge |
Preserve
fnand{}duringstart_fnconstructionCloses #57.
This PR changes the generation of
start_fnsuch that it reuses thefnkeyword and{}tokens from the original definition.This fix works because rustdoc only considers the spans of the first and last tokens when determining the span of a function. In our case, the start token is
pub,constorfn. The ending token is}. The original code already preservespubandconstso I have added code for preservingfnand{}.The original implementation relies on
quote!for generating{,}andfnwhich default toSpan::call_site()which is why rustdoc linked to the macro callsite instead of the original function.Seeing the changes
Some methods in the bon sandbox such as
bon/bon-sandbox/src/docs_comparison/methods.rs
Lines 10 to 26 in c0e4356
cargo doc --package bon-sandbox --open.Possible future improvements
Since rustdoc only cares about the start and end tokens, it is theoretically possible to modify builder method generation such that it also reuses the spans of the original struct member/parameter definitions (not implemented in this PR). This would be more complicated because you would have to assign spans from one type of token to another type of token which I haven't tested yet. I might make an issue for that later after digging through more of the codebase and thinking a bit more.