aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax/src/lib.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-04-10 22:35:05 +0100
committerGitHub <[email protected]>2021-04-10 22:35:05 +0100
commita8a25863f6e1e6da94b60813b2daee73b55132f7 (patch)
tree1e2b90d4196867eb1326d19bac70be8a5847a26e /crates/syntax/src/lib.rs
parentbd675c8a8bdd3fda239bee3d3f31acd8679655b9 (diff)
parentc989287a34b8b27fa4880d27e698bd880631a794 (diff)
Merge #8436
8436: Fix extract function's mutability of variables outliving the body r=matklad a=brandondong **Reproduction:** ```rust fn main() { let mut k = 1; let mut j = 2; j += 1; k += j; } ``` 1. Select the first to third lines of the main function. Use the "Extract into function" code assist. 2. The output is the following which does not compile because the outlived variable `k` is declared as immutable: ```rust fn main() { let (k, j) = fun_name(); k += j; } fn fun_name() -> (i32, i32) { let mut k = 1; let mut j = 2; j += 1; (k, j) } ``` 3. We would instead expect the output to be: ```rust fn main() { let (mut k, j) = fun_name(); k += j; } ``` **Fix:** - Instead of declaring outlived variables as immutable unconditionally, check for any mutable usages outside of the extracted function. Co-authored-by: Brandon <[email protected]>
Diffstat (limited to 'crates/syntax/src/lib.rs')
0 files changed, 0 insertions, 0 deletions