about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2021-01-15 18:26:16 +0900
committerGitHub <noreply@github.com>2021-01-15 18:26:16 +0900
commitce06df2e4a1d2c8a1d092d39b589bb5d101b6c10 (patch)
treecd26478c2ff94622721f566024dda1714c0f50ad /src/test
parenta584d874172b85d854f2e4d2a3256f7c23e3183a (diff)
parent5ea1d0e865e3a15c054233198622b711ed0b5f86 (diff)
downloadrust-ce06df2e4a1d2c8a1d092d39b589bb5d101b6c10.tar.gz
rust-ce06df2e4a1d2c8a1d092d39b589bb5d101b6c10.zip
Rollup merge of #81008 - tmiasko:generator-layout-err, r=tmandry
Don't ICE when computing a layout of a generator tainted by errors

Fixes #80998.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/generator/layout-error.rs28
-rw-r--r--src/test/ui/generator/layout-error.stderr9
2 files changed, 37 insertions, 0 deletions
diff --git a/src/test/ui/generator/layout-error.rs b/src/test/ui/generator/layout-error.rs
new file mode 100644
index 00000000000..059867277ad
--- /dev/null
+++ b/src/test/ui/generator/layout-error.rs
@@ -0,0 +1,28 @@
+// Verifies that computing a layout of a generator tainted by type errors
+// doesn't ICE. Regression test for #80998.
+//
+// edition:2018
+
+#![feature(type_alias_impl_trait)]
+use std::future::Future;
+
+pub struct Task<F: Future>(F);
+impl<F: Future> Task<F> {
+    fn new() -> Self {
+        todo!()
+    }
+    fn spawn(&self, _: impl FnOnce() -> F) {
+        todo!()
+    }
+}
+
+fn main() {
+    async fn cb() {
+        let a = Foo; //~ ERROR cannot find value `Foo` in this scope
+    }
+
+    type F = impl Future;
+    // Check that statics are inhabited computes they layout.
+    static POOL: Task<F> = Task::new();
+    Task::spawn(&POOL, || cb());
+}
diff --git a/src/test/ui/generator/layout-error.stderr b/src/test/ui/generator/layout-error.stderr
new file mode 100644
index 00000000000..b1a258f4f2c
--- /dev/null
+++ b/src/test/ui/generator/layout-error.stderr
@@ -0,0 +1,9 @@
+error[E0425]: cannot find value `Foo` in this scope
+  --> $DIR/layout-error.rs:21:17
+   |
+LL |         let a = Foo;
+   |                 ^^^ not found in this scope
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.