Commit 059ec69
committed
Auto merge of #13226 - ehuss:fix-empty-span, r=weihanglo
rustfix: Support inserting new lines.
If rustfix received a suggestion which inserts new lines without replacing existing lines, it would ignore the suggestion. This is because `parse_snippet` would immediately return if the `lines` to replace was empty.
The solution here is to just drop the code which messes with the original text line. `cargo fix` (and compiletest) currently do not use this. This was originally added back in the days when rustfix supported an interactive UI which showed color highlighting of what it looks like with the replacement. My feeling is that when we add something like this back in, I would prefer to instead use a real diff library and display instead of trying to do various text manipulation for display. This particular code has generally been buggy, and has been a problem several times.
The included test fails without this fix because the changes do not apply, and the code cannot compile.
This also includes a little bit of cleanup for the `parse_and_replace` test. My feeling is that this test could use further improvements.File tree
8 files changed
+70
-93
lines changed- crates/rustfix
- src
- tests
- everything
8 files changed
+70
-93
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | 107 | | |
112 | 108 | | |
113 | 109 | | |
| |||
119 | 115 | | |
120 | 116 | | |
121 | 117 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
174 | 121 | | |
175 | 122 | | |
176 | 123 | | |
| |||
183 | 130 | | |
184 | 131 | | |
185 | 132 | | |
186 | | - | |
187 | | - | |
| 133 | + | |
188 | 134 | | |
189 | 135 | | |
190 | 136 | | |
191 | 137 | | |
192 | | - | |
| 138 | + | |
193 | 139 | | |
194 | 140 | | |
195 | 141 | | |
| |||
217 | 163 | | |
218 | 164 | | |
219 | 165 | | |
220 | | - | |
| 166 | + | |
221 | 167 | | |
222 | 168 | | |
223 | 169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
1 | 23 | | |
2 | 24 | | |
3 | 25 | | |
| |||
20 | 42 | | |
21 | 43 | | |
22 | 44 | | |
| 45 | + | |
23 | 46 | | |
24 | 47 | | |
25 | 48 | | |
| |||
79 | 102 | | |
80 | 103 | | |
81 | 104 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | 105 | | |
92 | 106 | | |
93 | 107 | | |
| |||
104 | 118 | | |
105 | 119 | | |
106 | 120 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
| 121 | + | |
112 | 122 | | |
113 | 123 | | |
114 | 124 | | |
| |||
133 | 143 | | |
134 | 144 | | |
135 | 145 | | |
136 | | - | |
| 146 | + | |
137 | 147 | | |
138 | 148 | | |
139 | 149 | | |
140 | 150 | | |
141 | 151 | | |
142 | 152 | | |
143 | 153 | | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
| 154 | + | |
149 | 155 | | |
150 | 156 | | |
151 | 157 | | |
152 | | - | |
| 158 | + | |
153 | 159 | | |
154 | 160 | | |
155 | 161 | | |
| |||
168 | 174 | | |
169 | 175 | | |
170 | 176 | | |
171 | | - | |
| 177 | + | |
| 178 | + | |
172 | 179 | | |
173 | 180 | | |
174 | | - | |
175 | | - | |
176 | | - | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
177 | 189 | | |
178 | 190 | | |
179 | | - | |
180 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
181 | 194 | | |
182 | 195 | | |
183 | 196 | | |
| |||
191 | 204 | | |
192 | 205 | | |
193 | 206 | | |
194 | | - | |
195 | | - | |
| 207 | + | |
196 | 208 | | |
197 | 209 | | |
198 | 210 | | |
| |||
203 | 215 | | |
204 | 216 | | |
205 | 217 | | |
206 | | - | |
| 218 | + | |
207 | 219 | | |
208 | 220 | | |
209 | 221 | | |
| |||
0 commit comments