Skip to content

Commit df65291

Browse files
committed
Auto merge of rust-lang#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`
2 parents 6714eff + 9def82d commit df65291

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

clippy_lints/src/doc.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,12 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
578578
// text "http://example.com" by pulldown-cmark
579579
continue;
580580
}
581-
headers.safety |= in_heading && text.trim() == "Safety";
582-
headers.errors |= in_heading && text.trim() == "Errors";
583-
headers.panics |= in_heading && text.trim() == "Panics";
581+
let trimmed_text = text.trim();
582+
headers.safety |= in_heading && trimmed_text == "Safety";
583+
headers.safety |= in_heading && trimmed_text == "Implementation safety";
584+
headers.safety |= in_heading && trimmed_text == "Implementation Safety";
585+
headers.errors |= in_heading && trimmed_text == "Errors";
586+
headers.panics |= in_heading && trimmed_text == "Panics";
584587
if in_code {
585588
if is_rust {
586589
let edition = edition.unwrap_or_else(|| cx.tcx.sess.edition());

tests/ui/doc_unsafe.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,8 @@ pub mod __macro {
125125
pub unsafe fn f() {}
126126
}
127127
}
128+
129+
/// # Implementation safety
130+
pub unsafe trait DocumentedUnsafeTraitWithImplementationHeader {
131+
fn method();
132+
}

0 commit comments

Comments
 (0)