Closed
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
.'