185 Commits

Author SHA1 Message Date
Karol Zwolak
fb046a1354 update tests to match lint message changes from rust-lang/rust#140794 2025-08-17 18:50:55 +02:00
Eric Huss
1ce8023626 Rustfmt 2024 2025-07-05 19:50:36 -07:00
Urgau
c5fee7d595 Use a different lint for the ffix_only_once_for_duplicates test 2025-06-28 14:29:29 +02:00
Ross Sullivan
92d9a94d02
chore: Migrated testsuite to testsuite::prelude 2025-06-25 22:37:24 +09:00
Ross Sullivan
47312c446d
chore: Moved tools and some cross compiling logic into testsuite 2025-06-24 23:51:39 +09:00
Eric Huss
21629670f4 Implement -Zfix-edition
This adds the implementation for the behavior of `cargo fix
-Zfix-edition`.
2025-05-25 08:24:09 -07:00
Ed Page
f49d2fdbb4 fix(toml): Remove workaround for rustc frontmatter support
With rust-lang/rust#140035 now merged, we can rely on that rather than
dirty hacks
2025-05-21 12:48:56 -05:00
Ed Page
b81c676ebc test: Remove unused nightly requirements 2025-05-06 12:52:20 -05:00
Rustin170506
a6eb2bd334 test: use the correct stats code and do not use --all-targets
Signed-off-by: Rustin170506 <techregister@pm.me>
2025-04-28 23:45:05 +08:00
Rustin170506
75a8cdd5a9 fix: default to all targets when using --edition and --edition-idioms in cargo fix
Signed-off-by: Rustin170506 <techregister@pm.me>
2025-04-16 17:21:51 +08:00
Rustin170506
69f398f647 test: add tests for fixing edition and edition idioms
Signed-off-by: Rustin170506 <techregister@pm.me>
2025-03-06 21:57:36 +08:00
Ed Page
f6514977ef
feat: add cargo pkgid support for cargo-script (#14961)
### What does this PR try to resolve?

close https://github.com/rust-lang/cargo/issues/14831

In this PR, we added the `cargo pkgid` support for the cargo-script.

For the package itself:

```console
cargo pkgid --manifest-path foo.rs
path+file:///my-project/foo.rs/foo#0.86.0
```

For its dependence:

```console
cargo pkgid --manifest-path foo.rs -p sqlx
registry+https://github.com/rust-lang/crates.io-index#sqlx@0.7.4
```

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

I have updated the unit tests and also added more test cases for it.

### Additional information

None
2025-02-04 19:52:07 +00:00
Rustin170506
95f6d0b2da feat: use full URL for embedded script paths
Signed-off-by: Rustin170506 <techregister@pm.me>
2025-01-20 21:53:15 +08:00
Kornel
22690a3236
Make --allow-dirty imply --allow-staged 2025-01-04 00:25:41 +00:00
Ed Page
f8468abc76 fix(fix): Migrate workspace dependencies 2024-12-03 15:06:53 -06:00
Ed Page
d4b3b9d35a test(fix): Show virtual manifest migration issue 2024-12-02 20:47:12 -06:00
Ed Page
ed3947f2ef fix(fix): Migrate cargo script manifests across editions
At this point it is unlikely for a script to be written for pre-2024
edition and migrated to 2024+ but this code is independent of Editions
so this means we have one less bug and are better prepared for the next
edition.

When we add `cargo fix` support for regular manifest warnings, we'll
need to take into account cargo scripts.

This is a part of #12207.
2024-11-27 13:24:37 -06:00
Ed Page
a609028eae test(fix): Show cargo-script behavior 2024-11-27 13:18:34 -06:00
Ed Page
81411ec545 feat: Stabilize Edition 2024 2024-11-25 09:27:09 -06:00
Ed Page
af3cfd5abe fix(test): Un-deprecate contains assertions 2024-11-07 15:55:35 -06:00
Weihang Lo
8aec0a40f5
test(rustfix): switch to a simpler case for dedup-suggestions
This case also emits an insert-only suggestions (span start == end),
and doesn't rely on any lint behavior.

See also

* https://github.com/rust-lang/cargo/pull/13728
* https://github.com/rust-lang/cargo/issues/13027
2024-10-31 22:05:24 -04:00
Ed Page
7be5a2146b fix: Remove implicit feature removal
Due to problems we ran into with #14016, we're removing implicit
features from the 2024 edition to give ourselves more time to design it
as we should.

I could have added a new flag for this or made an EditionNext but I
decided to remove it in the hopes to avoid any path dependency in
solving this the next time.
2024-10-01 11:48:31 -05:00
Ed Page
a6cf1be655 test: Switch from allow to expect deprecated
This caught a couple of lingering items.
2024-09-23 20:44:06 -05:00
Ed Page
d2ec764995 fix(resolve): Dont show locking workspace members
This is for `cargo generate-lockfile` and when syncing the lockfile with
the manifest.
We still show it for `cargo update` because of `cargo update
--workspace`.

We hacked around this previously by filtering out the `num_pkgs==1` case
for single packages but this didn't help with workspaces.
2024-08-22 16:57:06 -05:00
Ed Page
3a615ca9c8 feat(test): Add CargoPathExt to prelude 2024-07-18 15:22:29 -05:00
eth3lbert
882f3473b5
test: migrate fix to snapbox 2024-07-02 08:42:34 +08:00
Ed Page
21c0928638 fix(fix): Ensure optional dep is available for dep-features 2024-06-05 16:00:39 -05:00
Ed Page
078383bd0f fix(fix): Dont remove features when making implicit features explicit 2024-06-05 15:27:00 -05:00
Ed Page
fbe1cd1ab7 test(fix): Show the dep-feature behavior 2024-06-05 15:09:29 -05:00
Ed Page
fa14a13618 test(fix): Simplify existing-table test
We already have a test that covers each dep type; we don't need to cover
that here.
2024-06-05 15:08:22 -05:00
Ed Page
1b51d170fe tests(fix): Clarify role of dependencies 2024-06-05 12:03:24 -05:00
Ed Page
c009b3208d tests(fix): Snapshot fixes 2024-06-05 11:59:50 -05:00
Ed Page
dc5ac62cab fix(test): Deprecate non-snapbox assertions
While this is noisy and hides other deprecations, I figured deprecations would
make it easier for people to discover what tasks remain and allow us to
divide and conquer this work rather than doing a heroic PR.
In theory, this will be short lived and we'll go back to seeing
deprecations in our tests.
2024-06-10 10:20:52 -05:00
Ed Page
3054936cab refactor: Port from assert_matches_exact to assert_e2e
This leaves off `validate_crate_contents` as that would be an effort on
its own
2024-05-29 14:08:10 -05:00
surechen
1c8da38a5c Fix test error in https://github.com/rust-lang/rust/pull/125533
As lint dropping_copy_types will give suggsetion in this
situation.(Changed in https://github.com/rust-lang/rust/pull/125433)
2024-05-25 23:49:13 +08:00
Ed Page
627b1d1470 feat(fix): Migrate inherited deps with ignored default-features 2024-05-01 12:43:47 -05:00
Ed Page
10012ce9cf test(fix): Show default-features migration 2024-05-01 12:30:57 -05:00
bors
6087566b3f Auto merge of #13792 - weihanglo:fix-in-rust-src, r=ehuss
fix(cargo-fix): dont fix into standard library
2024-04-30 20:45:20 +00:00
Ed Page
a71b8fecf3 feat(fix): Migrate underscore toml fields 2024-04-25 13:22:06 -05:00
Ed Page
bcf032e5be test(fix): Show underscore field migration 2024-04-25 12:44:53 -05:00
Weihang Lo
0810627891
fix(cargo-fix): dont fix into standard library
This takes a more aggressive approach by stop any write into sysroot.
2024-04-23 11:52:22 -04:00
Weihang Lo
8410c1e99d
test(fix): verify cargo might fix into rust-src
The suggestion is slightly tweaked since the original
diagnostic was rejected due to multiple files were involved.

For the original diagnostic JSON, see
https://github.com/rust-lang/rust/issues/88514#issuecomment-2043469384
2024-04-23 09:41:14 -04:00
Scott Schafer
064184a2bb
feat(fix): Add features for unused deps on Edition 2024 2024-04-19 11:43:39 -06:00
Ed Page
cbd9def9dc feat(fix): Migrate from project to package on Edition 2024 2024-04-15 13:33:28 -05:00
Ed Page
98298d4966 feat(fix): Report manifest migrations 2024-04-15 13:33:27 -05:00
Ed Page
d5606b2278 test(fix): Show current project/package behavior 2024-04-15 13:32:17 -05:00
Ed Page
1876326b6b feat(resolve): Tell the user the style of resovle done
This is to help with #9930

Example changes:
```diff
-[LOCKING] 4 packages
+[LOCKING] 4 packages to latest version
-[LOCKING] 2 packages
+[LOCKING] 2 packages to latest Rust 1.60.0 compatible versions
-[LOCKING] 2 packages
+[LOCKING] 2 packages to earliest versions
```

Benefits
- The package count is of "added" packages and this makes that more
  logically clear
- This gives users transparency into what is happening, especially with
  - what rust-version is use
  - the transition to this feature in the new edition
  - whether the planned config was applied or not (as I don't want it to
    require an MSRV bump)
- Will make it easier in tests to show what changed
- Provides more motiviation to show this message in `cargo update` and
  `cargo install` (that will be explored in a follow up PR)

This does come at the cost of more verbose output but hopefully not too
verbose.  This is why I left off other factors, like avoid-dev-deps.
2024-04-13 20:39:59 -05: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
Ed Page
4ab2797f36 feat(lock): Print lockfile changes on all commands 2024-03-12 13:39:56 -05:00