-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
The following code: (playground)
fn is_send<T: Send>(_val: T) {}
fn bar() -> impl Copy { 0 as *const () }
fn main() {
is_send(bar());
}
gives the following error message:
error[E0277]: `*const ()` cannot be sent between threads safely
--> src/main.rs:5:5
|
1 | fn is_send<T: Send>(_val: T) {}
| ------- ---- required by this bound in `is_send`
...
5 | is_send(bar());
| ^^^^^^^ `*const ()` cannot be sent between threads safely
|
= help: within `impl std::marker::Copy`, the trait `std::marker::Send` is not implemented for `*const ()`
= note: required because it appears within the type `impl std::marker::Copy`
There are a couple of problems here:
- We refer to
impl std::marker::Copy
within mentioning where it's defined. Since auto traits 'leak through'impl trait
, it would probably be a good idea to reference the function where it's defined to help disambiguate between multiple distinctimpl SomeTrait
types. - We use the generic 'within' terminology, which doesn't really make that make much sense when referring to
impl trait
types. Since we're already exposing the underlying type in the error message, we might want to say something like:
'note: the anonymous return type impl Copy
of function bar
(with underlying type *const ()
) does not implement std::marker::Send
.'
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.