summaryrefslogtreecommitdiffstats
path: root/tests/ui/generator
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
commitd1b2d29528b7794b41e66fc2136e395a02f8529b (patch)
treea4a17504b260206dec3cf55b2dca82929a348ac2 /tests/ui/generator
parentReleasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz
rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/generator')
-rw-r--r--tests/ui/generator/auto-trait-regions.rs6
-rw-r--r--tests/ui/generator/dropck-resume.stderr2
-rw-r--r--tests/ui/generator/dropck.stderr2
-rw-r--r--tests/ui/generator/issue-113279.rs27
-rw-r--r--tests/ui/generator/issue-113279.stderr16
5 files changed, 48 insertions, 5 deletions
diff --git a/tests/ui/generator/auto-trait-regions.rs b/tests/ui/generator/auto-trait-regions.rs
index fd13e4131..350f3cc34 100644
--- a/tests/ui/generator/auto-trait-regions.rs
+++ b/tests/ui/generator/auto-trait-regions.rs
@@ -26,7 +26,7 @@ fn assert_foo<T: Foo>(f: T) {}
fn main() {
// Make sure 'static is erased for generator interiors so we can't match it in trait selection
let x: &'static _ = &OnlyFooIfStaticRef(No);
- let gen = || {
+ let gen = move || {
let x = x;
yield;
assert_foo(x);
@@ -36,7 +36,7 @@ fn main() {
// Allow impls which matches any lifetime
let x = &OnlyFooIfRef(No);
- let gen = || {
+ let gen = move || {
let x = x;
yield;
assert_foo(x);
@@ -44,7 +44,7 @@ fn main() {
assert_foo(gen); // ok
// Disallow impls which relates lifetimes in the generator interior
- let gen = || {
+ let gen = move || {
let a = A(&mut true, &mut true, No);
//~^ temporary value dropped while borrowed
//~| temporary value dropped while borrowed
diff --git a/tests/ui/generator/dropck-resume.stderr b/tests/ui/generator/dropck-resume.stderr
index b0756eb55..ecf92e7e3 100644
--- a/tests/ui/generator/dropck-resume.stderr
+++ b/tests/ui/generator/dropck-resume.stderr
@@ -5,7 +5,7 @@ LL | let z = &mut y;
| ------ mutable borrow occurs here
...
LL | r = y.as_ref().unwrap();
- | ^^^^^^^^^^ immutable borrow occurs here
+ | ^ immutable borrow occurs here
LL |
LL | }
| - mutable borrow might be used here, when `g` is dropped and runs the destructor for generator
diff --git a/tests/ui/generator/dropck.stderr b/tests/ui/generator/dropck.stderr
index b9a3a124a..246ac99f8 100644
--- a/tests/ui/generator/dropck.stderr
+++ b/tests/ui/generator/dropck.stderr
@@ -5,7 +5,7 @@ LL | let (mut gen, cell);
| ---- binding `cell` declared here
LL | cell = Box::new(RefCell::new(0));
LL | let ref_ = Box::leak(Box::new(Some(cell.borrow_mut())));
- | ^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
+ | ^^^^ borrowed value does not live long enough
...
LL | }
| -
diff --git a/tests/ui/generator/issue-113279.rs b/tests/ui/generator/issue-113279.rs
new file mode 100644
index 000000000..f69f804b7
--- /dev/null
+++ b/tests/ui/generator/issue-113279.rs
@@ -0,0 +1,27 @@
+#![feature(generators)]
+
+// `foo` attempts to dereference `""`, which results in an error being reported. Later, the
+// generator transform for `foo` then produces a union which contains a `str` type - unions should
+// not contain unsized types, but this is okay because an error has been reported already.
+// When const propagation happens later in compilation, it attempts to compute the layout of the
+// generator (as part of checking whether something can be const propagated) and in turn attempts
+// to compute the layout of `str` in the context of a union - where this caused an ICE. This test
+// makes sure that doesn't happen again.
+
+fn foo() {
+ let _y = static || {
+ let x = &mut 0;
+ *{
+ yield;
+ x
+ } += match { *"" }.len() {
+ //~^ ERROR cannot move a value of type `str` [E0161]
+ //~^^ ERROR cannot move out of a shared reference [E0507]
+ _ => 0,
+ };
+ };
+}
+
+fn main() {
+ foo()
+}
diff --git a/tests/ui/generator/issue-113279.stderr b/tests/ui/generator/issue-113279.stderr
new file mode 100644
index 000000000..cc9b64ef9
--- /dev/null
+++ b/tests/ui/generator/issue-113279.stderr
@@ -0,0 +1,16 @@
+error[E0161]: cannot move a value of type `str`
+ --> $DIR/issue-113279.rs:17:20
+ |
+LL | } += match { *"" }.len() {
+ | ^^^^^^^ the size of `str` cannot be statically determined
+
+error[E0507]: cannot move out of a shared reference
+ --> $DIR/issue-113279.rs:17:22
+ |
+LL | } += match { *"" }.len() {
+ | ^^^ move occurs because value has type `str`, which does not implement the `Copy` trait
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0161, E0507.
+For more information about an error, try `rustc --explain E0161`.