Uh oh!
There was an error while loading. Please reload this page.
Improve intra doc errors display - #87285
Conversation
rust-highfive
commented
Jul 19, 2021
Some changes occurred in intra-doc-links. cc @jyn514 |
rust-highfive
commented
Jul 19, 2021
r? @ollie27 (rust-highfive has picked a reviewer for you, use r? to override) |
jyn514
commented
Jul 19, 2021
r? @jyn514 |
There was a problem hiding this comment.
It's not actually required that the backticks match - can you also check that the ending backtick is present?
| if dox.bytes().nth(link_range.start) == Some(b'`'){ | |
| if dox.bytes().nth(link_range.start) == Some(b'`')&& dox.bytes().nth(link_range.end) == Some(b'`'){ |
There was a problem hiding this comment.
I was wondering originally why it wasn't checking both the beginning and the end. Well, I guess that answers my question. :)
There was a problem hiding this comment.
Given that these are being shown as verbose already (because there's more than one suggestion), it'd be nice to make the span smaller, only covering the enum@ and ().
There was a problem hiding this comment.
This is an interesting take. Although, not sure it would be an improvement in these cases because they ask to add things, not remove them.
There was a problem hiding this comment.
This would look like this:
error: `foo::bar` is both an enum and a function
--> $DIR/ambiguity.rs:35:43
|
LL | /// Ambiguous non-implied shortcut link [`foo::bar`].
| ^^^^^^^^ ambiguous link
|
help: to link to the enum, prefix with `enum@`
|
LL | /// Ambiguous non-implied shortcut link [`enum@foo::bar`].
| ^^^^^
help: to link to the function, add parentheses
|
LL | /// Ambiguous non-implied shortcut link [`foo::bar()`].
| ^^
which to my eyes looks easier to understand at a glance.
8d91e49 to
28f0a97CompareGuillaumeGomez
commented
Jul 20, 2021
@estebank confirmed that it was already using verbose because there are multiple messages, so on this part I think it's already fine? What is unresolved with the current changes? My complain was that the error message was unclear because of the duplication of the backticks. So instead of including the whole intra-doc element, I only include the part in the backticks. If you have something else in mind, I can do it here as well if you want. |
This comment has been minimized.
This comment has been minimized.
28f0a97 to
7f0cb81Comparejyn514
commented
Jul 20, 2021
It happened in that specific case because there happened to be multiple help messages. Almost always there will be only 0 or 1.
My concern is that showing backticks at all is confusing - showing 1 backtick is actually even more confusing because it's not obviously a bug. Take this diagnostic: https://github.com/rust-lang/rust/blob/7f0cb81c8e4743aacc37167a7299ea0a85f005af/src/test/rustdoc-ui/intra-doc/disambiguator-mismatch.stderr#L1-L5 That makes it look like you should add backticks when they weren't there before, I've seen people running into this in practice: lightningdevkit/rust-lightning#955 (comment) |
GuillaumeGomez
commented
Jul 20, 2021
We use backticks literally everywhere: So this is coherent with all other error outputs. But again, I might misunderstand you...
It's definitely worth adding a new test to ensure the output for an error with just one message then! |
jyn514
commented
Jul 20, 2021
Yes, I understand that. In most parts of the compiler it's not ambiguous, because adding the backtick will cause the code to fail to compile. But in markdown it's valid syntax, and changes the meaning of the code. So we shouldn't suggest it, because it's not easy for the user to tell it's formatting and not part of the suggestion. |
GuillaumeGomez
commented
Jul 20, 2021
I see, it's why I changed the span in order to only underline the parts without backticks so we can use the same logic. But at least I understand your point now. |
estebank
commented
Jul 20, 2021
I'm for the change to make the span smaller. I would also prefer it if we could use |
GuillaumeGomez
commented
Jul 20, 2021
Definitely sounds like an improvement. I'm going to give it a try tomorrow! |
3829068 to
d39a544CompareWith the (great!) help of @estebank, I was able to greatly improve the error output. You can now admire! 😃 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
d39a544 to
9dc0fbbCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
For this case the replacement span was pointing at the point immediately after m, but it needs to start there and end at the current sp.hi().
There was a problem hiding this comment.
Somehow, even after all the other cases have been fixed, this one hasn't 🤔
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
9dc0fbb to
bcf057aCompareGuillaumeGomez
commented
Jul 29, 2021
Updated! |
There was a problem hiding this comment.
I think that you can just always call multipart_suggestion_verbose to get the same effect. Otherwise, it's fine to keep this as is.
There was a problem hiding this comment.
There was a problem hiding this comment.
Ah! I added one, but in a PR that hasn't been merged yet. Disregard for now then.
There was a problem hiding this comment.
This is needed to account for the foo() -> foo! change, so the span covers the () and gets replaced by !:
| letmut sugg = vec![(inner_sp.shrink_to_hi(),"!".to_string())]; | |
| letmut sugg = vec![(inner_sp.shrink_to_hi().with_hi(sp.hi()),"!".to_string())]; |
There was a problem hiding this comment.
Good point, I'll add a specific check for that.
There was a problem hiding this comment.
Actually, it is a valid link to have macro!(), so I'll keep as is. :)
estebank
left a comment
There was a problem hiding this comment.
r=me after addressing the outstanding incorrect suggestion.
Love the results!
bcf057a to
0f7f85eCompareGuillaumeGomez
commented
Jul 29, 2021
@bors: r=estebank |
bors
commented
Jul 29, 2021
📌 Commit 0f7f85e has been approved by |
…tebank Improve intra doc errors display rust-lang#87169 `@jyn514` This is what I had in mind to avoid having duplicated backticks. I also gave a try to simply updating the span for the suggestion/help messages but I think this current one is better because less "noisy". Anyway, that allows you to see the result. ;)
…tebank Improve intra doc errors display rust-lang#87169 ``@jyn514`` This is what I had in mind to avoid having duplicated backticks. I also gave a try to simply updating the span for the suggestion/help messages but I think this current one is better because less "noisy". Anyway, that allows you to see the result. ;)
jyn514
commented
Jul 29, 2021
I see that this has already been put in a rollup, but I'd really prefer to see a test for multiple overlaps in a namespace: #87285 (comment) |
GuillaumeGomez
commented
Jul 29, 2021
I answered on the discussion: I added a function with the same name. ;) |
bors
commented
Jul 29, 2021
bors
commented
Jul 30, 2021
☀️ Test successful - checks-actions |
#87169
@jyn514 This is what I had in mind to avoid having duplicated backticks. I also gave a try to simply updating the span for the suggestion/help messages but I think this current one is better because less "noisy". Anyway, that allows you to see the result. ;)