diff options
| author | Rémy Rakic <remy.rakic+github@gmail.com> | 2023-11-22 15:49:20 +0000 |
|---|---|---|
| committer | Rémy Rakic <remy.rakic+github@gmail.com> | 2023-12-01 14:04:54 +0000 |
| commit | b442120a3097585b72d9f03eb71ba11c050883a3 (patch) | |
| tree | e9c97f7b5099a90fcc375c23d3fe18033c2ab1eb /tests | |
| parent | 60d4eb2c1ba6ad3ea4be52295e064ec8c07d1bf1 (diff) | |
| download | rust-b442120a3097585b72d9f03eb71ba11c050883a3.tar.gz rust-b442120a3097585b72d9f03eb71ba11c050883a3.zip | |
add tests from crater for liveness causing scope differences
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/nll/polonius/location-insensitive-scopes-liveness.rs | 46 |
1 files changed, 46 insertions, 0 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 00000000000..5fabf31cecd --- /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() {} |
