Skip to content

Weird error when implementing Send with a nonexisting type param #75627

Description

@lcnr
struct Foo<T>(T, *const ());

unsafe impl Send for Foo<T> {}

results in

error[E0412]: cannot find type `T` in this scope
 --> src/lib.rs:3:26
  |
3 | unsafe impl Send for Foo<T> {}
  |                          ^ not found in this scope

error[E0277]: `*const ()` cannot be sent between threads safely
  --> src/lib.rs:3:13
   |
3  |   unsafe impl Send for Foo<T> {}
   |               ^^^^ `*const ()` cannot be sent between threads safely
   |
   = help: within `Foo<[type error]>`, the trait `std::marker::Send` is not implemented for `*const ()`
   = note: required because it appears within the type `Foo<[type error]>`

The second error is incorrect and quite confusing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions