Skip to content

Commit

Permalink
[macros] safety_comment! permits multiple comments (#342)
Browse files Browse the repository at this point in the history
The following is now supported:

    safety_comment! {
        /// SAFETY:
        /// Safety comment here.
        macro_invocation!();
        macro_invocation!();

        /// Previously, this comment (which appears after macro
        /// invocations) was not supported.
        macro_invocation!();
        macro_invocation!();
    }
  • Loading branch information
joshlf authored Sep 7, 2023
1 parent 9c06da2 commit 3773da2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
/// /// Safety comment starts on its own line.
/// macro_1!(args);
/// macro_2! { args };
/// /// SAFETY:
/// /// Subsequent safety comments are allowed but not required.
/// macro_3! { args };
/// }
/// ```
///
/// The macro invocations are emitted, each decorated with the following
/// attribute: `#[allow(clippy::undocumented_unsafe_blocks)]`.
macro_rules! safety_comment {
(#[doc = r" SAFETY:"] $(#[doc = $_doc:literal])* $($macro:ident!$args:tt;)*) => {
(#[doc = r" SAFETY:"] $($(#[doc = $_doc:literal])* $macro:ident!$args:tt;)*) => {
#[allow(clippy::undocumented_unsafe_blocks)]
const _: () = { $($macro!$args;)* };
}
Expand Down

0 comments on commit 3773da2

Please sign in to comment.