about summary refs log tree commit diff
path: root/src/test/ui/generator
diff options
context:
space:
mode:
authorOli Scherer <github35764891676564198441@oli-obk.de>2021-03-12 12:02:29 +0000
committerOli Scherer <github35764891676564198441@oli-obk.de>2021-03-15 17:36:57 +0000
commit4a6dc8e20328ecb627a519c6704afadcf378a72b (patch)
treeee5607fbd29dd70d9a2bfce4f3e4ea15c8653db9 /src/test/ui/generator
parentcdbb0ff8ca7d6a4d6d858e03ffcc5360ddf60a3f (diff)
Only allow tait defining uses in function and method return position
Diffstat (limited to 'src/test/ui/generator')
-rw-r--r--src/test/ui/generator/layout-error.min_tait.stderr35
-rw-r--r--src/test/ui/generator/layout-error.rs7
-rw-r--r--src/test/ui/generator/metadata-sufficient-for-layout.full_tait.stderr12
-rw-r--r--src/test/ui/generator/metadata-sufficient-for-layout.min_tait.stderr24
-rw-r--r--src/test/ui/generator/metadata-sufficient-for-layout.rs8
5 files changed, 75 insertions, 11 deletions
diff --git a/src/test/ui/generator/layout-error.min_tait.stderr b/src/test/ui/generator/layout-error.min_tait.stderr
index 1be39856883..be469d781b5 100644
--- a/src/test/ui/generator/layout-error.min_tait.stderr
+++ b/src/test/ui/generator/layout-error.min_tait.stderr
@@ -4,6 +4,37 @@ error[E0425]: cannot find value `Foo` in this scope
 LL |         let a = Foo;
    |                 ^^^ not found in this scope
 
-error: aborting due to previous error
+error[E0658]: type alias impl trait is not permitted here
+  --> $DIR/layout-error.rs:31:27
+   |
+LL |     Task::spawn(&POOL, || cb());
+   |                           ^
+   |
+   = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
+   = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
+
+error[E0658]: type alias impl trait is not permitted here
+  --> $DIR/layout-error.rs:30:28
+   |
+LL |     static POOL: Task<F> = Task::new();
+   |                            ^^^^^^^^^^^
+   |
+   = note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
+   = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
+
+error: concrete type differs from previous defining opaque type use
+  --> $DIR/layout-error.rs:31:24
+   |
+LL |     Task::spawn(&POOL, || cb());
+   |                        ^^^^^^^ expected `[type error]`, got `impl Future`
+   |
+note: previous use here
+  --> $DIR/layout-error.rs:30:5
+   |
+LL |     static POOL: Task<F> = Task::new();
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 4 previous errors
 
-For more information about this error, try `rustc --explain E0425`.
+Some errors have detailed explanations: E0425, E0658.
+For more information about an error, try `rustc --explain E0425`.
diff --git a/src/test/ui/generator/layout-error.rs b/src/test/ui/generator/layout-error.rs
index 549c6f6ebe7..9f15a6b2eca 100644
--- a/src/test/ui/generator/layout-error.rs
+++ b/src/test/ui/generator/layout-error.rs
@@ -12,7 +12,7 @@ use std::future::Future;
 
 pub struct Task<F: Future>(F);
 impl<F: Future> Task<F> {
-    fn new() -> Self {
+    const fn new() -> Self {
         todo!()
     }
     fn spawn(&self, _: impl FnOnce() -> F) {
@@ -27,6 +27,7 @@ fn main() {
 
     type F = impl Future;
     // Check that statics are inhabited computes they layout.
-    static POOL: Task<F> = Task::new();
-    Task::spawn(&POOL, || cb());
+    static POOL: Task<F> = Task::new(); //[min_tait]~ ERROR not permitted here
+    Task::spawn(&POOL, || cb()); //[min_tait]~ ERROR type alias impl trait is not permitted here
+    //[min_tait]~^ ERROR concrete type differs from previous
 }
diff --git a/src/test/ui/generator/metadata-sufficient-for-layout.full_tait.stderr b/src/test/ui/generator/metadata-sufficient-for-layout.full_tait.stderr
index 59cd8e04513..ce874c1518c 100644
--- a/src/test/ui/generator/metadata-sufficient-for-layout.full_tait.stderr
+++ b/src/test/ui/generator/metadata-sufficient-for-layout.full_tait.stderr
@@ -1,5 +1,5 @@
 warning: the feature `type_alias_impl_trait` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/metadata-sufficient-for-layout.rs:11:32
+  --> $DIR/metadata-sufficient-for-layout.rs:10:32
    |
 LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_bindings))]
    |                                ^^^^^^^^^^^^^^^^^^^^^
@@ -8,12 +8,18 @@ LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_binding
    = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
 
 warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes
-  --> $DIR/metadata-sufficient-for-layout.rs:11:55
+  --> $DIR/metadata-sufficient-for-layout.rs:10:55
    |
 LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_bindings))]
    |                                                       ^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
 
-warning: 2 warnings emitted
+error: fatal error triggered by #[rustc_error]
+  --> $DIR/metadata-sufficient-for-layout.rs:29:1
+   |
+LL | fn main() {}
+   | ^^^^^^^^^
+
+error: aborting due to previous error; 2 warnings emitted
 
diff --git a/src/test/ui/generator/metadata-sufficient-for-layout.min_tait.stderr b/src/test/ui/generator/metadata-sufficient-for-layout.min_tait.stderr
new file mode 100644
index 00000000000..e2b0d3622a6
--- /dev/null
+++ b/src/test/ui/generator/metadata-sufficient-for-layout.min_tait.stderr
@@ -0,0 +1,24 @@
+error[E0658]: type alias impl trait is not permitted here
+  --> $DIR/metadata-sufficient-for-layout.rs:22:23
+   |
+LL | static A: Option<F> = None;
+   |                       ^^^^
+   |
+   = note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information
+   = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable
+
+error: concrete type differs from previous defining opaque type use
+  --> $DIR/metadata-sufficient-for-layout.rs:25:1
+   |
+LL | fn f() -> F { metadata_sufficient_for_layout::g() }
+   | ^^^^^^^^^^^ expected `[type error]`, got `impl Generator`
+   |
+note: previous use here
+  --> $DIR/metadata-sufficient-for-layout.rs:22:1
+   |
+LL | static A: Option<F> = None;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/generator/metadata-sufficient-for-layout.rs b/src/test/ui/generator/metadata-sufficient-for-layout.rs
index 7d474c82eef..f206093d971 100644
--- a/src/test/ui/generator/metadata-sufficient-for-layout.rs
+++ b/src/test/ui/generator/metadata-sufficient-for-layout.rs
@@ -4,10 +4,9 @@
 // Regression test for #80998.
 //
 // aux-build:metadata-sufficient-for-layout.rs
-// check-pass
 
 // revisions: min_tait full_tait
-#![feature(min_type_alias_impl_trait)]
+#![feature(min_type_alias_impl_trait, rustc_attrs)]
 #![cfg_attr(full_tait, feature(type_alias_impl_trait, impl_trait_in_bindings))]
 //[full_tait]~^ WARN incomplete
 //[full_tait]~| WARN incomplete
@@ -21,7 +20,10 @@ type F = impl Generator<(), Yield = (), Return = ()>;
 
 // Static queries the layout of the generator.
 static A: Option<F> = None;
+//[min_tait]~^ ERROR not permitted here
 
 fn f() -> F { metadata_sufficient_for_layout::g() }
+//[min_tait]~^ ERROR concrete type differs
 
-fn main() {}
+#[rustc_error]
+fn main() {} //[full_tait]~ ERROR