rust-lang / rust-lang/rust-clippy

Spurious warning in #[allow(clippy::non_send_fields_in_send_ty)] for complex thread-safe wrapper

Open
#8,275 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug I-false-positive L-nursery
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

Summary

Our unsafe implementation of Send for a wrapper type that deliberately strips out all of the !Send components of our complex collection tripped the new clippy lint. This was, in fact the entire point of the type, and why we used an unsafe impl block.

Ping @DJMcNab, the author of that PR.

Lint Name

#[allow(clippy::non_send_fields_in_send_ty)]

Reproducer

See https://github.com/bevyengine/bevy/pull/3519 for the case where this lint triggered spuriously.

The existing warning on World was correct: this impl was in fact unsound, and this PR was an attempt to solve that problem.

Version
rustc 1.60.0-nightly (1bd4fdc94 2022-01-12)
binary: rustc
commit-hash: 1bd4fdc943513e1004f498bbf289279c9784fc6f
commit-date: 2022-01-12
host: x86_64-pc-windows-msvc
release: 1.60.0-nightly
LLVM version: 13.0.0
Additional Labels

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the non_send_fields_in_send_ty warning using the case linked in Bevy PR #3519, then inspect the Clippy lint behavior for the unsafe Send wrapper. Compare it with the existing warning on World; done means the valid wrapper no longer triggers a spurious warning while the unsound World implementation remains diagnosed.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.