Error says std might implement Send for types which are defined as !Send
@asquared31415 is already working on this.
Since Sep 11, 2025.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
use std::marker::PhantomData;
struct MyType {
_definitely_not_thread_safe: PhantomData<*mut ()>,
}
impl<T: Send> From<T> for MyType {
fn from(_: T) -> MyType {
todo!()
}
}
I expected to see this happen: It compiles, because there is no conflict - MyType clearly doesn't implement Send, so blanket implementation for T: Send is valid and shouldn't conflict with From<MyType> for MyType.
Instead, this happened:
error[E0119]: conflicting implementations of trait `From<MyType>` for type `MyType`
--> <source>:7:1
|
7 | impl<T: Send> From<T> for MyType {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate `core`:
- impl<T> From<T> for T;
= note: upstream crates may add a new impl of trait `std::marker::Send` for type `std::marker::PhantomData<*mut ()>` in future versions
This error seems wrong or misleading at least. After all, the whole point of using marker type in this way is to make something as non-Send/non-Sync.
I know of the unstable negative_impls feature, which would have the intended behaviour here even without a marker, but I'd assume that at least Rust core would already use negative trait impls for built-in types. Indeed, what makes such error even more confusing is that negative trait impl is exactly what Rust docs renders for these types:
Meta
(applies to all versions of the compiler, it's a language issue)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.