summaryrefslogtreecommitdiffstats
path: root/tests/ui/nll/polonius
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:25:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:25:56 +0000
commit018c4950b9406055dec02ef0fb52f132e2bb1e2c (patch)
treea835ebdf2088ef88fa681f8fad45f09922c1ae9a /tests/ui/nll/polonius
parentAdding debian version 1.75.0+dfsg1-5. (diff)
downloadrustc-018c4950b9406055dec02ef0fb52f132e2bb1e2c.tar.xz
rustc-018c4950b9406055dec02ef0fb52f132e2bb1e2c.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/nll/polonius')
-rw-r--r--tests/ui/nll/polonius/location-insensitive-scopes-liveness.rs46
-rw-r--r--tests/ui/nll/polonius/subset-relations.stderr2
2 files changed, 47 insertions, 1 deletions
diff --git a/tests/ui/nll/polonius/location-insensitive-scopes-liveness.rs b/tests/ui/nll/polonius/location-insensitive-scopes-liveness.rs
new file mode 100644
index 000000000..5fabf31ce
--- /dev/null
+++ b/tests/ui/nll/polonius/location-insensitive-scopes-liveness.rs
@@ -0,0 +1,46 @@
+// This is a non-regression test about differences in scopes computed by NLLs and `-Zpolonius=next`
+// found during the crater run for PR #117593.
+//
+// Live loans were computed too early compared to some of the liveness data coming from later passes
+// than `liveness::trace`, on some specific CFGs shapes: a variable was dead during tracing but its
+// regions were marked live later, and live loans were not recomputed at this point.
+
+// check-pass
+// revisions: nll polonius
+// [polonius] compile-flags: -Zpolonius=next
+
+// minimized from wavefc-cli-3.0.0
+fn repro1() {
+ let a = 0;
+ let closure = || {
+ let _b = a;
+ };
+
+ let callback = if true { Some(closure) } else { None };
+ do_it(callback);
+}
+fn do_it<F>(_: Option<F>)
+where
+ F: Fn(),
+{
+}
+
+// minimized from simple-server-0.4.0
+fn repro2() {
+ let mut a = &();
+ let s = S(&mut a);
+ let _ = if true { Some(s) } else { None };
+}
+struct S<'a>(&'a mut &'a ());
+
+// minimized from https://github.com/SHaaD94/AICup2022
+fn repro3() {
+ let runner = ();
+ let writer = debug_interface(&runner);
+ let _ = if true { Some(writer) } else { None };
+}
+fn debug_interface(_: &()) -> &mut dyn std::io::Write {
+ unimplemented!()
+}
+
+fn main() {}
diff --git a/tests/ui/nll/polonius/subset-relations.stderr b/tests/ui/nll/polonius/subset-relations.stderr
index 6df5563ea..9deca6449 100644
--- a/tests/ui/nll/polonius/subset-relations.stderr
+++ b/tests/ui/nll/polonius/subset-relations.stderr
@@ -10,5 +10,5 @@ LL | y
|
= help: consider adding the following bound: `'b: 'a`
-error: aborting due to previous error
+error: aborting due to 1 previous error