summaryrefslogtreecommitdiffstats
path: root/tests/ui/kindck
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/kindck
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/kindck')
-rw-r--r--tests/ui/kindck/kindck-copy.rs71
-rw-r--r--tests/ui/kindck/kindck-copy.stderr145
-rw-r--r--tests/ui/kindck/kindck-impl-type-params-2.rs15
-rw-r--r--tests/ui/kindck/kindck-impl-type-params-2.stderr24
-rw-r--r--tests/ui/kindck/kindck-impl-type-params.rs47
-rw-r--r--tests/ui/kindck/kindck-impl-type-params.stderr115
-rw-r--r--tests/ui/kindck/kindck-inherited-copy-bound.curr.stderr55
-rw-r--r--tests/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr41
-rw-r--r--tests/ui/kindck/kindck-inherited-copy-bound.rs34
-rw-r--r--tests/ui/kindck/kindck-nonsendable-1.rs11
-rw-r--r--tests/ui/kindck/kindck-nonsendable-1.stderr25
-rw-r--r--tests/ui/kindck/kindck-send-object.rs26
-rw-r--r--tests/ui/kindck/kindck-send-object.stderr32
-rw-r--r--tests/ui/kindck/kindck-send-object1.rs32
-rw-r--r--tests/ui/kindck/kindck-send-object1.stderr32
-rw-r--r--tests/ui/kindck/kindck-send-object2.rs24
-rw-r--r--tests/ui/kindck/kindck-send-object2.stderr32
-rw-r--r--tests/ui/kindck/kindck-send-owned.rs16
-rw-r--r--tests/ui/kindck/kindck-send-owned.stderr18
-rw-r--r--tests/ui/kindck/kindck-send-unsafe.rs11
-rw-r--r--tests/ui/kindck/kindck-send-unsafe.rs~rust-lang_master12
-rw-r--r--tests/ui/kindck/kindck-send-unsafe.stderr16
22 files changed, 834 insertions, 0 deletions
diff --git a/tests/ui/kindck/kindck-copy.rs b/tests/ui/kindck/kindck-copy.rs
new file mode 100644
index 000000000..6df98c230
--- /dev/null
+++ b/tests/ui/kindck/kindck-copy.rs
@@ -0,0 +1,71 @@
+// Test which of the builtin types are considered POD.
+
+use std::rc::Rc;
+
+fn assert_copy<T:Copy>() { }
+
+trait Dummy { }
+
+#[derive(Copy, Clone)]
+struct MyStruct {
+ x: isize,
+ y: isize,
+}
+
+struct MyNoncopyStruct {
+ x: Box<char>,
+}
+
+fn test<'a,T,U:Copy>(_: &'a isize) {
+ // lifetime pointers are ok...
+ assert_copy::<&'static isize>();
+ assert_copy::<&'a isize>();
+ assert_copy::<&'a str>();
+ assert_copy::<&'a [isize]>();
+
+ // ...unless they are mutable
+ assert_copy::<&'static mut isize>(); //~ ERROR : Copy` is not satisfied
+ assert_copy::<&'a mut isize>(); //~ ERROR : Copy` is not satisfied
+
+ // boxes are not ok
+ assert_copy::<Box<isize>>(); //~ ERROR : Copy` is not satisfied
+ assert_copy::<String>(); //~ ERROR : Copy` is not satisfied
+ assert_copy::<Vec<isize> >(); //~ ERROR : Copy` is not satisfied
+ assert_copy::<Box<&'a mut isize>>(); //~ ERROR : Copy` is not satisfied
+
+ // borrowed object types are generally ok
+ assert_copy::<&'a dyn Dummy>();
+ assert_copy::<&'a (dyn Dummy + Send)>();
+ assert_copy::<&'static (dyn Dummy + Send)>();
+
+ // owned object types are not ok
+ assert_copy::<Box<dyn Dummy>>(); //~ ERROR : Copy` is not satisfied
+ assert_copy::<Box<dyn Dummy + Send>>(); //~ ERROR : Copy` is not satisfied
+
+ // mutable object types are not ok
+ assert_copy::<&'a mut (dyn Dummy + Send)>(); //~ ERROR : Copy` is not satisfied
+
+ // unsafe ptrs are ok
+ assert_copy::<*const isize>();
+ assert_copy::<*const &'a mut isize>();
+
+ // regular old ints and such are ok
+ assert_copy::<isize>();
+ assert_copy::<bool>();
+ assert_copy::<()>();
+
+ // tuples are ok
+ assert_copy::<(isize,isize)>();
+
+ // structs of POD are ok
+ assert_copy::<MyStruct>();
+
+ // structs containing non-POD are not ok
+ assert_copy::<MyNoncopyStruct>(); //~ ERROR : Copy` is not satisfied
+
+ // ref counted types are not ok
+ assert_copy::<Rc<isize>>(); //~ ERROR : Copy` is not satisfied
+}
+
+pub fn main() {
+}
diff --git a/tests/ui/kindck/kindck-copy.stderr b/tests/ui/kindck/kindck-copy.stderr
new file mode 100644
index 000000000..aee2aa98a
--- /dev/null
+++ b/tests/ui/kindck/kindck-copy.stderr
@@ -0,0 +1,145 @@
+error[E0277]: the trait bound `&'static mut isize: Copy` is not satisfied
+ --> $DIR/kindck-copy.rs:27:19
+ |
+LL | assert_copy::<&'static mut isize>();
+ | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `&'static mut isize`
+ |
+note: required by a bound in `assert_copy`
+ --> $DIR/kindck-copy.rs:5:18
+ |
+LL | fn assert_copy<T:Copy>() { }
+ | ^^^^ required by this bound in `assert_copy`
+help: consider removing the leading `&`-reference
+ |
+LL - assert_copy::<&'static mut isize>();
+LL + assert_copy::<isize>();
+ |
+
+error[E0277]: the trait bound `&'a mut isize: Copy` is not satisfied
+ --> $DIR/kindck-copy.rs:28:19
+ |
+LL | assert_copy::<&'a mut isize>();
+ | ^^^^^^^^^^^^^ the trait `Copy` is not implemented for `&'a mut isize`
+ |
+note: required by a bound in `assert_copy`
+ --> $DIR/kindck-copy.rs:5:18
+ |
+LL | fn assert_copy<T:Copy>() { }
+ | ^^^^ required by this bound in `assert_copy`
+help: consider removing the leading `&`-reference
+ |
+LL - assert_copy::<&'a mut isize>();
+LL + assert_copy::<isize>();
+ |
+
+error[E0277]: the trait bound `Box<isize>: Copy` is not satisfied
+ --> $DIR/kindck-copy.rs:31:19
+ |
+LL | assert_copy::<Box<isize>>();
+ | ^^^^^^^^^^ the trait `Copy` is not implemented for `Box<isize>`
+ |
+note: required by a bound in `assert_copy`
+ --> $DIR/kindck-copy.rs:5:18
+ |
+LL | fn assert_copy<T:Copy>() { }
+ | ^^^^ required by this bound in `assert_copy`
+
+error[E0277]: the trait bound `String: Copy` is not satisfied
+ --> $DIR/kindck-copy.rs:32:19
+ |
+LL | assert_copy::<String>();
+ | ^^^^^^ the trait `Copy` is not implemented for `String`
+ |
+note: required by a bound in `assert_copy`
+ --> $DIR/kindck-copy.rs:5:18
+ |
+LL | fn assert_copy<T:Copy>() { }
+ | ^^^^ required by this bound in `assert_copy`
+
+error[E0277]: the trait bound `Vec<isize>: Copy` is not satisfied
+ --> $DIR/kindck-copy.rs:33:19
+ |
+LL | assert_copy::<Vec<isize> >();
+ | ^^^^^^^^^^ the trait `Copy` is not implemented for `Vec<isize>`
+ |
+note: required by a bound in `assert_copy`
+ --> $DIR/kindck-copy.rs:5:18
+ |
+LL | fn assert_copy<T:Copy>() { }
+ | ^^^^ required by this bound in `assert_copy`
+
+error[E0277]: the trait bound `Box<&'a mut isize>: Copy` is not satisfied
+ --> $DIR/kindck-copy.rs:34:19
+ |
+LL | assert_copy::<Box<&'a mut isize>>();
+ | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Box<&'a mut isize>`
+ |
+note: required by a bound in `assert_copy`
+ --> $DIR/kindck-copy.rs:5:18
+ |
+LL | fn assert_copy<T:Copy>() { }
+ | ^^^^ required by this bound in `assert_copy`
+
+error[E0277]: the trait bound `Box<dyn Dummy>: Copy` is not satisfied
+ --> $DIR/kindck-copy.rs:42:19
+ |
+LL | assert_copy::<Box<dyn Dummy>>();
+ | ^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Box<dyn Dummy>`
+ |
+note: required by a bound in `assert_copy`
+ --> $DIR/kindck-copy.rs:5:18
+ |
+LL | fn assert_copy<T:Copy>() { }
+ | ^^^^ required by this bound in `assert_copy`
+
+error[E0277]: the trait bound `Box<dyn Dummy + Send>: Copy` is not satisfied
+ --> $DIR/kindck-copy.rs:43:19
+ |
+LL | assert_copy::<Box<dyn Dummy + Send>>();
+ | ^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Box<dyn Dummy + Send>`
+ |
+note: required by a bound in `assert_copy`
+ --> $DIR/kindck-copy.rs:5:18
+ |
+LL | fn assert_copy<T:Copy>() { }
+ | ^^^^ required by this bound in `assert_copy`
+
+error[E0277]: the trait bound `&'a mut (dyn Dummy + Send + 'a): Copy` is not satisfied
+ --> $DIR/kindck-copy.rs:46:19
+ |
+LL | assert_copy::<&'a mut (dyn Dummy + Send)>();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `&'a mut (dyn Dummy + Send + 'a)`
+ |
+note: required by a bound in `assert_copy`
+ --> $DIR/kindck-copy.rs:5:18
+ |
+LL | fn assert_copy<T:Copy>() { }
+ | ^^^^ required by this bound in `assert_copy`
+
+error[E0277]: the trait bound `MyNoncopyStruct: Copy` is not satisfied
+ --> $DIR/kindck-copy.rs:64:19
+ |
+LL | assert_copy::<MyNoncopyStruct>();
+ | ^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `MyNoncopyStruct`
+ |
+note: required by a bound in `assert_copy`
+ --> $DIR/kindck-copy.rs:5:18
+ |
+LL | fn assert_copy<T:Copy>() { }
+ | ^^^^ required by this bound in `assert_copy`
+
+error[E0277]: the trait bound `Rc<isize>: Copy` is not satisfied
+ --> $DIR/kindck-copy.rs:67:19
+ |
+LL | assert_copy::<Rc<isize>>();
+ | ^^^^^^^^^ the trait `Copy` is not implemented for `Rc<isize>`
+ |
+note: required by a bound in `assert_copy`
+ --> $DIR/kindck-copy.rs:5:18
+ |
+LL | fn assert_copy<T:Copy>() { }
+ | ^^^^ required by this bound in `assert_copy`
+
+error: aborting due to 11 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/kindck/kindck-impl-type-params-2.rs b/tests/ui/kindck/kindck-impl-type-params-2.rs
new file mode 100644
index 000000000..8950fc51e
--- /dev/null
+++ b/tests/ui/kindck/kindck-impl-type-params-2.rs
@@ -0,0 +1,15 @@
+trait Foo {
+}
+
+
+
+impl<T:Copy> Foo for T {
+}
+
+fn take_param<T:Foo>(foo: &T) { }
+
+fn main() {
+ let x: Box<_> = Box::new(3);
+ take_param(&x);
+ //~^ ERROR the trait bound `Box<{integer}>: Copy` is not satisfied
+}
diff --git a/tests/ui/kindck/kindck-impl-type-params-2.stderr b/tests/ui/kindck/kindck-impl-type-params-2.stderr
new file mode 100644
index 000000000..1d26ae51f
--- /dev/null
+++ b/tests/ui/kindck/kindck-impl-type-params-2.stderr
@@ -0,0 +1,24 @@
+error[E0277]: the trait bound `Box<{integer}>: Copy` is not satisfied
+ --> $DIR/kindck-impl-type-params-2.rs:13:16
+ |
+LL | take_param(&x);
+ | ---------- ^^ the trait `Copy` is not implemented for `Box<{integer}>`
+ | |
+ | required by a bound introduced by this call
+ |
+note: required for `Box<{integer}>` to implement `Foo`
+ --> $DIR/kindck-impl-type-params-2.rs:6:14
+ |
+LL | impl<T:Copy> Foo for T {
+ | ---- ^^^ ^
+ | |
+ | unsatisfied trait bound introduced here
+note: required by a bound in `take_param`
+ --> $DIR/kindck-impl-type-params-2.rs:9:17
+ |
+LL | fn take_param<T:Foo>(foo: &T) { }
+ | ^^^ required by this bound in `take_param`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/kindck/kindck-impl-type-params.rs b/tests/ui/kindck/kindck-impl-type-params.rs
new file mode 100644
index 000000000..72a6599c3
--- /dev/null
+++ b/tests/ui/kindck/kindck-impl-type-params.rs
@@ -0,0 +1,47 @@
+// Issue #14061: tests the interaction between generic implementation
+// parameter bounds and trait objects.
+
+use std::marker;
+
+struct S<T>(marker::PhantomData<T>);
+
+trait Gettable<T> {
+ fn get(&self) -> T { panic!() }
+}
+
+impl<T: Send + Copy + 'static> Gettable<T> for S<T> {}
+
+fn f<T>(val: T) {
+ let t: S<T> = S(marker::PhantomData);
+ let a = &t as &dyn Gettable<T>;
+ //~^ ERROR `T` cannot be sent between threads safely
+ //~| ERROR : Copy` is not satisfied
+}
+
+fn g<T>(val: T) {
+ let t: S<T> = S(marker::PhantomData);
+ let a: &dyn Gettable<T> = &t;
+ //~^ ERROR `T` cannot be sent between threads safely
+ //~| ERROR : Copy` is not satisfied
+}
+
+fn foo<'a>() {
+ let t: S<&'a isize> = S(marker::PhantomData);
+ let a = &t as &dyn Gettable<&'a isize>;
+}
+
+fn foo2<'a>() {
+ let t: Box<S<String>> = Box::new(S(marker::PhantomData));
+ let a = t as Box<dyn Gettable<String>>;
+ //~^ ERROR : Copy` is not satisfied
+}
+
+fn foo3<'a>() {
+ struct Foo; // does not impl Copy
+
+ let t: Box<S<Foo>> = Box::new(S(marker::PhantomData));
+ let a: Box<dyn Gettable<Foo>> = t;
+ //~^ ERROR : Copy` is not satisfied
+}
+
+fn main() { }
diff --git a/tests/ui/kindck/kindck-impl-type-params.stderr b/tests/ui/kindck/kindck-impl-type-params.stderr
new file mode 100644
index 000000000..6fd1fc3f7
--- /dev/null
+++ b/tests/ui/kindck/kindck-impl-type-params.stderr
@@ -0,0 +1,115 @@
+error[E0277]: `T` cannot be sent between threads safely
+ --> $DIR/kindck-impl-type-params.rs:16:13
+ |
+LL | let a = &t as &dyn Gettable<T>;
+ | ^^ `T` cannot be sent between threads safely
+ |
+note: required for `S<T>` to implement `Gettable<T>`
+ --> $DIR/kindck-impl-type-params.rs:12:32
+ |
+LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {}
+ | ---- ^^^^^^^^^^^ ^^^^
+ | |
+ | unsatisfied trait bound introduced here
+ = note: required for the cast from `S<T>` to the object type `dyn Gettable<T>`
+help: consider restricting type parameter `T`
+ |
+LL | fn f<T: std::marker::Send>(val: T) {
+ | +++++++++++++++++++
+
+error[E0277]: the trait bound `T: Copy` is not satisfied
+ --> $DIR/kindck-impl-type-params.rs:16:13
+ |
+LL | let a = &t as &dyn Gettable<T>;
+ | ^^ the trait `Copy` is not implemented for `T`
+ |
+note: required for `S<T>` to implement `Gettable<T>`
+ --> $DIR/kindck-impl-type-params.rs:12:32
+ |
+LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {}
+ | ---- ^^^^^^^^^^^ ^^^^
+ | |
+ | unsatisfied trait bound introduced here
+ = note: required for the cast from `S<T>` to the object type `dyn Gettable<T>`
+help: consider restricting type parameter `T`
+ |
+LL | fn f<T: std::marker::Copy>(val: T) {
+ | +++++++++++++++++++
+
+error[E0277]: `T` cannot be sent between threads safely
+ --> $DIR/kindck-impl-type-params.rs:23:31
+ |
+LL | let a: &dyn Gettable<T> = &t;
+ | ^^ `T` cannot be sent between threads safely
+ |
+note: required for `S<T>` to implement `Gettable<T>`
+ --> $DIR/kindck-impl-type-params.rs:12:32
+ |
+LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {}
+ | ---- ^^^^^^^^^^^ ^^^^
+ | |
+ | unsatisfied trait bound introduced here
+ = note: required for the cast from `S<T>` to the object type `dyn Gettable<T>`
+help: consider restricting type parameter `T`
+ |
+LL | fn g<T: std::marker::Send>(val: T) {
+ | +++++++++++++++++++
+
+error[E0277]: the trait bound `T: Copy` is not satisfied
+ --> $DIR/kindck-impl-type-params.rs:23:31
+ |
+LL | let a: &dyn Gettable<T> = &t;
+ | ^^ the trait `Copy` is not implemented for `T`
+ |
+note: required for `S<T>` to implement `Gettable<T>`
+ --> $DIR/kindck-impl-type-params.rs:12:32
+ |
+LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {}
+ | ---- ^^^^^^^^^^^ ^^^^
+ | |
+ | unsatisfied trait bound introduced here
+ = note: required for the cast from `S<T>` to the object type `dyn Gettable<T>`
+help: consider restricting type parameter `T`
+ |
+LL | fn g<T: std::marker::Copy>(val: T) {
+ | +++++++++++++++++++
+
+error[E0277]: the trait bound `String: Copy` is not satisfied
+ --> $DIR/kindck-impl-type-params.rs:35:13
+ |
+LL | let a = t as Box<dyn Gettable<String>>;
+ | ^ the trait `Copy` is not implemented for `String`
+ |
+ = help: the trait `Gettable<T>` is implemented for `S<T>`
+note: required for `S<String>` to implement `Gettable<String>`
+ --> $DIR/kindck-impl-type-params.rs:12:32
+ |
+LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {}
+ | ---- ^^^^^^^^^^^ ^^^^
+ | |
+ | unsatisfied trait bound introduced here
+ = note: required for the cast from `S<String>` to the object type `dyn Gettable<String>`
+
+error[E0277]: the trait bound `Foo: Copy` is not satisfied
+ --> $DIR/kindck-impl-type-params.rs:43:37
+ |
+LL | let a: Box<dyn Gettable<Foo>> = t;
+ | ^ the trait `Copy` is not implemented for `Foo`
+ |
+ = help: the trait `Gettable<T>` is implemented for `S<T>`
+note: required for `S<Foo>` to implement `Gettable<Foo>`
+ --> $DIR/kindck-impl-type-params.rs:12:32
+ |
+LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {}
+ | ---- ^^^^^^^^^^^ ^^^^
+ | |
+ | unsatisfied trait bound introduced here
+ = note: required for the cast from `S<Foo>` to the object type `dyn Gettable<Foo>`
+help: consider annotating `Foo` with `#[derive(Copy)]`
+ |
+LL | #[derive(Copy)]
+ |
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/kindck/kindck-inherited-copy-bound.curr.stderr b/tests/ui/kindck/kindck-inherited-copy-bound.curr.stderr
new file mode 100644
index 000000000..8d45748a6
--- /dev/null
+++ b/tests/ui/kindck/kindck-inherited-copy-bound.curr.stderr
@@ -0,0 +1,55 @@
+error[E0277]: the trait bound `Box<{integer}>: Copy` is not satisfied
+ --> $DIR/kindck-inherited-copy-bound.rs:21:16
+ |
+LL | take_param(&x);
+ | ---------- ^^ the trait `Copy` is not implemented for `Box<{integer}>`
+ | |
+ | required by a bound introduced by this call
+ |
+note: required for `Box<{integer}>` to implement `Foo`
+ --> $DIR/kindck-inherited-copy-bound.rs:14:14
+ |
+LL | impl<T:Copy> Foo for T {
+ | ---- ^^^ ^
+ | |
+ | unsatisfied trait bound introduced here
+note: required by a bound in `take_param`
+ --> $DIR/kindck-inherited-copy-bound.rs:17:17
+ |
+LL | fn take_param<T:Foo>(foo: &T) { }
+ | ^^^ required by this bound in `take_param`
+
+error[E0038]: the trait `Foo` cannot be made into an object
+ --> $DIR/kindck-inherited-copy-bound.rs:28:19
+ |
+LL | let z = &x as &dyn Foo;
+ | ^^^^^^^^ `Foo` cannot be made into an object
+ |
+note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+ --> $DIR/kindck-inherited-copy-bound.rs:10:13
+ |
+LL | trait Foo : Copy {
+ | --- ^^^^ ...because it requires `Self: Sized`
+ | |
+ | this trait cannot be made into an object...
+
+error[E0038]: the trait `Foo` cannot be made into an object
+ --> $DIR/kindck-inherited-copy-bound.rs:28:13
+ |
+LL | let z = &x as &dyn Foo;
+ | ^^ `Foo` cannot be made into an object
+ |
+note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+ --> $DIR/kindck-inherited-copy-bound.rs:10:13
+ |
+LL | trait Foo : Copy {
+ | --- ^^^^ ...because it requires `Self: Sized`
+ | |
+ | this trait cannot be made into an object...
+ = note: required for `&Box<{integer}>` to implement `CoerceUnsized<&dyn Foo>`
+ = note: required by cast to type `&dyn Foo`
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0038, E0277.
+For more information about an error, try `rustc --explain E0038`.
diff --git a/tests/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr b/tests/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr
new file mode 100644
index 000000000..2fbb5a98a
--- /dev/null
+++ b/tests/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr
@@ -0,0 +1,41 @@
+error[E0277]: the trait bound `Box<{integer}>: Copy` is not satisfied
+ --> $DIR/kindck-inherited-copy-bound.rs:21:16
+ |
+LL | take_param(&x);
+ | ---------- ^^ the trait `Copy` is not implemented for `Box<{integer}>`
+ | |
+ | required by a bound introduced by this call
+ |
+note: required for `Box<{integer}>` to implement `Foo`
+ --> $DIR/kindck-inherited-copy-bound.rs:14:14
+ |
+LL | impl<T:Copy> Foo for T {
+ | ---- ^^^ ^
+ | |
+ | unsatisfied trait bound introduced here
+note: required by a bound in `take_param`
+ --> $DIR/kindck-inherited-copy-bound.rs:17:17
+ |
+LL | fn take_param<T:Foo>(foo: &T) { }
+ | ^^^ required by this bound in `take_param`
+
+error[E0038]: the trait `Foo` cannot be made into an object
+ --> $DIR/kindck-inherited-copy-bound.rs:28:13
+ |
+LL | let z = &x as &dyn Foo;
+ | ^^ `Foo` cannot be made into an object
+ |
+note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+ --> $DIR/kindck-inherited-copy-bound.rs:10:13
+ |
+LL | trait Foo : Copy {
+ | --- ^^^^ ...because it requires `Self: Sized`
+ | |
+ | this trait cannot be made into an object...
+ = note: required for `&Box<i32>` to implement `CoerceUnsized<&dyn Foo>`
+ = note: required by cast to type `&dyn Foo`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0038, E0277.
+For more information about an error, try `rustc --explain E0038`.
diff --git a/tests/ui/kindck/kindck-inherited-copy-bound.rs b/tests/ui/kindck/kindck-inherited-copy-bound.rs
new file mode 100644
index 000000000..87d47556b
--- /dev/null
+++ b/tests/ui/kindck/kindck-inherited-copy-bound.rs
@@ -0,0 +1,34 @@
+// Test that Copy bounds inherited by trait are checked.
+//
+// revisions: curr object_safe_for_dispatch
+
+#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))]
+
+
+use std::any::Any;
+
+trait Foo : Copy {
+ fn foo(&self) {}
+}
+
+impl<T:Copy> Foo for T {
+}
+
+fn take_param<T:Foo>(foo: &T) { }
+
+fn a() {
+ let x: Box<_> = Box::new(3);
+ take_param(&x); //[curr]~ ERROR E0277
+ //[object_safe_for_dispatch]~^ ERROR E0277
+}
+
+fn b() {
+ let x: Box<_> = Box::new(3);
+ let y = &x;
+ let z = &x as &dyn Foo;
+ //[curr]~^ ERROR E0038
+ //[curr]~| ERROR E0038
+ //[object_safe_for_dispatch]~^^^ ERROR E0038
+}
+
+fn main() { }
diff --git a/tests/ui/kindck/kindck-nonsendable-1.rs b/tests/ui/kindck/kindck-nonsendable-1.rs
new file mode 100644
index 000000000..b32fd7862
--- /dev/null
+++ b/tests/ui/kindck/kindck-nonsendable-1.rs
@@ -0,0 +1,11 @@
+use std::rc::Rc;
+
+fn foo(_x: Rc<usize>) {}
+
+fn bar<F:FnOnce() + Send>(_: F) { }
+
+fn main() {
+ let x = Rc::new(3);
+ bar(move|| foo(x));
+ //~^ ERROR `Rc<usize>` cannot be sent between threads safely
+}
diff --git a/tests/ui/kindck/kindck-nonsendable-1.stderr b/tests/ui/kindck/kindck-nonsendable-1.stderr
new file mode 100644
index 000000000..cc6e1f59c
--- /dev/null
+++ b/tests/ui/kindck/kindck-nonsendable-1.stderr
@@ -0,0 +1,25 @@
+error[E0277]: `Rc<usize>` cannot be sent between threads safely
+ --> $DIR/kindck-nonsendable-1.rs:9:9
+ |
+LL | bar(move|| foo(x));
+ | --- ------^^^^^^^
+ | | |
+ | | `Rc<usize>` cannot be sent between threads safely
+ | | within this `[closure@$DIR/kindck-nonsendable-1.rs:9:9: 9:15]`
+ | required by a bound introduced by this call
+ |
+ = help: within `[closure@$DIR/kindck-nonsendable-1.rs:9:9: 9:15]`, the trait `Send` is not implemented for `Rc<usize>`
+note: required because it's used within this closure
+ --> $DIR/kindck-nonsendable-1.rs:9:9
+ |
+LL | bar(move|| foo(x));
+ | ^^^^^^
+note: required by a bound in `bar`
+ --> $DIR/kindck-nonsendable-1.rs:5:21
+ |
+LL | fn bar<F:FnOnce() + Send>(_: F) { }
+ | ^^^^ required by this bound in `bar`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/kindck/kindck-send-object.rs b/tests/ui/kindck/kindck-send-object.rs
new file mode 100644
index 000000000..6411e688b
--- /dev/null
+++ b/tests/ui/kindck/kindck-send-object.rs
@@ -0,0 +1,26 @@
+// Test which of the builtin types are considered sendable. The tests
+// in this file all test the "kind" violates detected during kindck.
+// See all `regions-bounded-by-send.rs`
+
+fn assert_send<T:Send>() { }
+trait Dummy { }
+trait Message : Send { }
+
+// careful with object types, who knows what they close over...
+
+fn object_ref_with_static_bound_not_ok() {
+ assert_send::<&'static (dyn Dummy + 'static)>();
+ //~^ ERROR `(dyn Dummy + 'static)` cannot be shared between threads safely [E0277]
+}
+
+fn box_object_with_no_bound_not_ok<'a>() {
+ assert_send::<Box<dyn Dummy>>();
+ //~^ ERROR `dyn Dummy` cannot be sent between threads safely
+}
+
+fn object_with_send_bound_ok() {
+ assert_send::<&'static (dyn Dummy + Sync)>();
+ assert_send::<Box<dyn Dummy + Send>>();
+}
+
+fn main() { }
diff --git a/tests/ui/kindck/kindck-send-object.stderr b/tests/ui/kindck/kindck-send-object.stderr
new file mode 100644
index 000000000..e9bbeeacd
--- /dev/null
+++ b/tests/ui/kindck/kindck-send-object.stderr
@@ -0,0 +1,32 @@
+error[E0277]: `(dyn Dummy + 'static)` cannot be shared between threads safely
+ --> $DIR/kindck-send-object.rs:12:19
+ |
+LL | assert_send::<&'static (dyn Dummy + 'static)>();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'static)` cannot be shared between threads safely
+ |
+ = help: the trait `Sync` is not implemented for `(dyn Dummy + 'static)`
+ = note: required for `&'static (dyn Dummy + 'static)` to implement `Send`
+note: required by a bound in `assert_send`
+ --> $DIR/kindck-send-object.rs:5:18
+ |
+LL | fn assert_send<T:Send>() { }
+ | ^^^^ required by this bound in `assert_send`
+
+error[E0277]: `dyn Dummy` cannot be sent between threads safely
+ --> $DIR/kindck-send-object.rs:17:19
+ |
+LL | assert_send::<Box<dyn Dummy>>();
+ | ^^^^^^^^^^^^^^ `dyn Dummy` cannot be sent between threads safely
+ |
+ = help: the trait `Send` is not implemented for `dyn Dummy`
+ = note: required for `Unique<dyn Dummy>` to implement `Send`
+ = note: required because it appears within the type `Box<dyn Dummy>`
+note: required by a bound in `assert_send`
+ --> $DIR/kindck-send-object.rs:5:18
+ |
+LL | fn assert_send<T:Send>() { }
+ | ^^^^ required by this bound in `assert_send`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/kindck/kindck-send-object1.rs b/tests/ui/kindck/kindck-send-object1.rs
new file mode 100644
index 000000000..787d0f8f6
--- /dev/null
+++ b/tests/ui/kindck/kindck-send-object1.rs
@@ -0,0 +1,32 @@
+// Test which object types are considered sendable. This test
+// is broken into two parts because some errors occur in distinct
+// phases in the compiler. See kindck-send-object2.rs as well!
+
+fn assert_send<T:Send+'static>() { }
+trait Dummy { }
+
+// careful with object types, who knows what they close over...
+fn test51<'a>() {
+ assert_send::<&'a dyn Dummy>();
+ //~^ ERROR `(dyn Dummy + 'a)` cannot be shared between threads safely [E0277]
+}
+fn test52<'a>() {
+ assert_send::<&'a (dyn Dummy + Sync)>();
+}
+
+// ...unless they are properly bounded
+fn test60() {
+ assert_send::<&'static (dyn Dummy + Sync)>();
+}
+fn test61() {
+ assert_send::<Box<dyn Dummy + Send>>();
+}
+
+// closure and object types can have lifetime bounds which make
+// them not ok
+fn test_71<'a>() {
+ assert_send::<Box<dyn Dummy + 'a>>();
+ //~^ ERROR `(dyn Dummy + 'a)` cannot be sent between threads safely
+}
+
+fn main() { }
diff --git a/tests/ui/kindck/kindck-send-object1.stderr b/tests/ui/kindck/kindck-send-object1.stderr
new file mode 100644
index 000000000..11f597fee
--- /dev/null
+++ b/tests/ui/kindck/kindck-send-object1.stderr
@@ -0,0 +1,32 @@
+error[E0277]: `(dyn Dummy + 'a)` cannot be shared between threads safely
+ --> $DIR/kindck-send-object1.rs:10:19
+ |
+LL | assert_send::<&'a dyn Dummy>();
+ | ^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be shared between threads safely
+ |
+ = help: the trait `Sync` is not implemented for `(dyn Dummy + 'a)`
+ = note: required for `&'a (dyn Dummy + 'a)` to implement `Send`
+note: required by a bound in `assert_send`
+ --> $DIR/kindck-send-object1.rs:5:18
+ |
+LL | fn assert_send<T:Send+'static>() { }
+ | ^^^^ required by this bound in `assert_send`
+
+error[E0277]: `(dyn Dummy + 'a)` cannot be sent between threads safely
+ --> $DIR/kindck-send-object1.rs:28:19
+ |
+LL | assert_send::<Box<dyn Dummy + 'a>>();
+ | ^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely
+ |
+ = help: the trait `Send` is not implemented for `(dyn Dummy + 'a)`
+ = note: required for `Unique<(dyn Dummy + 'a)>` to implement `Send`
+ = note: required because it appears within the type `Box<(dyn Dummy + 'a)>`
+note: required by a bound in `assert_send`
+ --> $DIR/kindck-send-object1.rs:5:18
+ |
+LL | fn assert_send<T:Send+'static>() { }
+ | ^^^^ required by this bound in `assert_send`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/kindck/kindck-send-object2.rs b/tests/ui/kindck/kindck-send-object2.rs
new file mode 100644
index 000000000..b797588e4
--- /dev/null
+++ b/tests/ui/kindck/kindck-send-object2.rs
@@ -0,0 +1,24 @@
+// Continue kindck-send-object1.rs.
+
+fn assert_send<T:Send>() { }
+trait Dummy { }
+
+fn test50() {
+ assert_send::<&'static dyn Dummy>();
+ //~^ ERROR `(dyn Dummy + 'static)` cannot be shared between threads safely [E0277]
+}
+
+fn test53() {
+ assert_send::<Box<dyn Dummy>>();
+ //~^ ERROR `dyn Dummy` cannot be sent between threads safely
+}
+
+// ...unless they are properly bounded
+fn test60() {
+ assert_send::<&'static (dyn Dummy + Sync)>();
+}
+fn test61() {
+ assert_send::<Box<dyn Dummy + Send>>();
+}
+
+fn main() { }
diff --git a/tests/ui/kindck/kindck-send-object2.stderr b/tests/ui/kindck/kindck-send-object2.stderr
new file mode 100644
index 000000000..b8af33d0d
--- /dev/null
+++ b/tests/ui/kindck/kindck-send-object2.stderr
@@ -0,0 +1,32 @@
+error[E0277]: `(dyn Dummy + 'static)` cannot be shared between threads safely
+ --> $DIR/kindck-send-object2.rs:7:19
+ |
+LL | assert_send::<&'static dyn Dummy>();
+ | ^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'static)` cannot be shared between threads safely
+ |
+ = help: the trait `Sync` is not implemented for `(dyn Dummy + 'static)`
+ = note: required for `&'static (dyn Dummy + 'static)` to implement `Send`
+note: required by a bound in `assert_send`
+ --> $DIR/kindck-send-object2.rs:3:18
+ |
+LL | fn assert_send<T:Send>() { }
+ | ^^^^ required by this bound in `assert_send`
+
+error[E0277]: `dyn Dummy` cannot be sent between threads safely
+ --> $DIR/kindck-send-object2.rs:12:19
+ |
+LL | assert_send::<Box<dyn Dummy>>();
+ | ^^^^^^^^^^^^^^ `dyn Dummy` cannot be sent between threads safely
+ |
+ = help: the trait `Send` is not implemented for `dyn Dummy`
+ = note: required for `Unique<dyn Dummy>` to implement `Send`
+ = note: required because it appears within the type `Box<dyn Dummy>`
+note: required by a bound in `assert_send`
+ --> $DIR/kindck-send-object2.rs:3:18
+ |
+LL | fn assert_send<T:Send>() { }
+ | ^^^^ required by this bound in `assert_send`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/kindck/kindck-send-owned.rs b/tests/ui/kindck/kindck-send-owned.rs
new file mode 100644
index 000000000..65efb6904
--- /dev/null
+++ b/tests/ui/kindck/kindck-send-owned.rs
@@ -0,0 +1,16 @@
+// Test which of the builtin types are considered sendable.
+
+fn assert_send<T:Send>() { }
+
+// owned content are ok
+fn test30() { assert_send::<Box<isize>>(); }
+fn test31() { assert_send::<String>(); }
+fn test32() { assert_send::<Vec<isize> >(); }
+
+// but not if they own a bad thing
+fn test40() {
+ assert_send::<Box<*mut u8>>();
+ //~^ ERROR `*mut u8` cannot be sent between threads safely
+}
+
+fn main() { }
diff --git a/tests/ui/kindck/kindck-send-owned.stderr b/tests/ui/kindck/kindck-send-owned.stderr
new file mode 100644
index 000000000..b03f56465
--- /dev/null
+++ b/tests/ui/kindck/kindck-send-owned.stderr
@@ -0,0 +1,18 @@
+error[E0277]: `*mut u8` cannot be sent between threads safely
+ --> $DIR/kindck-send-owned.rs:12:19
+ |
+LL | assert_send::<Box<*mut u8>>();
+ | ^^^^^^^^^^^^ `*mut u8` cannot be sent between threads safely
+ |
+ = help: the trait `Send` is not implemented for `*mut u8`
+ = note: required for `Unique<*mut u8>` to implement `Send`
+ = note: required because it appears within the type `Box<*mut u8>`
+note: required by a bound in `assert_send`
+ --> $DIR/kindck-send-owned.rs:3:18
+ |
+LL | fn assert_send<T:Send>() { }
+ | ^^^^ required by this bound in `assert_send`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/kindck/kindck-send-unsafe.rs b/tests/ui/kindck/kindck-send-unsafe.rs
new file mode 100644
index 000000000..4ef30a71f
--- /dev/null
+++ b/tests/ui/kindck/kindck-send-unsafe.rs
@@ -0,0 +1,11 @@
+extern crate core;
+
+fn assert_send<T:Send>() { }
+
+fn test71<'a>() {
+ assert_send::<*mut &'a isize>();
+ //~^ ERROR `*mut &'a isize` cannot be sent between threads safely
+}
+
+fn main() {
+}
diff --git a/tests/ui/kindck/kindck-send-unsafe.rs~rust-lang_master b/tests/ui/kindck/kindck-send-unsafe.rs~rust-lang_master
new file mode 100644
index 000000000..3f0444ec9
--- /dev/null
+++ b/tests/ui/kindck/kindck-send-unsafe.rs~rust-lang_master
@@ -0,0 +1,12 @@
+fn assert_send<T:Send>() { }
+
+// unsafe ptrs are ok unless they point at unsendable things
+fn test70() {
+ assert_send::<*mut int>();
+}
+fn test71<'a>() {
+ assert_send::<*mut &'a int>(); //~ ERROR does not fulfill the required lifetime
+}
+
+fn main() {
+}
diff --git a/tests/ui/kindck/kindck-send-unsafe.stderr b/tests/ui/kindck/kindck-send-unsafe.stderr
new file mode 100644
index 000000000..ceed0053c
--- /dev/null
+++ b/tests/ui/kindck/kindck-send-unsafe.stderr
@@ -0,0 +1,16 @@
+error[E0277]: `*mut &'a isize` cannot be sent between threads safely
+ --> $DIR/kindck-send-unsafe.rs:6:19
+ |
+LL | assert_send::<*mut &'a isize>();
+ | ^^^^^^^^^^^^^^ `*mut &'a isize` cannot be sent between threads safely
+ |
+ = help: the trait `Send` is not implemented for `*mut &'a isize`
+note: required by a bound in `assert_send`
+ --> $DIR/kindck-send-unsafe.rs:3:18
+ |
+LL | fn assert_send<T:Send>() { }
+ | ^^^^ required by this bound in `assert_send`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.