diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /src/test/ui/closures/2229_closure_analysis/diagnostics/liveness.rs | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/closures/2229_closure_analysis/diagnostics/liveness.rs')
-rw-r--r-- | src/test/ui/closures/2229_closure_analysis/diagnostics/liveness.rs | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/src/test/ui/closures/2229_closure_analysis/diagnostics/liveness.rs b/src/test/ui/closures/2229_closure_analysis/diagnostics/liveness.rs deleted file mode 100644 index 3399bc001..000000000 --- a/src/test/ui/closures/2229_closure_analysis/diagnostics/liveness.rs +++ /dev/null @@ -1,92 +0,0 @@ -// edition:2021 - -// check-pass -#![allow(unreachable_code)] -#![warn(unused)] -#![allow(dead_code)] - -#[derive(Debug)] -struct Point { - x: i32, - y: i32, -} - -pub fn f() { - let mut a = 1; - let mut c = Point{ x:1, y:0 }; - - // Captured by value, but variable is dead on entry. - (move || { - // This will not trigger a warning for unused variable as - // c.x will be treated as a Non-tracked place - c.x = 1; - println!("{}", c.x); - a = 1; //~ WARN value captured by `a` is never read - println!("{}", a); - })(); - - // Read and written to, but never actually used. - (move || { - // This will not trigger a warning for unused variable as - // c.x will be treated as a Non-tracked place - c.x += 1; - a += 1; //~ WARN unused variable: `a` - })(); - - (move || { - println!("{}", c.x); - // Value is read by closure itself on later invocations. - // This will not trigger a warning for unused variable as - // c.x will be treated as a Non-tracked place - c.x += 1; - println!("{}", a); - a += 1; - })(); - let b = Box::new(42); - (move || { - println!("{}", c.x); - // Never read because this is FnOnce closure. - // This will not trigger a warning for unused variable as - // c.x will be treated as a Non-tracked place - c.x += 1; - println!("{}", a); - a += 1; //~ WARN value assigned to `a` is never read - drop(b); - })(); -} - -#[derive(Debug)] -struct MyStruct<'a> { - x: Option<& 'a str>, - y: i32, -} - -pub fn nested() { - let mut a : Option<& str>; - a = None; - let mut b : Option<& str>; - b = None; - let mut d = MyStruct{ x: None, y: 1}; - let mut e = MyStruct{ x: None, y: 1}; - (|| { - (|| { - // This will not trigger a warning for unused variable as - // d.x will be treated as a Non-tracked place - d.x = Some("d1"); - d.x = Some("d2"); - a = Some("d1"); //~ WARN value assigned to `a` is never read - a = Some("d2"); - })(); - (move || { - // This will not trigger a warning for unused variable as - //e.x will be treated as a Non-tracked place - e.x = Some("e1"); - e.x = Some("e2"); - b = Some("e1"); //~ WARN value assigned to `b` is never read - //~| WARN unused variable: `b` - b = Some("e2"); //~ WARN value assigned to `b` is never read - })(); - })(); -} - -fn main() {} |