Skip to content

internal: turn PhantomPinned error into warnings#135

Open
nbdd0121 wants to merge 1 commit intomainfrom
dev/warn
Open

internal: turn PhantomPinned error into warnings#135
nbdd0121 wants to merge 1 commit intomainfrom
dev/warn

Conversation

@nbdd0121
Copy link
Copy Markdown
Member

The PhantomPinned detection is just a lint, and is emitted as an error because there is no compile_warning!() macro, and proc-macro-diagnostics is not stable.

Use of #[deprecated = ""] attribute to approximate custom proc-macro warnings. A new line is added before message for visual clarity.

An example warning with this trick looks like this:

warning: use of deprecated function `_::warn`:
         The field `pin` of type `PhantomPinned` only has an effect if it has the `#[pin]` attribute
 --> test.rs:9:5
  |
9 |     pin: marker::PhantomPinned,
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^

Closes #51

@nbdd0121 nbdd0121 requested a review from BennoLossin April 24, 2026 13:04
The `PhantomPinned` detection is just a lint, and is emitted as an error
because there is no `compile_warning!()` macro, and
`proc-macro-diagnostics` is not stable.

Use of `#[deprecated = ""]` attribute to approximate custom proc-macro
warnings. A new line is added before message for visual clarity.

An example warning with this trick looks like this:

    warning: use of deprecated function `_::warn`:
             The field `pin` of type `PhantomPinned` only has an effect if it has the `#[pin]` attribute
     --> test.rs:9:5
      |
    9 |     pin: marker::PhantomPinned,
      |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^

Suggested-by: Benno Lossin <lossin@kernel.org>
Link: #51
Signed-off-by: Gary Guo <gary@garyguo.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

PhantomPinned detection of #[pin_data] replaces original path with ::core::marker::PhantomPinned

1 participant