-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change handling of doc comments to warn when mis-parsed, not error. #2789
Comments
On second thought, I kind of want to see how the current arrangement works before changing it. There is some amount of value in catching incorrect doc comments, which is sort of what happened with the |
I've run into another case where sections were formatted like |
Nominating for "maturity #4 - well covered" |
It represents a potential backwards incompatibility, so belongs on the backward compatible maturity milestone (or closed as wontfix) |
I don't see how this could be a backwards incompatibility. Fixing the error to be better is no problem and allowing this behavior wouldn't break any valid code. Nominating for production ready. |
Example errors:
Which honestly isn't that bad but it's not good either. |
Visiting for triage, still broken. |
First off, I LOVE you guys and am so glad rust is happening. But I'm frustrated today about this issue. I'm still very new to rust, and it took me hours to figure out the problem, mostly because the error message I get is very misdirecting:
I strongly recommend a better error message, if at all possible, so you don't lose new people to the community. My code was something like this:
|
Display an explicit message about items missing after sugared doc comment attributes. References rust-lang#2789.
…huonw Display an explicit message about items missing after sugared doc comment attributes. References #2789. * I tried looking through `parser.rs` for an appropriate location for `expected_item_err` and ended up putting it just above the first use. Is there a better location? * Did I add enough test cases? Too many? Should I add more cases for the original error message?
I'll take a look at this. |
What if we conditionally convert them to attributes if they are correct, else leave them as a comment and throw a warning? |
(Hi, I'm trying to help make E-easy issues more accessible to newcomers 😸) Checking reproducibility:
which seems clearer than the "expected item after attributes" error, so I think this is fixed
I'm not totally convinced this is the same problem as the others though... but maybe it is? A smaller example:
From #4106:
So it looks like there are still some less-than-ideal cases, and that the fix would be a better error message indicating that there was a doc comment in an unsupported location? Is that correct? If so, where would one start looking to go about making the error message better for the remaining cases? |
Thanks! 😄 |
Yes. We basically want to add a note around https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/parser.rs#L3415 It would be even better if these were parsed correctly, but that's not an easy fix. |
I'll try this! :) |
Should this be closed? |
My comment above is still applicable, 2 years on. If it has been determined to be a separate issue, I can file it separately. Otherwise I think this should stay open. |
I've opened a new issue specifically to deal with @mikedilger's issue: #34516 |
Deprecate kani::slice::any_slice in Kani 0.38.0 (and the related AnySlice struct), and remove it in a later version. Motivation: The Kani library's `slice::any_slice` API is doing more harm than benefit: it is meant to provide a convenient way for users to generate non-deterministic slices, but its current implementation aims to avoid any unsoundness by making sure that for the non-deterministic slice returned by the API, accessing memory beyond the slice length is flagged as an out-of-bounds access (see rust-lang#1009 for details). However, in practical scenarios, using it ends up causing memory to blowup for CBMC. Given that users may not care about this type of unsoundness, which is only possible through using a pointer dereference inside an unsafe block (see discussion in rust-lang#2634). Thus, we should leave it to the user to decide the suitable method for generating slices that fits their verification needs. For example, they can use Kani's alternative API, `any_slice_of_array` that extracts a slice of a non-deterministic start and end from a given array.
…-lang#2860) Kani's `any_slice` function (and related code) has been deprecated since Kani 0.38.0 (see rust-lang#2789). This PR officially obsoletes it by deleting the code. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
Now that we've implemented doc comments as attributes I am doubtful that it was the correct thing to do. There are a lot of positions where attributes aren't valid and now the parser rejects things like:
I was planning putting some smarts into the lexer to detect four slashes and not consider those doc attributes, but then patrick checked in some code like
///< comment
which was rejected.Comments not being treated as whitespace is weird.
The text was updated successfully, but these errors were encountered: