Summary
There is some tricky low-level generated code that is written to compile on older Rust versions and can't use &raw syntax, so this lint should not be triggered if implementation is annotated with #[automatically_derived].
Lint Name
borrow_as_ptr
Reproducer
I triggered this with derive_destructure2 crate (obscure, but fairly popular crate):
#[derive(Debug, destructure)]
pub struct MethodMetadataDecoder<'a, 'metadata> {
metadata: &'a mut &'metadata [u8],
container_kind: MethodsContainerKind,
}
https://github.com/nazar-pc/abundance/blob/184e6807a3138939f89a5ba18b550957421eacc1/crates/contracts/core/ab-contracts-common/src/metadata/decode.rs#L358-L362
warning: implicit borrow as raw pointer
--> crates/contracts/core/ab-contracts-common/src/metadata/decode.rs:360:5
|
360 | metadata: &'a mut &'metadata [u8],
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrow_as_ptr
= note: `-W clippy::borrow-as-ptr` implied by `-W clippy::pedantic`
= help: to override `-W clippy::pedantic` add `#[allow(clippy::borrow_as_ptr)]`
help: use a raw pointer instead
|
360 | &raw const metadata: &'a mut &'metadata [u8],
| ++++++++++
warning: implicit borrow as raw pointer
--> crates/contracts/core/ab-contracts-common/src/metadata/decode.rs:361:5
|
361 | container_kind: MethodsContainerKind,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrow_as_ptr
help: use a raw pointer instead
|
361 | &raw const container_kind: MethodsContainerKind,
| ++++++++++
I sent a PR to add #[automatically_derived] attribute, which if accepted will benefit from resolving this issue: NobodyXu/derive_destructure2#6
Version
rustc 1.97.0-nightly (20de910db 2026-05-02)
binary: rustc
commit-hash: 20de910db49d3476ccf49ea79a4b22e2b5dface0
commit-date: 2026-05-02
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.4
Additional Labels
No response
Summary
There is some tricky low-level generated code that is written to compile on older Rust versions and can't use
&rawsyntax, so this lint should not be triggered if implementation is annotated with#[automatically_derived].Lint Name
borrow_as_ptr
Reproducer
I triggered this with derive_destructure2 crate (obscure, but fairly popular crate):
https://github.com/nazar-pc/abundance/blob/184e6807a3138939f89a5ba18b550957421eacc1/crates/contracts/core/ab-contracts-common/src/metadata/decode.rs#L358-L362
I sent a PR to add
#[automatically_derived]attribute, which if accepted will benefit from resolving this issue: NobodyXu/derive_destructure2#6Version
Additional Labels
No response