Closed
Description
Summary
multiple_unsafe_ops_per_block currently warns of unsafe code generated by external macros, but it should not. (there is no way for the user to fix it.)
Mentioning @Niki4tap who implemented this lint in #10206.
Lint Name
multiple_unsafe_ops_per_block
Reproducer
I tried this code:
# Cargo.toml
[package]
name = "repro"
version = "0.1.0"
edition = "2021"
[dependencies]
pin-project = "=1.0.12"
// src/lib.rs
#![warn(clippy::multiple_unsafe_ops_per_block)]
#[pin_project::pin_project(project_replace)]
struct S {
f: (),
}
I saw this happen:
warning: this `unsafe` block contains 4 unsafe operations, expected only one
--> src/lib.rs:3:1
|
3 | #[pin_project::pin_project(project_replace)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: unsafe method call occurs here
--> src/lib.rs:3:1
|
3 | #[pin_project::pin_project(project_replace)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: unsafe function call occurs here
--> src/lib.rs:3:1
|
3 | #[pin_project::pin_project(project_replace)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: raw pointer dereference occurs here
--> src/lib.rs:3:1
|
3 | #[pin_project::pin_project(project_replace)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: unsafe function call occurs here
--> src/lib.rs:3:1
|
3 | #[pin_project::pin_project(project_replace)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_unsafe_ops_per_block
note: the lint level is defined here
--> src/lib.rs:1:9
|
1 | #![warn(clippy::multiple_unsafe_ops_per_block)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this warning originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
I expected to see this happen: no warnings
Version
rustc 1.69.0-nightly (e972bc808 2023-01-29)
binary: rustc
commit-hash: e972bc8083d5228536dfd42913c8778b6bb04c8e
commit-date: 2023-01-29
host: aarch64-apple-darwin
release: 1.69.0-nightly
LLVM version: 15.0.7
Additional Labels
No response