about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2021-08-31 10:41:20 +0200
committerGitHub <noreply@github.com>2021-08-31 10:41:20 +0200
commit0e49feb1e5dcb481c8adc9026aad4ac20dbdcc38 (patch)
tree855cbf930d10a9cc6d2803ea9f0b6967fdf49ede
parentb490f3580bada670576b63ee2523536baa7165e3 (diff)
parentc85529e6288028ecf62635ff001caf0603d67ac2 (diff)
downloadrust-0e49feb1e5dcb481c8adc9026aad4ac20dbdcc38.tar.gz
rust-0e49feb1e5dcb481c8adc9026aad4ac20dbdcc38.zip
Rollup merge of #88409 - spastorino:autoleakage-tait-test, r=oli-obk
Add auto trait leakage TAIT test

r? `@oli-obk`

Related to #86727
-rw-r--r--src/test/ui/type-alias-impl-trait/auto-trait-leakage.rs18
-rw-r--r--src/test/ui/type-alias-impl-trait/auto-trait-leakage2.rs19
-rw-r--r--src/test/ui/type-alias-impl-trait/auto-trait-leakage2.stderr20
-rw-r--r--src/test/ui/type-alias-impl-trait/auto-trait-leakage3.rs21
-rw-r--r--src/test/ui/type-alias-impl-trait/auto-trait-leakage3.stderr22
5 files changed, 100 insertions, 0 deletions
diff --git a/src/test/ui/type-alias-impl-trait/auto-trait-leakage.rs b/src/test/ui/type-alias-impl-trait/auto-trait-leakage.rs
new file mode 100644
index 00000000000..a1584581e6c
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/auto-trait-leakage.rs
@@ -0,0 +1,18 @@
+// check-pass
+
+#![feature(type_alias_impl_trait)]
+#![allow(dead_code)]
+
+mod m {
+    type Foo = impl std::fmt::Debug;
+
+    pub fn foo() -> Foo {
+        22_u32
+    }
+}
+
+fn is_send<T: Send>(_: T) {}
+
+fn main() {
+    is_send(m::foo());
+}
diff --git a/src/test/ui/type-alias-impl-trait/auto-trait-leakage2.rs b/src/test/ui/type-alias-impl-trait/auto-trait-leakage2.rs
new file mode 100644
index 00000000000..745379efa6d
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/auto-trait-leakage2.rs
@@ -0,0 +1,19 @@
+#![feature(type_alias_impl_trait)]
+#![allow(dead_code)]
+
+mod m {
+    use std::rc::Rc;
+
+    type Foo = impl std::fmt::Debug;
+
+    pub fn foo() -> Foo {
+        Rc::new(22_u32)
+    }
+}
+
+fn is_send<T: Send>(_: T) {}
+
+fn main() {
+    is_send(m::foo());
+    //~^ ERROR: `Rc<u32>` cannot be sent between threads safely [E0277]
+}
diff --git a/src/test/ui/type-alias-impl-trait/auto-trait-leakage2.stderr b/src/test/ui/type-alias-impl-trait/auto-trait-leakage2.stderr
new file mode 100644
index 00000000000..d60be4b1ccf
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/auto-trait-leakage2.stderr
@@ -0,0 +1,20 @@
+error[E0277]: `Rc<u32>` cannot be sent between threads safely
+  --> $DIR/auto-trait-leakage2.rs:17:5
+   |
+LL |     type Foo = impl std::fmt::Debug;
+   |                -------------------- within this `impl Debug`
+...
+LL |     is_send(m::foo());
+   |     ^^^^^^^ `Rc<u32>` cannot be sent between threads safely
+   |
+   = help: within `impl Debug`, the trait `Send` is not implemented for `Rc<u32>`
+   = note: required because it appears within the type `impl Debug`
+note: required by a bound in `is_send`
+  --> $DIR/auto-trait-leakage2.rs:14:15
+   |
+LL | fn is_send<T: Send>(_: T) {}
+   |               ^^^^ required by this bound in `is_send`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/type-alias-impl-trait/auto-trait-leakage3.rs b/src/test/ui/type-alias-impl-trait/auto-trait-leakage3.rs
new file mode 100644
index 00000000000..5fb7a9473d3
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/auto-trait-leakage3.rs
@@ -0,0 +1,21 @@
+#![feature(type_alias_impl_trait)]
+#![allow(dead_code)]
+
+// FIXME This should compile, but it currently doesn't
+
+mod m {
+    type Foo = impl std::fmt::Debug;
+    //~^ ERROR: cycle detected when computing type of `m::Foo::{opaque#0}` [E0391]
+
+    pub fn foo() -> Foo {
+        22_u32
+    }
+
+    pub fn bar() {
+        is_send(foo());
+    }
+
+    fn is_send<T: Send>(_: T) {}
+}
+
+fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/auto-trait-leakage3.stderr b/src/test/ui/type-alias-impl-trait/auto-trait-leakage3.stderr
new file mode 100644
index 00000000000..ac7bbd272c7
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/auto-trait-leakage3.stderr
@@ -0,0 +1,22 @@
+error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}`
+  --> $DIR/auto-trait-leakage3.rs:7:16
+   |
+LL |     type Foo = impl std::fmt::Debug;
+   |                ^^^^^^^^^^^^^^^^^^^^
+   |
+note: ...which requires type-checking `m::bar`...
+  --> $DIR/auto-trait-leakage3.rs:14:5
+   |
+LL |     pub fn bar() {
+   |     ^^^^^^^^^^^^
+   = note: ...which requires evaluating trait selection obligation `impl std::fmt::Debug: std::marker::Send`...
+   = note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle
+note: cycle used when checking item types in module `m`
+  --> $DIR/auto-trait-leakage3.rs:6:1
+   |
+LL | mod m {
+   | ^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0391`.