Skip to content

Commit 6d8a173

Browse files
committed
Reword E0044 and message for !Send types
- Reword E0044 help. - Change error message for types that don't implement `Send`
1 parent 883e746 commit 6d8a173

26 files changed

+66
-55
lines changed

src/libcore/marker.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,10 @@ pub trait Copy : Clone {
343343
/// [transmute]: ../../std/mem/fn.transmute.html
344344
#[stable(feature = "rust1", since = "1.0.0")]
345345
#[lang = "sync"]
346-
#[rustc_on_unimplemented = "`{Self}` cannot be shared between threads safely"]
346+
#[rustc_on_unimplemented(
347+
message="`{Self}` cannot be shared between threads safely",
348+
label="`{Self}` cannot be shared between threads safely"
349+
)]
347350
pub unsafe auto trait Sync {
348351
// Empty
349352
}

src/librustc_typeck/check/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,9 +1222,10 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item
12221222
if !generics.types.is_empty() {
12231223
let mut err = struct_span_err!(tcx.sess, item.span, E0044,
12241224
"foreign items may not have type parameters");
1225-
span_help!(&mut err, item.span,
1226-
"consider using specialization instead of \
1227-
type parameters");
1225+
// FIXME: once we start storing spans for type arguments, turn this into a
1226+
// suggestion.
1227+
err.help("use specialization instead of type parameters by replacing them \
1228+
with concrete types like `u32`");
12281229
err.emit();
12291230
}
12301231

src/test/compile-fail/builtin-superkinds-double-superkind.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313

1414
trait Foo : Send+Sync { }
1515

16-
impl <T: Sync+'static> Foo for (T,) { } //~ ERROR `T: std::marker::Send` is not satisfied
16+
impl <T: Sync+'static> Foo for (T,) { }
17+
//~^ ERROR the trait bound `T: std::marker::Send` is not satisfied in `(T,)` [E0277]
1718

18-
impl <T: Send> Foo for (T,T) { } //~ ERROR `T: std::marker::Sync` is not satisfied
19+
impl <T: Send> Foo for (T,T) { }
20+
//~^ ERROR `T` cannot be shared between threads safely [E0277]
1921

2022
impl <T: Send+Sync> Foo for (T,T,T) { } // (ok)
2123

src/test/compile-fail/closure-bounds-subtype.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn give_any<F>(f: F) where F: FnOnce() {
2121

2222
fn give_owned<F>(f: F) where F: FnOnce() + Send {
2323
take_any(f);
24-
take_const_owned(f); //~ ERROR `F: std::marker::Sync` is not satisfied
24+
take_const_owned(f); //~ ERROR `F` cannot be shared between threads safely [E0277]
2525
}
2626

2727
fn main() {}

src/test/compile-fail/extern-types-not-sync-send.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn assert_send<T: ?Sized + Send>() { }
2121

2222
fn main() {
2323
assert_sync::<A>();
24-
//~^ ERROR the trait bound `A: std::marker::Sync` is not satisfied
24+
//~^ ERROR `A` cannot be shared between threads safely [E0277]
2525

2626
assert_send::<A>();
2727
//~^ ERROR the trait bound `A: std::marker::Send` is not satisfied

src/test/compile-fail/issue-16538.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ mod Y {
2121
}
2222

2323
static foo: *const Y::X = Y::foo(Y::x as *const Y::X);
24-
//~^ ERROR `*const usize: std::marker::Sync` is not satisfied
24+
//~^ ERROR `*const usize` cannot be shared between threads safely [E0277]
2525
//~| ERROR cannot refer to other statics by value, use the address-of operator or a constant instead
2626
//~| ERROR E0015
2727

src/test/compile-fail/issue-17718-static-sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ impl !Sync for Foo {}
1717

1818
static FOO: usize = 3;
1919
static BAR: Foo = Foo;
20-
//~^ ERROR: `Foo: std::marker::Sync` is not satisfied
20+
//~^ ERROR: `Foo` cannot be shared between threads safely [E0277]
2121

2222
fn main() {}

src/test/compile-fail/issue-43733-2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl<T> Key<T> {
3333
use std::thread::__FastLocalKeyInner as Key;
3434

3535
static __KEY: Key<()> = Key::new();
36-
//~^ ERROR `std::cell::UnsafeCell<std::option::Option<()>>: std::marker::Sync` is not satisfied
37-
//~| ERROR `std::cell::Cell<bool>: std::marker::Sync` is not satisfied
36+
//~^ ERROR `std::cell::UnsafeCell<std::option::Option<()>>` cannot be shared between threads
37+
//~| ERROR `std::cell::Cell<bool>` cannot be shared between threads safely [E0277]
3838

3939
fn main() {}

src/test/compile-fail/issue-7364.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ use std::cell::RefCell;
1515
// Regression test for issue 7364
1616
static boxed: Box<RefCell<isize>> = box RefCell::new(0);
1717
//~^ ERROR allocations are not allowed in statics
18-
//~| ERROR `std::cell::RefCell<isize>: std::marker::Sync` is not satisfied
18+
//~| ERROR `std::cell::RefCell<isize>` cannot be shared between threads safely [E0277]
1919

2020
fn main() { }

src/test/compile-fail/kindck-send-object.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ trait Message : Send { }
2020

2121
fn object_ref_with_static_bound_not_ok() {
2222
assert_send::<&'static (Dummy+'static)>();
23-
//~^ ERROR : std::marker::Sync` is not satisfied
23+
//~^ ERROR `Dummy + 'static` cannot be shared between threads safely [E0277]
2424
}
2525

2626
fn box_object_with_no_bound_not_ok<'a>() {

0 commit comments

Comments
 (0)