21 Commits

Author SHA1 Message Date
Mo
af04e54235
Apply suggestions from code review
Inline variables in `format!`

Co-authored-by: Weihang Lo <weihanglo@users.noreply.github.com>
2024-08-09 15:42:02 +02:00
mo8it
3ccb17c399 Use with_context with format! 2024-08-09 14:20:18 +02:00
Weihang Lo
a47766149f
test(rustfix): bless multiple-solutions.nightly.rs 2024-05-09 09:30:25 -04:00
Weihang Lo
26bcf58bfe
test(rustfix): run some tests only on nightly 2024-05-09 09:30:25 -04:00
Weihang Lo
95edc06e5b
fix(rustfix): dont apply same suggestion twice
This assumes that if any of the machine applicable fixes in
a diagnostic suggestion is a duplicate, we should see the
entire suggestion as a duplicate.
2024-04-10 11:54:33 -04:00
Weihang Lo
5b05a3bb5a
test(rustfix): demonstrate duplicate suggestions 2024-04-10 11:53:37 -04:00
Eric Huss
daa884169c Fix redundant imports. 2024-02-20 09:57:03 -08:00
Eric Huss
3d3e1b3668 Handle Windows newlines.
Suggestions that come from rustc that are multi-line only use LF line
endings. But if the file is checked out on windows with CRLF
line-endings, then you end up with a mix of line endings that don't
match the "fixed.rs" file.

Tracking this at https://github.com/rust-lang/rust/issues/119482.
2023-12-31 16:20:41 -08:00
Eric Huss
a21997f0cc 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.
2023-12-31 10:18:22 -08:00
Eric Huss
029fe2bafc Add a primitive way to add new tests to parse_and_replace.
This adds an environment variable to make it easier to add new tests.
2023-12-31 09:58:37 -08:00
Eric Huss
c54fa88ea4 Cleanup rustfix parse_and_replace test.
This is just some minor code cleanup for the parse_and_replace test,
there should not be any functional differences.
2023-12-31 09:56:20 -08:00
bors
3920bd5ea5 Auto merge of #13047 - tompscanlan:rustfix-ignored-tests, r=weihanglo
review and remove ignored tests in rustfix

### What does this PR try to resolve?
review ignored tests in rustfix crate per #13034.

### How should we test and review this PR?
CI testing

### Additional information

* Removed unproductive test in `parse_and_replace`
* un-ignore proptests, and reduce runtime from ~2s to ~<.25s
2023-11-26 17:14:11 +00:00
Tom Scanlan
b179cd175a
review and remove ignored tests in rustfix
* reduce time in proptest
* delete edition dir
* remove refs to fixmode::EDITION
2023-11-26 09:29:18 -05:00
Tom Scanlan
e9e22e5c2f try running on windows 2023-11-23 18:34:56 -05:00
Eric Huss
47c7ff0f96 Deduplicate the similar dependency. 2023-11-21 10:18:15 -08:00
Eric Huss
f99a494c31 Remove copyright headers in tests.
These were all removed a while ago in https://github.com/rust-lang/rust/pull/57108
2023-11-19 08:20:21 -08:00
Eric Huss
b5308f648b Fix tests to run on stable. 2023-11-19 08:17:17 -08:00
Eric Huss
d6e49ca06b Fix clippy warnings. 2023-11-19 08:07:37 -08:00
Eric Huss
3c0126aec4 rustfix: Drop test dependency on duct
It didn't seem to be doing anything that `Command` doesn't already
support. This helps lighten the dependency size.
2023-11-18 18:21:01 -08:00
Eric Huss
d0d9bd5cbb Switch rustfix to using tracing instead of log.
This helps bring it in line with the rust of cargo.
2023-11-18 18:10:44 -08:00
Eric Huss
73e5506338 Merge remote-tracking branch 'rustfix/master' into rustfix 2023-11-18 16:51:22 -08:00