-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Use different numbers of #
s when expanding documentation comments
#27499
Conversation
r? @huonw (rust_highfive has picked a reviewer for you, use r? to override) |
This solution seems ok since the pretty-printer isn't relied on for its fidelity, but an alternate approach would be to store this information somewhere so the roundtrip doesn't lose information. Edit: I think I misunderstood this patch. |
By looking at the test case exercising this with |
By stable rust source, you mean code will actually stop compiling? |
@huonw I don't know, maybe. The same way barosol can verify that the pretty printer (which is mostly not part of the Rust language itself) behaves this way via a test case, I'm imagining somebody might be able to write code that compiles and runs that can also detect this behavior - in which case the exact behavior requires more careful consideration than an implementation detail would. |
Yeah, I guess code could theoretically have an |
Yes, agree it's better, but not sure if it's the solution that we want to put in the spec. Maybe we can get some other eyes. |
So, the thing is that the "encoding" of documentation comments in macros has already been changed heavily recently.
Therefore, the problems I think are:
|
@rust-lang/lang, this has been waiting on a decision for two (almost three) months now. |
nominating |
Discussed at lang team meeting. Consensus was: I do think @brson raised a good point, but I also feel comfortable with this solution. It seems like a strict improvement on the status quo -- we desugar |
@barosl would you mind adding the comments that @nikomatsakis referred to, before we merge this? |
Ok, so I guess Also, do you think this PR itself is a breaking change? In that case, I will have to append |
@barosl I don't consider this a breaking change, personally. It seems POSSIBLE that someone is relying on this, but highly unlikely, so an annotation seems more likely to produce noise than be of use. But others may have another POV. |
I feel the same as @nikomatsakis |
☔ The latest upstream changes (presumably #29582) made this pull request unmergeable. Please resolve the merge conflicts. |
Was there a decision on this? |
@durka yes: #27499 (comment) PR is considered OK. |
@barosl can you rebase this so we can FINALLY get it merged? :) |
8597e59
to
928fdb2
Compare
Any documentation comments that contain raw-string-looking sequences may pretty-print invalid code when expanding them, as the current logic always uses the `r"literal"` form, without appending any `#`s. This commit calculates the minimum number of `#`s required to wrap a comment correctly and appends `#`s appropriately. Fixes rust-lang#27489.
928fdb2
to
1a8cdc0
Compare
@@ -365,6 +365,9 @@ pub mod builtin { | |||
/// stringification of all the tokens passed to the macro. No restrictions | |||
/// are placed on the syntax of the macro invocation itself. | |||
/// | |||
/// Note that the expanded results of the input tokens may change in the | |||
/// future. You should be careful if you rely on the output. | |||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased, sorry for the huge delay.
Also I added this comment. Please tell me if it lacks some information.
(ping) Does this just need a re-review to move forward? |
@bors r+ |
📌 Commit 1a8cdc0 has been approved by |
@bors rollup |
…nikomatsakis Any documentation comments that contain raw-string-looking sequences may pretty-print invalid code when expanding them, as the current logic always uses the `r"literal"` form, without appending any `#`s. This commit calculates the minimum number of `#`s required to wrap a comment correctly and appends `#`s appropriately. Fixes rust-lang#27489.
Any documentation comments that contain raw-string-looking sequences may pretty-print invalid code when expanding them, as the current logic always uses the
r"literal"
form, without appending any#
s.This commit calculates the minimum number of
#
s required to wrap a comment correctly and appends#
s appropriately.Fixes #27489.