Skip to content

Commit 59b3b3e

Browse files
committed
fix: only check solutions are in the same file
1 parent c4b5a63 commit 59b3b3e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/cargo/ops/fix.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -400,21 +400,21 @@ fn rustfix_and_fix(
400400
for suggestion in suggestions {
401401
trace!("suggestion");
402402
// Make sure we've got a file associated with this suggestion and all
403-
// snippets point to the same location. Right now it's not clear what
404-
// we would do with multiple locations.
405-
let (file_name, range) = match suggestion.snippets.get(0) {
406-
Some(s) => (s.file_name.clone(), s.line_range),
403+
// snippets point to the same file. Right now it's not clear what
404+
// we would do with multiple files.
405+
let file_name = match suggestion.solutions.get(0).and_then(|sol| sol.replacements.get(0)) {
406+
Some(s) => s.snippet.file_name.clone(),
407407
None => {
408-
trace!("rejecting as it has no snippets {:?}", suggestion);
408+
trace!("rejecting as it has no solutions {:?}", suggestion);
409409
continue;
410410
}
411411
};
412412
if !suggestion
413-
.snippets
413+
.solutions
414414
.iter()
415-
.all(|s| s.file_name == file_name && s.line_range == range)
415+
.all(|sol| sol.replacements.iter().all(|rep| rep.snippet.file_name == file_name))
416416
{
417-
trace!("rejecting as it spans multiple files {:?}", suggestion);
417+
trace!("rejecting as it changes multiple files: {:?}", suggestion);
418418
continue;
419419
}
420420

0 commit comments

Comments
 (0)