-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add new comment_within_doc
lint
#15260
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
base: master
Are you sure you want to change the base?
Add new comment_within_doc
lint
#15260
Conversation
Some changes occurred in clippy_lints/src/doc cc @notriddle |
Lintcheck changes for 938e647
This comment will be updated if you push new changes |
736e910
to
938e647
Compare
If I understand correctly, this finds surrounding cases like: /// ...
// ...
/// ...
But at least #15245 was intended to only lint on empty ones like: /// ...
//
/// ...
The reason was to be more conservative to avoid false positives -- at least in the Linux kernel we expect to be able to write comments together to docs, and we already have 6 adjacent cases we would hit, e.g. one of them: /// Use the given initializer to in-place initialize a `T`.
///
/// If `T: !Unpin` it will not be able to move afterwards.
// We don't implement `InPlaceInit` because `ListArc` is implicitly pinned. This is similar to
// what we do for `Arc`.
#[inline]
pub fn pin_init<E>(init: impl PinInit<T, E>, flags: Flags) -> Result<Self, E> Moreover, I think we should also probably want to lint on adjacent cases, not just surrounded cases, e.g. /// ...
// So I think there are these cases:
Of those, 1 and 3 seem both pretty safe to enable and that was my original intention with the issue. 4 is not something we would want at least for the Linux kernel, since we expect to write those (and we have 6 cases already). And finally 3 could perhaps be interesting for some projects -- in the Linux kernel we don't have any case yet (if I grepped correctly), but when I wrote our coding guidelines about comments I expected it to be possible (https://docs.kernel.org/rust/coding-guidelines.html#comments): /// # Examples
///
// TODO: Find a better example.
/// ```
/// let foo = f(42);
/// ```
|
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.
Not sure if this us supposed to be empty comments only, or if it's supposed to be any comment sandwiched between doc comment lines.
I'm not sure if blank-lines-only would have enough true positives to justify maintaining it. Has this happened more than once?
@@ -0,0 +1,23 @@ | |||
#![warn(clippy::comment_within_doc)] | |||
|
|||
//! Hello//!/ oups |
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.
That "fix" is wrong, isn't it?
Fixes #15245.
Considering how many false positive we might trigger with this lint, I put it into
pedantic
.cc @ojeda
r? @samueltardieu
changelog: Add new
comment_within_doc
lintSummary Notes
Managed by
@rustbot
—see help for details