rename local variables
Identifies conflicts with other variables, function-local and non-function local types, but only non-function local functions. Function-local functions can cause sub-block conflicts.
fn main() {
let a = 2;
fn foo() {}
foo();
let _ = 3 + a; // type conflict
}
Doesn't conflict with variables declared in a nested scope.
Also functions for tuple let bindings, but haven't tested other destructuring assignments. (Obvious case where this doesn't work is the iterator variable for a (macro) for loop.)
Conflicts with struct destructures are fine when given a name, but not when they are inferred. FINE:
let Point{x:x, y:y} = Point{x:1, y:2}
NOT FINE:
let Point{x, y} = Point{x:1, y:2}
to
let Point{foo, y} = Point{x:1, y:2}
I believe this check requires going to type checking, which makes it an interesting corner case.
Oh, that is a lovely edge case! Small note that there is no inference here - we just match the name of the field with the name of the introduced local variable. This will also affect field renaming - if you rename the *field x to foo, then you'll also need to either rename the local variable x to foo too (which could also clash with other local vars) or you'll need to change Point { x, ... to Point { x: foo, ....
Perhaps option 2 plus a warning is the best solution?
Anyway, make sure this goes into your report.