Checking that we are not missing any `// SAFETY` comments in our `unsafe` blocks is something we have wanted to do for a long time, as well as cleaning up the remaining cases that were not documented [1]. Back when Rust for Linux started, this was something that could have been done via a script, like Rust's `tidy`. Soon after, in Rust 1.58.0, Clippy implemented the `undocumented_unsafe_blocks` lint [2]. Even though the lint has a few false positives, e.g. in some cases where attributes appear between the comment and the `unsafe` block [3], there are workarounds and the lint seems quite usable already. Thus enable the lint now. We still have a few cases to clean up, so just allow those for the moment by writing a `TODO` comment -- some of those may be good candidates for new contributors.
Showing the changes to rust/kernel/workqueue.rs (1 of 16 files). Show all
Unified · Split
| @@ -519,6 +519,7 @@ impl_has_work! { · 518 unmodified lines | ||
| 519 | 519 | impl{T} HasWork<Self> for ClosureWork<T> { self.work } |
| 520 | 520 | } |
| 521 | 521 | |
| 522 | +// SAFETY: TODO. | |
| 522 | 523 | unsafe impl<T, const ID: u64> WorkItemPointer<ID> for Arc<T> |
| 523 | 524 | where |
| 524 | 525 | T: WorkItem<ID, Pointer = Self>, |
| @@ -536,6 +537,7 @@ where · 11 unmodified lines | ||
| 536 | 537 | } |
| 537 | 538 | } |
| 538 | 539 | |
| 540 | +// SAFETY: TODO. | |
| 539 | 541 | unsafe impl<T, const ID: u64> RawWorkItem<ID> for Arc<T> |
| 540 | 542 | where |
| 541 | 543 | T: WorkItem<ID, Pointer = Self>, |
| @@ -564,6 +566,7 @@ where · 22 unmodified lines | ||
| 564 | 566 | } |
| 565 | 567 | } |
| 566 | 568 | |
| 569 | +// SAFETY: TODO. | |
| 567 | 570 | unsafe impl<T, const ID: u64> WorkItemPointer<ID> for Pin<Box<T>> |
| 568 | 571 | where |
| 569 | 572 | T: WorkItem<ID, Pointer = Self>, |
| @@ -583,6 +586,7 @@ where · 13 unmodified lines | ||
| 583 | 586 | } |
| 584 | 587 | } |
| 585 | 588 | |
| 589 | +// SAFETY: TODO. | |
| 586 | 590 | unsafe impl<T, const ID: u64> RawWorkItem<ID> for Pin<Box<T>> |
| 587 | 591 | where |
| 588 | 592 | T: WorkItem<ID, Pointer = Self>, |