diff options
| author | bors <bors@rust-lang.org> | 2021-10-21 21:51:24 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-10-21 21:51:24 +0000 |
| commit | df65291edd6b89a241fed483ab165c32df468746 (patch) | |
| tree | dd89e84f6ec08fcae9c8cc9c65f2e39745325292 | |
| parent | 6714eff09ac91e4149cffea53aaa5204c9198ed3 (diff) | |
| parent | 9def82d382220970760baa9d6480663bec3ebf97 (diff) | |
Auto merge of #7856 - Manishearth:impl-safety, r=xFrednet
missing_safety_doc: Handle 'implementation safety' headers as well We hit some FPs on this in `yoke`, it's somewhat normal to mark trait impl safety with "implementation safety". We could also broaden the check for headers which contain the word "safety" somehow, or split out impl safety stuff to only apply to traits. changelog: handle 'implementation safety' headers in `missing_safety_doc`
| -rw-r--r-- | clippy_lints/src/doc.rs | 9 | ||||
| -rw-r--r-- | tests/ui/doc_unsafe.rs | 5 |
2 files changed, 11 insertions, 3 deletions
diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index 5511c3ea9b6..ec67adf3f87 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -578,9 +578,12 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize // text "http://example.com" by pulldown-cmark continue; } - headers.safety |= in_heading && text.trim() == "Safety"; - headers.errors |= in_heading && text.trim() == "Errors"; - headers.panics |= in_heading && text.trim() == "Panics"; + let trimmed_text = text.trim(); + headers.safety |= in_heading && trimmed_text == "Safety"; + headers.safety |= in_heading && trimmed_text == "Implementation safety"; + headers.safety |= in_heading && trimmed_text == "Implementation Safety"; + headers.errors |= in_heading && trimmed_text == "Errors"; + headers.panics |= in_heading && trimmed_text == "Panics"; if in_code { if is_rust { let edition = edition.unwrap_or_else(|| cx.tcx.sess.edition()); diff --git a/tests/ui/doc_unsafe.rs b/tests/ui/doc_unsafe.rs index 03bb30f9083..4464a21b3b6 100644 --- a/tests/ui/doc_unsafe.rs +++ b/tests/ui/doc_unsafe.rs @@ -125,3 +125,8 @@ pub mod __macro { pub unsafe fn f() {} } } + +/// # Implementation safety +pub unsafe trait DocumentedUnsafeTraitWithImplementationHeader { + fn method(); +} |
