This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit 49dd380
committed
Auto merge of rust-lang#16009 - werifu:fix-extract-function, r=Veykril
fix: bug in extract_function.rs
There is a little bug in extract_function: It appends `use path::to::ControlFlow;` if the function created contains string "ControlFlow".
A case below (also in the test named `does_not_import_control_flow` which will fail in the original code)
<img width="322" alt="image" src="https://github.com/rust-lang/rust-analyzer/assets/53432474/4b80bb58-0cfd-4d56-b64c-d9649eed336e">
<img width="391" alt="image" src="https://github.com/rust-lang/rust-analyzer/assets/53432474/3d7262f4-8a4c-44ea-822d-304b8b23fe28">
Now I have changed the condition determining whether adding import statement. Only when the new function body contains ControlFlow::Break or ControlFlow::Continue can the import statement be added.
Last related PR: rust-lang/rust-analyzer#103091 file changed
+27
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
151 | 156 | | |
152 | 157 | | |
153 | 158 | | |
| |||
4968 | 4973 | | |
4969 | 4974 | | |
4970 | 4975 | | |
| 4976 | + | |
| 4977 | + | |
| 4978 | + | |
| 4979 | + | |
| 4980 | + | |
| 4981 | + | |
| 4982 | + | |
| 4983 | + | |
| 4984 | + | |
| 4985 | + | |
| 4986 | + | |
| 4987 | + | |
| 4988 | + | |
| 4989 | + | |
| 4990 | + | |
| 4991 | + | |
| 4992 | + | |
| 4993 | + | |
| 4994 | + | |
| 4995 | + | |
| 4996 | + | |
4971 | 4997 | | |
4972 | 4998 | | |
4973 | 4999 | | |
| |||
0 commit comments