Closed
Description
In #87078, we arrived at the following situation:
error: incompatible link kind for `Foo::bar`
--> $DIR/field-ice.rs:5:6
|
LL | /// [`Foo::bar()`]
| ^^^^^^^^^^^^ help: to link to the field, remove the disambiguator: ``Foo::bar``
I want to underline this part in particular:
``Foo::bar``
Having two backticks is very weird. What I suggest instead is to reduce the "^^^^^" underlining part in order to not include backticks in it so then they can be removed from the error message as well, which would give:
error: incompatible link kind for `Foo::bar`
--> $DIR/field-ice.rs:5:6
|
LL | /// [`Foo::bar()`]
| ^^^^^^^^^^ help: to link to the field, remove the disambiguator: `Foo::bar`
I'll do it in the next days if no one does until then. :)
cc @jyn514
Metadata
Metadata
Assignees
Labels
Area: Intra-doc links, the ability to link to items in docs by nameCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
estebank commentedon Jul 16, 2021
You can fix this by using a
span_suggestion_verbose
instead ofspan_suggestion
:rust/src/librustdoc/passes/collect_intra_doc_links.rs
Line 2110 in c49895d
It'll take more vertical space, but it's ok.
If someone picks this up as their first contribution, you need to
--bless
the.stderr
test files by running./x.py test src/test/rustdoc-ui --stage 1 --bless
from the root of the repo directory.b41sh commentedon Jul 17, 2021
@rustbot claim
GuillaumeGomez commentedon Jul 17, 2021
@estebank It's a bit different here because we create the spans ourselves because they come from inside a doc comment. So I'm not sure if your suggestion will work out.
Also, in here it's
src/test/rustdoc-ui
, notsrc/test/ui
(but otherwise it's the same). ;)estebank commentedon Jul 17, 2021
@GuillaumeGomez thanks for the correction!
As long as the span was synthesized correctly (including what side of a char the boundary falls on), then just changing the method will work as expected.
GuillaumeGomez commentedon Jul 17, 2021
I had in mind to simply update the span instead in case the string was starting and ending with backticks.
jyn514 commentedon Jul 17, 2021
@GuillaumeGomez look at the code that's already there:
rust/src/librustdoc/passes/collect_intra_doc_links.rs
Lines 2104 to 2108 in c49895d
If you think this shouldn't use
verbose
, remove that instead. But I think it's better to show backticks if the user had them there originally.GuillaumeGomez commentedon Jul 17, 2021
We can take advantage of the span to exclude the backticks from the underlining, so then we can avoid displaying the backticks twice in the suggestion. As for the how, I guess it's fine as long as we get the output we want.
Rollup merge of rust-lang#87285 - GuillaumeGomez:intra-doc-span, r=es…
Rollup merge of rust-lang#87285 - GuillaumeGomez:intra-doc-span, r=es…
Auto merge of rust-lang#87285 - GuillaumeGomez:intra-doc-span, r=este…
GuillaumeGomez commentedon Aug 2, 2021
Fixed in #87285.