about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir2
-rw-r--r--tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir2
-rw-r--r--tests/mir-opt/building/match_false_edges.main.built.after.mir4
-rw-r--r--tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff8
-rw-r--r--tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff8
-rw-r--r--tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir2
-rw-r--r--tests/mir-opt/remove_fake_borrows.match_guard.CleanupPostBorrowck.panic-abort.diff8
-rw-r--r--tests/mir-opt/remove_fake_borrows.match_guard.CleanupPostBorrowck.panic-unwind.diff8
-rw-r--r--tests/ui/dropck/coroutine-liveness-1.rs18
-rw-r--r--tests/ui/dropck/coroutine-liveness-2.rs23
-rw-r--r--tests/ui/generator/borrowing.stderr20
-rw-r--r--tests/ui/generator/issue-110929-generator-conflict-error-ice.rs2
-rw-r--r--tests/ui/generator/issue-110929-generator-conflict-error-ice.stderr18
-rw-r--r--tests/ui/generator/retain-resume-ref.stderr7
-rw-r--r--tests/ui/generator/witness-ignore-fake-reads.rs34
-rw-r--r--tests/ui/late-bound-lifetimes/predicate-is-global.rs40
16 files changed, 146 insertions, 58 deletions
diff --git a/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir b/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir
index bd4cd4eb678..9f64a23f37d 100644
--- a/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir
+++ b/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir
@@ -51,7 +51,7 @@ fn full_tested_match() -> () {
     bb5: {
         StorageLive(_6);
         _6 = &((_2 as Some).0: i32);
-        _4 = &shallow _2;
+        _4 = &fake _2;
         StorageLive(_7);
         _7 = guard() -> [return: bb6, unwind: bb12];
     }
diff --git a/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir b/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir
index 595e3ab9224..89f9bafb680 100644
--- a/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir
+++ b/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir
@@ -57,7 +57,7 @@ fn full_tested_match2() -> () {
     bb5: {
         StorageLive(_6);
         _6 = &((_2 as Some).0: i32);
-        _4 = &shallow _2;
+        _4 = &fake _2;
         StorageLive(_7);
         _7 = guard() -> [return: bb6, unwind: bb12];
     }
diff --git a/tests/mir-opt/building/match_false_edges.main.built.after.mir b/tests/mir-opt/building/match_false_edges.main.built.after.mir
index 91fe2f90e35..9a2d89c4816 100644
--- a/tests/mir-opt/building/match_false_edges.main.built.after.mir
+++ b/tests/mir-opt/building/match_false_edges.main.built.after.mir
@@ -78,7 +78,7 @@ fn main() -> () {
     bb8: {
         StorageLive(_7);
         _7 = &((_2 as Some).0: i32);
-        _5 = &shallow _2;
+        _5 = &fake _2;
         StorageLive(_8);
         _8 = guard() -> [return: bb9, unwind: bb20];
     }
@@ -120,7 +120,7 @@ fn main() -> () {
     bb14: {
         StorageLive(_11);
         _11 = &((_2 as Some).0: i32);
-        _5 = &shallow _2;
+        _5 = &fake _2;
         StorageLive(_12);
         StorageLive(_13);
         _13 = (*_11);
diff --git a/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff
index 3e817ff433b..137688ff613 100644
--- a/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff
+++ b/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff
@@ -80,8 +80,8 @@
           _6 = &(_2.1: bool);
           StorageLive(_8);
           _8 = &(_2.2: std::string::String);
--         _3 = &shallow (_2.0: bool);
--         _4 = &shallow (_2.1: bool);
+-         _3 = &fake (_2.0: bool);
+-         _4 = &fake (_2.1: bool);
           StorageLive(_9);
           StorageLive(_10);
           _10 = _1;
@@ -137,8 +137,8 @@
           _6 = &(_2.0: bool);
           StorageLive(_8);
           _8 = &(_2.2: std::string::String);
--         _3 = &shallow (_2.0: bool);
--         _4 = &shallow (_2.1: bool);
+-         _3 = &fake (_2.0: bool);
+-         _4 = &fake (_2.1: bool);
           StorageLive(_12);
           StorageLive(_13);
           _13 = _1;
diff --git a/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff
index 3e817ff433b..137688ff613 100644
--- a/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff
+++ b/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff
@@ -80,8 +80,8 @@
           _6 = &(_2.1: bool);
           StorageLive(_8);
           _8 = &(_2.2: std::string::String);
--         _3 = &shallow (_2.0: bool);
--         _4 = &shallow (_2.1: bool);
+-         _3 = &fake (_2.0: bool);
+-         _4 = &fake (_2.1: bool);
           StorageLive(_9);
           StorageLive(_10);
           _10 = _1;
@@ -137,8 +137,8 @@
           _6 = &(_2.0: bool);
           StorageLive(_8);
           _8 = &(_2.2: std::string::String);
--         _3 = &shallow (_2.0: bool);
--         _4 = &shallow (_2.1: bool);
+-         _3 = &fake (_2.0: bool);
+-         _4 = &fake (_2.1: bool);
           StorageLive(_12);
           StorageLive(_13);
           _13 = _1;
diff --git a/tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir b/tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir
index 7f8eb82c772..8764236bf1f 100644
--- a/tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir
+++ b/tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir
@@ -68,7 +68,7 @@ fn main() -> () {
     }
 
     bb9: {
-        _8 = &shallow _1;
+        _8 = &fake _1;
         StorageLive(_9);
         _9 = _2;
         switchInt(move _9) -> [0: bb11, otherwise: bb10];
diff --git a/tests/mir-opt/remove_fake_borrows.match_guard.CleanupPostBorrowck.panic-abort.diff b/tests/mir-opt/remove_fake_borrows.match_guard.CleanupPostBorrowck.panic-abort.diff
index 33322c41b01..6c469d74439 100644
--- a/tests/mir-opt/remove_fake_borrows.match_guard.CleanupPostBorrowck.panic-abort.diff
+++ b/tests/mir-opt/remove_fake_borrows.match_guard.CleanupPostBorrowck.panic-abort.diff
@@ -34,10 +34,10 @@
       }
   
       bb4: {
--         _4 = &shallow _1;
--         _5 = &shallow (*((_1 as Some).0: &&i32));
--         _6 = &shallow ((_1 as Some).0: &&i32);
--         _7 = &shallow (*(*((_1 as Some).0: &&i32)));
+-         _4 = &fake _1;
+-         _5 = &fake (*((_1 as Some).0: &&i32));
+-         _6 = &fake ((_1 as Some).0: &&i32);
+-         _7 = &fake (*(*((_1 as Some).0: &&i32)));
 +         nop;
 +         nop;
 +         nop;
diff --git a/tests/mir-opt/remove_fake_borrows.match_guard.CleanupPostBorrowck.panic-unwind.diff b/tests/mir-opt/remove_fake_borrows.match_guard.CleanupPostBorrowck.panic-unwind.diff
index 33322c41b01..6c469d74439 100644
--- a/tests/mir-opt/remove_fake_borrows.match_guard.CleanupPostBorrowck.panic-unwind.diff
+++ b/tests/mir-opt/remove_fake_borrows.match_guard.CleanupPostBorrowck.panic-unwind.diff
@@ -34,10 +34,10 @@
       }
   
       bb4: {
--         _4 = &shallow _1;
--         _5 = &shallow (*((_1 as Some).0: &&i32));
--         _6 = &shallow ((_1 as Some).0: &&i32);
--         _7 = &shallow (*(*((_1 as Some).0: &&i32)));
+-         _4 = &fake _1;
+-         _5 = &fake (*((_1 as Some).0: &&i32));
+-         _6 = &fake ((_1 as Some).0: &&i32);
+-         _7 = &fake (*(*((_1 as Some).0: &&i32)));
 +         nop;
 +         nop;
 +         nop;
diff --git a/tests/ui/dropck/coroutine-liveness-1.rs b/tests/ui/dropck/coroutine-liveness-1.rs
new file mode 100644
index 00000000000..aea4d15ad90
--- /dev/null
+++ b/tests/ui/dropck/coroutine-liveness-1.rs
@@ -0,0 +1,18 @@
+// check-pass
+// edition: 2021
+
+// regression test for #116242.
+use std::future;
+
+fn main() {
+    let mut recv = future::ready(());
+    let _combined_fut = async {
+        let _ = || read(&mut recv);
+    };
+
+    drop(recv);
+}
+
+fn read<F: future::Future>(_: &mut F) -> F::Output {
+    todo!()
+}
diff --git a/tests/ui/dropck/coroutine-liveness-2.rs b/tests/ui/dropck/coroutine-liveness-2.rs
new file mode 100644
index 00000000000..416a073c6b9
--- /dev/null
+++ b/tests/ui/dropck/coroutine-liveness-2.rs
@@ -0,0 +1,23 @@
+// check-pass
+// edition: 2021
+
+// regression test found while working on #117134.
+use std::future;
+
+fn main() {
+    let mut recv = future::ready(());
+    let _combined_fut = async {
+        let _ = || read(&mut recv);
+    };
+
+    let _uwu = (String::new(), _combined_fut);
+    // Dropping a coroutine as part of a more complex
+    // types should not add unnecessary liveness
+    // constraints.
+
+    drop(recv);
+}
+
+fn read<F: future::Future>(_: &mut F) -> F::Output {
+    todo!()
+}
diff --git a/tests/ui/generator/borrowing.stderr b/tests/ui/generator/borrowing.stderr
index 03a69fe3623..38e1ace8c4e 100644
--- a/tests/ui/generator/borrowing.stderr
+++ b/tests/ui/generator/borrowing.stderr
@@ -1,24 +1,16 @@
 error[E0597]: `a` does not live long enough
   --> $DIR/borrowing.rs:9:33
    |
+LL |     let _b = {
+   |         -- borrow later stored here
+LL |         let a = 3;
 LL |         Pin::new(&mut || yield &a).resume(())
-   |                       ----------^
-   |                       |         |
-   |                       |         borrowed value does not live long enough
+   |                       --        ^ borrowed value does not live long enough
+   |                       |
    |                       value captured here by generator
-   |                       a temporary with access to the borrow is created here ...
 LL |
 LL |     };
-   |     -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for generator
-   |     |
-   |     `a` dropped here while still borrowed
-   |
-   = note: the temporary is part of an expression at the end of a block;
-           consider forcing this temporary to be dropped sooner, before the block's local variables are dropped
-help: for example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block
-   |
-LL |         let x = Pin::new(&mut || yield &a).resume(()); x
-   |         +++++++                                      +++
+   |     - `a` dropped here while still borrowed
 
 error[E0597]: `a` does not live long enough
   --> $DIR/borrowing.rs:16:20
diff --git a/tests/ui/generator/issue-110929-generator-conflict-error-ice.rs b/tests/ui/generator/issue-110929-generator-conflict-error-ice.rs
index a45479e5300..84510246472 100644
--- a/tests/ui/generator/issue-110929-generator-conflict-error-ice.rs
+++ b/tests/ui/generator/issue-110929-generator-conflict-error-ice.rs
@@ -1,4 +1,5 @@
 // edition:2021
+// check-pass
 #![feature(generators)]
 
 fn main() {
@@ -6,6 +7,5 @@ fn main() {
     || {
         let _c = || yield *&mut *x;
         || _ = &mut *x;
-        //~^ cannot borrow `*x` as mutable more than once at a time
     };
 }
diff --git a/tests/ui/generator/issue-110929-generator-conflict-error-ice.stderr b/tests/ui/generator/issue-110929-generator-conflict-error-ice.stderr
deleted file mode 100644
index 66f0e3d94bd..00000000000
--- a/tests/ui/generator/issue-110929-generator-conflict-error-ice.stderr
+++ /dev/null
@@ -1,18 +0,0 @@
-error[E0499]: cannot borrow `*x` as mutable more than once at a time
-  --> $DIR/issue-110929-generator-conflict-error-ice.rs:8:9
-   |
-LL |         let _c = || yield *&mut *x;
-   |                  --             -- first borrow occurs due to use of `*x` in generator
-   |                  |
-   |                  first mutable borrow occurs here
-LL |         || _ = &mut *x;
-   |         ^^          -- second borrow occurs due to use of `*x` in closure
-   |         |
-   |         second mutable borrow occurs here
-LL |
-LL |     };
-   |     - first borrow might be used here, when `_c` is dropped and runs the destructor for generator
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0499`.
diff --git a/tests/ui/generator/retain-resume-ref.stderr b/tests/ui/generator/retain-resume-ref.stderr
index bc715c7030e..e33310d12d9 100644
--- a/tests/ui/generator/retain-resume-ref.stderr
+++ b/tests/ui/generator/retain-resume-ref.stderr
@@ -4,10 +4,9 @@ error[E0499]: cannot borrow `thing` as mutable more than once at a time
 LL |     gen.as_mut().resume(&mut thing);
    |                         ---------- first mutable borrow occurs here
 LL |     gen.as_mut().resume(&mut thing);
-   |                         ^^^^^^^^^^ second mutable borrow occurs here
-LL |
-LL | }
-   | - first borrow might be used here, when `gen` is dropped and runs the destructor for generator
+   |                  ------ ^^^^^^^^^^ second mutable borrow occurs here
+   |                  |
+   |                  first borrow later used by call
 
 error: aborting due to previous error
 
diff --git a/tests/ui/generator/witness-ignore-fake-reads.rs b/tests/ui/generator/witness-ignore-fake-reads.rs
new file mode 100644
index 00000000000..ccf9ce8b49e
--- /dev/null
+++ b/tests/ui/generator/witness-ignore-fake-reads.rs
@@ -0,0 +1,34 @@
+// check-pass
+// edition: 2021
+
+// regression test for #117059
+struct SendNotSync(*const ());
+unsafe impl Send for SendNotSync {}
+// impl !Sync for SendNotSync {} // automatically disabled
+
+struct Inner {
+    stream: SendNotSync,
+    state: bool,
+}
+
+struct SendSync;
+impl std::ops::Deref for SendSync {
+    type Target = Inner;
+    fn deref(&self) -> &Self::Target {
+        todo!();
+    }
+}
+
+async fn next() {
+    let inner = SendSync;
+    match inner.state {
+        true if false => {}
+        false => async {}.await,
+        _ => {}
+    }
+}
+
+fn is_send<T: Send>(_: T) {}
+fn main() {
+    is_send(next())
+}
diff --git a/tests/ui/late-bound-lifetimes/predicate-is-global.rs b/tests/ui/late-bound-lifetimes/predicate-is-global.rs
new file mode 100644
index 00000000000..be017a3f94f
--- /dev/null
+++ b/tests/ui/late-bound-lifetimes/predicate-is-global.rs
@@ -0,0 +1,40 @@
+// check-pass
+
+trait Foo {
+    type Assoc;
+
+    fn do_it(_: &Self::Assoc)
+    where
+        for<'a> Self: Baz<'a>;
+}
+
+trait Baz<'a>: Foo {}
+
+impl Foo for () {
+    type Assoc = Inherent;
+
+    // Ensure that the `for<'a> Self: Baz<'a>` predicate, which has
+    // a supertrait `for<'a> Self: Foo`, does not cause us to fail
+    // to normalize `Self::Assoc`.
+    fn do_it(x: &Self::Assoc)
+    where
+        for<'a> Self: Baz<'a>,
+    {
+        x.inherent();
+    }
+}
+
+struct Inherent;
+impl Inherent {
+    fn inherent(&self) {}
+}
+
+// This trivial bound doesn't hold, but the unused lifetime tripped up that check after #117589, and
+// showed up in its crater results (in `soa-derive 0.13.0`).
+fn do_it()
+where
+    for<'a> Inherent: Clone,
+{
+}
+
+fn main() {}