2022-05-05 14:12:52 +00:00
|
|
|
error: unneeded late initialization
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/needless_late_init.rs:27:5
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
|
|
|
LL | let a;
|
2022-06-04 11:34:07 +00:00
|
|
|
| ^^^^^^ created here
|
|
|
|
LL | a = "zero";
|
|
|
|
| ^^^^^^^^^^ initialised here
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
|
|
|
= note: `-D clippy::needless-late-init` implied by `-D warnings`
|
2023-08-01 12:02:21 +00:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::needless_late_init)]`
|
2024-05-08 05:38:00 +00:00
|
|
|
help: move the declaration `a` here
|
|
|
|
|
|
|
|
|
LL ~
|
|
|
|
LL ~ let a = "zero";
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
2022-06-04 11:34:07 +00:00
|
|
|
|
|
|
|
error: unneeded late initialization
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/needless_late_init.rs:30:5
|
2022-06-04 11:34:07 +00:00
|
|
|
|
|
|
|
|
LL | let b;
|
|
|
|
| ^^^^^^ created here
|
|
|
|
LL | let c;
|
|
|
|
LL | b = 1;
|
|
|
|
| ^^^^^ initialised here
|
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
help: move the declaration `b` here
|
|
|
|
|
|
|
|
|
LL ~
|
|
|
|
LL | let c;
|
|
|
|
LL ~ let b = 1;
|
2022-06-04 11:34:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
error: unneeded late initialization
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/needless_late_init.rs:31:5
|
2022-06-04 11:34:07 +00:00
|
|
|
|
|
|
|
|
LL | let c;
|
|
|
|
| ^^^^^^ created here
|
|
|
|
LL | b = 1;
|
|
|
|
LL | c = 2;
|
|
|
|
| ^^^^^ initialised here
|
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
help: move the declaration `c` here
|
|
|
|
|
|
|
|
|
LL ~
|
|
|
|
LL | b = 1;
|
|
|
|
LL ~ let c = 2;
|
2022-06-04 11:34:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
error: unneeded late initialization
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/needless_late_init.rs:35:5
|
2022-06-04 11:34:07 +00:00
|
|
|
|
|
|
|
|
LL | let d: usize;
|
|
|
|
| ^^^^^^^^^^^^^ created here
|
|
|
|
LL | d = 1;
|
|
|
|
| ^^^^^ initialised here
|
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
help: move the declaration `d` here
|
|
|
|
|
|
|
|
|
LL ~
|
|
|
|
LL ~ let d: usize = 1;
|
2022-06-04 11:34:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
error: unneeded late initialization
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/needless_late_init.rs:38:5
|
2022-06-04 11:34:07 +00:00
|
|
|
|
|
|
|
|
LL | let e;
|
|
|
|
| ^^^^^^ created here
|
|
|
|
LL | e = format!("{}", d);
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^ initialised here
|
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
help: move the declaration `e` here
|
|
|
|
|
|
|
|
|
LL ~
|
|
|
|
LL ~ let e = format!("{}", d);
|
2022-06-04 11:34:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
error: unneeded late initialization
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/needless_late_init.rs:43:5
|
2022-06-04 11:34:07 +00:00
|
|
|
|
|
|
|
|
LL | let a;
|
|
|
|
| ^^^^^^
|
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
help: move the declaration `a` here and remove the assignments from the `match` arms
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
LL ~
|
|
|
|
LL | let n = 1;
|
|
|
|
LL ~ let a = match n {
|
2021-12-06 11:33:31 +00:00
|
|
|
LL ~ 1 => "one",
|
|
|
|
LL | _ => {
|
|
|
|
LL ~ "two"
|
2024-05-08 05:38:00 +00:00
|
|
|
LL | },
|
|
|
|
LL ~ };
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
|
|
|
|
2022-05-05 14:12:52 +00:00
|
|
|
error: unneeded late initialization
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/needless_late_init.rs:52:5
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
|
|
|
LL | let b;
|
|
|
|
| ^^^^^^
|
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
help: move the declaration `b` here and remove the assignments from the branches
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
LL ~
|
|
|
|
LL ~ let b = if n == 3 {
|
2021-12-06 11:33:31 +00:00
|
|
|
LL ~ "four"
|
|
|
|
LL | } else {
|
|
|
|
LL ~ "five"
|
2024-05-08 05:38:00 +00:00
|
|
|
LL ~ };
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
|
|
|
|
2022-05-05 14:12:52 +00:00
|
|
|
error: unneeded late initialization
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/needless_late_init.rs:59:5
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
|
|
|
LL | let d;
|
|
|
|
| ^^^^^^
|
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
help: move the declaration `d` here and remove the assignments from the branches
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
LL ~
|
|
|
|
LL ~ let d = if true {
|
|
|
|
LL | let temp = 5;
|
2021-12-06 11:33:31 +00:00
|
|
|
LL ~ temp
|
|
|
|
LL | } else {
|
|
|
|
LL ~ 15
|
2024-05-08 05:38:00 +00:00
|
|
|
LL ~ };
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
|
|
|
|
2022-05-05 14:12:52 +00:00
|
|
|
error: unneeded late initialization
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/needless_late_init.rs:67:5
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
|
|
|
LL | let e;
|
|
|
|
| ^^^^^^
|
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
help: move the declaration `e` here and remove the assignments from the branches
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
LL ~
|
|
|
|
LL ~ let e = if true {
|
2021-12-06 11:33:31 +00:00
|
|
|
LL ~ format!("{} {}", a, b)
|
|
|
|
LL | } else {
|
2022-05-05 14:12:52 +00:00
|
|
|
LL ~ format!("{}", n)
|
2024-05-08 05:38:00 +00:00
|
|
|
LL ~ };
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
|
|
|
|
2022-05-05 14:12:52 +00:00
|
|
|
error: unneeded late initialization
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/needless_late_init.rs:74:5
|
2021-12-17 12:40:22 +00:00
|
|
|
|
|
|
|
|
LL | let f;
|
|
|
|
| ^^^^^^
|
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
help: move the declaration `f` here and remove the assignments from the `match` arms
|
2021-12-17 12:40:22 +00:00
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
LL ~
|
|
|
|
LL ~ let f = match 1 {
|
|
|
|
LL ~ 1 => "three",
|
2022-06-15 11:15:54 +00:00
|
|
|
|
|
2021-12-17 12:40:22 +00:00
|
|
|
|
2022-05-05 14:12:52 +00:00
|
|
|
error: unneeded late initialization
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/needless_late_init.rs:80:5
|
2021-12-17 12:40:22 +00:00
|
|
|
|
|
|
|
|
LL | let g: usize;
|
|
|
|
| ^^^^^^^^^^^^^
|
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
help: move the declaration `g` here and remove the assignments from the branches
|
2022-06-15 11:15:54 +00:00
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
LL ~
|
|
|
|
LL ~ let g: usize = if true {
|
|
|
|
LL ~ 5
|
|
|
|
LL | } else {
|
|
|
|
LL | panic!();
|
|
|
|
LL ~ };
|
2021-12-17 12:40:22 +00:00
|
|
|
|
|
|
|
|
|
2022-05-05 14:12:52 +00:00
|
|
|
error: unneeded late initialization
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/needless_late_init.rs:88:5
|
2022-05-05 14:12:52 +00:00
|
|
|
|
|
|
|
|
LL | let x;
|
|
|
|
| ^^^^^^ created here
|
|
|
|
LL | let y = SignificantDrop;
|
|
|
|
LL | x = 1;
|
|
|
|
| ^^^^^ initialised here
|
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
help: move the declaration `x` here
|
|
|
|
|
|
|
|
|
LL ~
|
|
|
|
LL | let y = SignificantDrop;
|
|
|
|
LL ~ let x = 1;
|
2022-05-05 14:12:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
error: unneeded late initialization
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/needless_late_init.rs:92:5
|
2022-05-05 14:12:52 +00:00
|
|
|
|
|
|
|
|
LL | let x;
|
|
|
|
| ^^^^^^ created here
|
|
|
|
LL | let y = 1;
|
|
|
|
LL | x = SignificantDrop;
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^ initialised here
|
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
help: move the declaration `x` here
|
|
|
|
|
|
|
|
|
LL ~
|
|
|
|
LL | let y = 1;
|
|
|
|
LL ~ let x = SignificantDrop;
|
2022-05-05 14:12:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
error: unneeded late initialization
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/needless_late_init.rs:96:5
|
2022-05-05 14:12:52 +00:00
|
|
|
|
|
|
|
|
LL | let x;
|
|
|
|
| ^^^^^^ created here
|
|
|
|
...
|
|
|
|
LL | x = SignificantDrop;
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^ initialised here
|
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
help: move the declaration `x` here
|
|
|
|
|
|
|
|
|
LL ~
|
|
|
|
LL | // types that should be considered insignificant
|
|
|
|
...
|
|
|
|
LL | let y = Box::new(4);
|
|
|
|
LL ~ let x = SignificantDrop;
|
2022-05-05 14:12:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
error: unneeded late initialization
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/needless_late_init.rs:115:5
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
|
|
|
LL | let a;
|
|
|
|
| ^^^^^^
|
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
help: move the declaration `a` here and remove the assignments from the `match` arms
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
LL ~
|
|
|
|
LL | let n = 1;
|
|
|
|
LL ~ let a = match n {
|
2021-12-06 11:33:31 +00:00
|
|
|
LL ~ 1 => f().await,
|
|
|
|
LL | _ => {
|
|
|
|
LL ~ "two"
|
2024-05-08 05:38:00 +00:00
|
|
|
LL | },
|
|
|
|
LL ~ };
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
|
|
|
|
2022-05-05 14:12:52 +00:00
|
|
|
error: unneeded late initialization
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/needless_late_init.rs:132:5
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
|
|
|
LL | let a;
|
|
|
|
| ^^^^^^
|
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
help: move the declaration `a` here and remove the assignments from the `match` arms
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
2024-05-08 05:38:00 +00:00
|
|
|
LL ~
|
|
|
|
LL | let n = 1;
|
|
|
|
LL ~ let a = match n {
|
2021-12-06 11:33:31 +00:00
|
|
|
LL ~ 1 => f(),
|
|
|
|
LL | _ => {
|
|
|
|
LL ~ "two"
|
2024-05-08 05:38:00 +00:00
|
|
|
LL | },
|
|
|
|
LL ~ };
|
2021-12-06 11:33:31 +00:00
|
|
|
|
|
|
|
|
|
2022-06-04 11:34:07 +00:00
|
|
|
error: aborting due to 16 previous errors
|
2021-12-06 11:33:31 +00:00
|
|
|
|