Skip to content

doc_lazy_continuation: do not warn on End events #12818

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

Merged
merged 1 commit into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clippy_lints/src/doc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,10 +750,11 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
Start(_tag) | End(_tag) => (), // We don't care about other tags
SoftBreak | HardBreak => {
if !containers.is_empty()
&& let Some((_next_event, next_range)) = events.peek()
&& let Some((next_event, next_range)) = events.peek()
&& let Some(next_span) = fragments.span(cx, next_range.clone())
&& let Some(span) = fragments.span(cx, range.clone())
&& !in_footnote_definition
&& !matches!(next_event, End(_))
{
lazy_continuation::check(
cx,
Expand Down
35 changes: 35 additions & 0 deletions tests/ui/doc/doc_lazy_list.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,38 @@ fn six() {}
///
/// this is not a lazy continuation
fn seven() {}

#[rustfmt::skip]
// https://github.com/rust-lang/rust-clippy/pull/12770#issuecomment-2118601768
/// Returns a list of ProtocolDescriptors from a Serde JSON input.
///
/// Defined Protocol Identifiers for the Protocol Descriptor
/// We intentionally omit deprecated profile identifiers.
/// From Bluetooth Assigned Numbers:
/// https://www.bluetooth.com/specifications/assigned-numbers/service-discovery
///
/// # Arguments
/// * `protocol_descriptors`: A Json Representation of the ProtocolDescriptors
/// to set up. Example:
/// 'protocol_descriptors': [
//~^ ERROR: doc list item missing indentation
/// {
/// 'protocol': 25, # u64 Representation of ProtocolIdentifier::AVDTP
/// 'params': [
/// {
/// 'data': 0x0103 # to indicate 1.3
/// },
/// {
/// 'data': 0x0105 # to indicate 1.5
/// }
/// ]
/// },
/// {
/// 'protocol': 1, # u64 Representation of ProtocolIdentifier::SDP
/// 'params': [{
/// 'data': 0x0019
/// }]
/// }
/// ]
//~^ ERROR: doc list item missing indentation
fn eight() {}
35 changes: 35 additions & 0 deletions tests/ui/doc/doc_lazy_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,38 @@ fn six() {}
///
/// this is not a lazy continuation
fn seven() {}

#[rustfmt::skip]
// https://github.com/rust-lang/rust-clippy/pull/12770#issuecomment-2118601768
/// Returns a list of ProtocolDescriptors from a Serde JSON input.
///
/// Defined Protocol Identifiers for the Protocol Descriptor
/// We intentionally omit deprecated profile identifiers.
/// From Bluetooth Assigned Numbers:
/// https://www.bluetooth.com/specifications/assigned-numbers/service-discovery
///
/// # Arguments
/// * `protocol_descriptors`: A Json Representation of the ProtocolDescriptors
/// to set up. Example:
/// 'protocol_descriptors': [
//~^ ERROR: doc list item missing indentation
/// {
/// 'protocol': 25, # u64 Representation of ProtocolIdentifier::AVDTP
/// 'params': [
/// {
/// 'data': 0x0103 # to indicate 1.3
/// },
/// {
/// 'data': 0x0105 # to indicate 1.5
/// }
/// ]
/// },
/// {
/// 'protocol': 1, # u64 Representation of ProtocolIdentifier::SDP
/// 'params': [{
/// 'data': 0x0019
/// }]
/// }
/// ]
//~^ ERROR: doc list item missing indentation
fn eight() {}
26 changes: 25 additions & 1 deletion tests/ui/doc/doc_lazy_list.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,29 @@ help: indent this line
LL | /// and so should this
| ++

error: aborting due to 9 previous errors
error: doc list item missing indentation
--> tests/ui/doc/doc_lazy_list.rs:56:5
|
LL | /// 'protocol_descriptors': [
| ^
|
= help: if this is supposed to be its own paragraph, add a blank line
help: indent this line
|
LL | /// 'protocol_descriptors': [
| +

error: doc list item missing indentation
--> tests/ui/doc/doc_lazy_list.rs:75:5
|
LL | /// ]
| ^
|
= help: if this is supposed to be its own paragraph, add a blank line
help: indent this line
|
LL | /// ]
| +

error: aborting due to 11 previous errors