Reword E0044 and message for !Send types

- Reword E0044 help.
 - Change error message for types that don't implement `Send`
This commit is contained in:
Esteban Küber 2018-02-10 21:01:49 -08:00
parent 883e74645d
commit 6d8a173980
26 changed files with 66 additions and 55 deletions

View file

@ -1,4 +1,4 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -8,7 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern { fn some_func<T>(x: T); } //~ ERROR E0044
extern {
fn sqrt<T>(f: T) -> T;
//~^ ERROR foreign items may not have type parameters [E0044]
//~| HELP use specialization instead of type parameters by replacing them with concrete types
}
fn main() {
}

View file

@ -1,14 +1,10 @@
error[E0044]: foreign items may not have type parameters
--> $DIR/E0044.rs:11:10
--> $DIR/E0044.rs:12:5
|
LL | extern { fn some_func<T>(x: T); } //~ ERROR E0044
| ^^^^^^^^^^^^^^^^^^^^^^
LL | fn sqrt<T>(f: T) -> T;
| ^^^^^^^^^^^^^^^^^^^^^^
|
help: consider using specialization instead of type parameters
--> $DIR/E0044.rs:11:10
|
LL | extern { fn some_func<T>(x: T); } //~ ERROR E0044
| ^^^^^^^^^^^^^^^^^^^^^^
= help: use specialization instead of type parameters by replacing them with concrete types like `u32`
error: aborting due to previous error

View file

@ -15,6 +15,6 @@ fn main() {
// `Cell` is not `Sync`, so `&Cell` is neither `Sync` nor `Send`,
// `std::fmt::Arguments` used to forget this...
let c = std::cell::Cell::new(42);
send(format_args!("{:?}", c)); //~ ERROR Sync` is not satisfied
sync(format_args!("{:?}", c)); //~ ERROR Sync` is not satisfied
send(format_args!("{:?}", c)); //~ ERROR E0277
sync(format_args!("{:?}", c)); //~ ERROR E0277
}

View file

@ -1,7 +1,7 @@
error[E0277]: the trait bound `*mut std::ops::Fn() + 'static: std::marker::Sync` is not satisfied in `[std::fmt::ArgumentV1<'_>]`
error[E0277]: `*mut std::ops::Fn() + 'static` cannot be shared between threads safely
--> $DIR/send-sync.rs:18:5
|
LL | send(format_args!("{:?}", c)); //~ ERROR Sync` is not satisfied
LL | send(format_args!("{:?}", c)); //~ ERROR E0277
| ^^^^ `*mut std::ops::Fn() + 'static` cannot be shared between threads safely
|
= help: within `[std::fmt::ArgumentV1<'_>]`, the trait `std::marker::Sync` is not implemented for `*mut std::ops::Fn() + 'static`
@ -18,10 +18,10 @@ note: required by `send`
LL | fn send<T: Send>(_: T) {}
| ^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `*mut std::ops::Fn() + 'static: std::marker::Sync` is not satisfied in `std::fmt::Arguments<'_>`
error[E0277]: `*mut std::ops::Fn() + 'static` cannot be shared between threads safely
--> $DIR/send-sync.rs:19:5
|
LL | sync(format_args!("{:?}", c)); //~ ERROR Sync` is not satisfied
LL | sync(format_args!("{:?}", c)); //~ ERROR E0277
| ^^^^ `*mut std::ops::Fn() + 'static` cannot be shared between threads safely
|
= help: within `std::fmt::Arguments<'_>`, the trait `std::marker::Sync` is not implemented for `*mut std::ops::Fn() + 'static`

View file

@ -17,14 +17,14 @@ fn main() {
fn assert_send<T: Send>(_: T) {}
assert_sync(|| {
//~^ ERROR: Sync` is not satisfied
//~^ ERROR: E0277
let a = Cell::new(2);
yield;
});
let a = Cell::new(2);
assert_send(|| {
//~^ ERROR: Sync` is not satisfied
//~^ ERROR: E0277
drop(&a);
yield;
});

View file

@ -1,4 +1,4 @@
error[E0277]: the trait bound `std::cell::Cell<i32>: std::marker::Sync` is not satisfied
error[E0277]: `std::cell::Cell<i32>` cannot be shared between threads safely
--> $DIR/not-send-sync.rs:26:5
|
LL | assert_send(|| {
@ -13,7 +13,7 @@ note: required by `main::assert_send`
LL | fn assert_send<T: Send>(_: T) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the trait bound `std::cell::Cell<i32>: std::marker::Sync` is not satisfied in `[generator@$DIR/not-send-sync.rs:19:17: 23:6 {std::cell::Cell<i32>, ()}]`
error[E0277]: `std::cell::Cell<i32>` cannot be shared between threads safely
--> $DIR/not-send-sync.rs:19:5
|
LL | assert_sync(|| {