Replace elided variable in let_unit with () when used

Situation: `let_unit` lints when an expression binds a unit (`()`)
to a variable. In some cases this binding may be passed down to
another function. Currently, the lint removes the binding without
considering usage.

Change: All usages of the elided variable are now replaced with `()`.

fixes: #12594
This commit is contained in:
Quinn Sinclair 2024-03-31 17:53:13 +02:00
parent 124e68bef8
commit eee4db928f
4 changed files with 100 additions and 3 deletions

View file

@ -177,3 +177,21 @@ async fn issue10433() {
}
pub async fn issue11502(a: ()) {}
pub fn issue12594() {
fn returns_unit() {}
fn returns_result<T>(res: T) -> Result<T, ()> {
Ok(res)
}
fn actual_test() {
// create first a unit value'd value
returns_unit();
returns_result(()).unwrap();
returns_result(()).unwrap();
// make sure we replace only the first variable
let res = 1;
returns_result(res).unwrap();
}
}