5992 Commits

Author SHA1 Message Date
Ed Page
38718eaa93 feat(resolve): Fallback to 'rustc -V' for MSRV resolving 2024-04-11 14:40:52 -05:00
Ed Page
a8e816b079 test(resolve): Show no-MSRV case 2024-04-11 14:36:50 -05:00
Ed Page
c7d89c64f1 feat(cli): Add --ignore-rust-version to update/generate-lockfile 2024-04-11 14:27:57 -05:00
Ed Page
c9de6eeeb2 test(resolve): Show update/generate-lockfile behavior 2024-04-11 14:18:10 -05:00
Ed Page
a0ba72918a fix(help): Generalize --ignore-rust-version 2024-04-11 13:45:39 -05:00
bors
7e31f62a80 Auto merge of #13744 - cuviper:ci-uncompressed, r=weihanglo
test: don't compress test registry crates

They are still nominally gzipped, but using `Compression::none()` makes
them consistent even across zlib and zlib-ng, and this fixes checksum
differences in the testsuite. There is a one-time update of all those
checksums to catch up with this change though.

r? `@weihanglo`
2024-04-11 22:48:34 +00:00
bors
c375398f3b Auto merge of #13738 - epage:msrv, r=Muscraft
feat(reslve): Respect '--ignore-rust-version'

### What does this PR try to resolve?

This is a part of #9930.

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

I had considered several ways of implementing this.  I first looked at passing this into `ops::resolve*`.
.This would get a bit annoying with the function signature, so I considered moving it to a builder..
Each of the entry points is slightly different with different ownership needs, making it hard to have a common abstraction.
In doing this, I noticed we currently pass some state around to the resolver via `Workspace`, so I mirrored that.

The nice thing about this location is it provides a good place to hook in config and `package.resolve` so they affect this.

### Additional information
2024-04-11 22:12:03 +00:00
Josh Stone
a70f23c50b test: don't compress test registry crates
They are still nominally gzipped, but using `Compression::none()` makes
them consistent even across zlib and zlib-ng, and this fixes checksum
differences in the testsuite. There is a one-time update of all those
checksums to catch up with this change though.
2024-04-11 14:58:42 -07:00
Scott Schafer
d77faa68af
refactor: Remove rust_2024_compatibility lint group 2024-04-11 14:36:30 -06:00
Ed Page
cd3d31b361 feat(reslve): Respect '--ignore-rust-version' 2024-04-11 12:56:53 -05:00
bors
40ce8ace29 Auto merge of #13728 - weihanglo:dedup-suggestion, r=epage
fix(cargo-fix): dont apply same suggestion twice
2024-04-10 16:50:17 +00: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
8b593e5ba7 fix(package): Normalize path separators
A windows user could use `\` and no Linux or Mac user could use the
package.
This normalizes the separator to what works on all platforms.
2024-04-09 21:29:08 -05:00
Ed Page
5539293cf6 fix(package): Normalize paths in published Cargo.toml
For now, this is more for visual consistency.
However, this blocks #13713 as we need to be able to make these paths
comparable to what is included in the package.
2024-04-09 20:57:25 -05:00
Ed Page
4eea907733 test(package): Show behavior with backslashes 2024-04-09 13:44:25 -05:00
bors
bd1cf584af Auto merge of #13560 - heisen-li:build_flag, r=weihanglo
[fix]:Build script not rerun when target rustflags change

### What does this PR try to resolve?

Fixes https://github.com/rust-lang/cargo/issues/13003
2024-04-08 15:54:04 +00:00
heisen-li
db7afeba4e
fix: rerun build script when target rustflags changed
fixes #13003
2024-04-08 10:48:20 -04:00
heisen-li
cdda9008a3
fix: show build script didnt rerun when target rustflags changed 2024-04-08 10:47:37 -04:00
bors
fa619a9d16 Auto merge of #13630 - Kobzol:msvc-disable-release-strip, r=weihanglo
Do not strip debuginfo by default for MSVC

This PR disables the logic which enables debuginfo stripping by default in release mode (https://github.com/rust-lang/cargo/pull/13257) for MSVC, since it causes problems there (https://github.com/rust-lang/rust/issues/122857).

I'm not sure if this is the correct way to gate the logic on a specific target triple.

The root of the issue is that `-Cstrip=debuginfo` currently behaves like `-Cstrip=symbols` on MSVC, which causes the original optimization to break backtraces on Windows. Ultimately, this should probably be fixed in `rustc`, but that might take some further design work, therefore a faster solution would be to just special case this in Cargo for now, and remove the special case later, once it gets fixed on the `rustc` side.

Related issue: https://github.com/rust-lang/rust/issues/122857
2024-03-26 00:22:51 +00:00
Jakub Beránek
53a0dc4aa2
Fix tests 2024-03-25 23:42:47 +01:00
Eric Huss
3adb796e87 Fix doc collision for lib/bin with a dash in the inferred name. 2024-03-25 13:35:52 -07:00
Eric Huss
9e7d6e3122 Add test for doc lib/bin collision with a dash. 2024-03-25 13:32:15 -07:00
bors
bc844af45d Auto merge of #13635 - Muscraft:lint-names-snake-case, r=epage
refactor: Make lint names snake_case

When working on #13621, I somehow missed that lint names should be `snake_case` according to the [`rustc-dev-guide`](https://rustc-dev-guide.rust-lang.org/diagnostics.html#lint-naming) as well as [`RFC #344`](https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints).

This PR renames:
- `implicit-features` => `implicit_featires`
- `rust-2024-compatibility` => `rust_2024_compatibility`.

<hr>

Note: We should probably have some tooling to enforce this, but I was unsure if it belonged to this PR or another one. One solution would be to use a macro to create the `const LINT_NAME: Lint = {...}`, where `LINT_NAME` would be the `ident` as well as the `name: &'static str` and then have a method on `Lint` to make it lowercase as needed. This is what `rustc` does, and it could work well here. It would ensure snake case as `const` names need to be [`SCREAMING_SNAKE_CASE`](https://rust-lang.github.io/rfcs/0430-finalizing-naming-conventions.html#general-naming-conventions), or a warning is shown.
2024-03-25 18:51:29 +00:00
Scott Schafer
0a400d5ef0
refactor: Make lint names snake_case 2024-03-25 12:44:12 -06:00
Jacob Pratt
def06ee243
Remove unnecessary test 2024-03-24 20:02:10 -04:00
bors
a5b31ebafa Auto merge of #13592 - Byron:gix-for-list-files-git, r=arlosi
Use `gitoxide` for `list_files_git`

Related to #10150.

### Tasks

* [x] update `gix` to v0.60
* [x] assure this is tested (currently only git-tests run with `git2` and `gitoxide`)
* [x] allow `list_files_git` to use `gitoxide` if it is enabled as feature.
* [x] use dirwalk iterator
* [x] use new release of `gix` with necessary updates

### Review Notes

As this PR has come a long way, I decided to keep a few of the steps leading up to the final state, showing the PR's evolution in the hope it helps the review.

* Would it be better to simply use `gitoxide` for this without a switch? I don't think
  it will cause more trouble than `git2`, and if there is an issue I will fix it with priority.
* In one test, the walk resolves a symlink to a submodule to individual files, including the `.git/*` folder contained in the submodule which is ignored by the walk, i.e. `submodule/*` does not contain it, but `submodule-link/*` does. This is fixed in the gitoxide version, and the `git2` version.
* I noticed that symlinks are resolved for packaging *and* are allowed to point to anywhere, even outside of package root. I left it, but felt that maybe this should be reconsidered.

### Remarks

* I love the test-suite! It's incredibly exhaustive to the point where it uncovers shortcomings in `gitoxide`, which I greatly appreciate.
* I also love `git2` as it's API for many things leads to pretty idiomatic code, and sometimes I really have to work to match it. The example here is the initial `dirwalk()` method which requires a delegate as it doesn't just collect into a `Vec` like `git2` does (for good reason). Turning that into an iterator via `dirwalk_iter()` makes it far more usable, and will definitely be good for performance as the dirwalk work is offloaded into its own thread.
2024-03-24 20:01:45 +00:00
Scott Schafer
c006a307f7
fix: Warn on -Zlints 2024-03-23 13:53:14 -06:00
Scott Schafer
307c7f825c
feat: Add a basic linting system 2024-03-23 10:26:02 -06:00
Scott Schafer
abf0953292
feat: Add -Zcargo-lints 2024-03-23 10:24:50 -06:00
Scott Schafer
31c3052524
refactor(testsuite): Rename lints to lints_table 2024-03-22 11:33:58 -06:00
Eric Huss
e0e000e1e5 Fix debuginfo strip when using --target 2024-03-21 13:39:45 -07:00
Weihang Lo
46214f3c79
fix(alias): dont panic when resolving an empty alias 2024-03-21 00:44:18 -04:00
Weihang Lo
352d8bbe8e
test(alias): panic if alias is empty
This demonstrate the current bad behavior
2024-03-21 00:41:19 -04:00
Ed Page
6e4e31bec0 feat(add): Stabilize MSRV-aware version req selection
This is part of #9930 for rust-lang/rfcs#3537

This will make it easier to maintain an MSRV-compliant `Cargo.toml` but
leaves validation up to the user as the resolver will pick newer
versions.
This helps the MSRV-aware workflows enumerated in
rust-lang/rfcs#3537 though it could be confusing to the workflow with an
MSRV-compatible lockfile.
PR #13561 at least raises awareness of that discrepancy.

There is an unresolved question on differences in the resolver vs
`cargo add` for dealing with an unset `rust-version`.
However, we are only stabilizing the `cargo add` side which is a very
light two-way door as this is a UX-focused command and not a
programmatic command.

This hasn't gotten much end-user testing but, as its UX focused, that
seems fine.

As such, this seems like it is ready to stabilize.
2024-03-20 11:19:06 -05:00
Ed Page
71e362fb17 test(package): Clean up a build.rs test 2024-04-05 13:12:41 -05:00
bors
a9a0746945 Auto merge of #13703 - epage:toml, r=arlosi
test(metadata): Show behavior with TOML-specific types

### What does this PR try to resolve?

The goal is to know if/when these change so we can have a conversation about what to do.

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

### Additional information
2024-04-04 22:20:15 +00:00
Ed Page
b930f7ad1b test(metadata): Show behavior with TOML-specific types
The goal is to know if/when these change so we can have a conversation
about what to do.
2024-04-04 16:37:39 -05:00
bors
81ca704784 Auto merge of #13696 - arlosi:gitoxide-list-files-default, r=weihanglo
Switch to using gitoxide by default for listing files

### What does this PR try to resolve?

Uses gitoxide by for listing the contents of a git repository by default. Fixes #10150

It's possible out-opt of this change with the environment variable `__CARGO_GITOXIDE_DISABLE_LIST_FILES=1`. This opt-out mechanism is temporary and will be removed before the next release.

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

The newly added test fails with the `git2` implementation.
2024-04-04 03:21:55 +00:00
Arlo Siemsen
312e2aab7f Use strip_path_canonical for getting the relative path
This resolve an issue where the package path contains a symlink that's resolved by git
2024-04-03 12:59:49 -05:00
Arlo Siemsen
45c390a2a5 Switch to using gitoxide by default for listing files 2024-04-03 12:05:26 -05:00
bors
6774b8503c Auto merge of #13626 - linyihai:pre-update, r=weihanglo
Allow precise update to prerelease.

### What does this PR try to resolve?

This is a feature that attempts to support updates to pre-release versions via `cargo update --precise`.

when `precise-pre-release` used, the prerelase version will be taking consider as compatible version.  That said, we can update to any compatible pre-release version. The logic of checking the compatibility of pre-release versions is currently tentative and does not take many conditions into account, this part of the logic makes more sense when implemented in semver.

Use `-Zunstable-options`  instead of  `-Zprecise-pre-release`.

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

### Additional information
Part of https://github.com/rust-lang/cargo/issues/13290
2024-04-03 15:44:08 +00:00
Lin Yihai
179f2f1066 Allow precise update to prerelease. 2024-04-03 22:44:36 +08:00
Flowrey
318072f3cf preserve dependency features order 2024-04-01 19:26:09 +02:00
Flowrey
5b90c4bbde add tests for preserve features sorted and usorted 2024-04-01 13:56:04 +02:00
Ed Page
cad9673785 refactor(package): Move preamble to Manifest 2024-03-28 13:29:24 -05:00
bors
97ed4ff1ad Auto merge of #13664 - epage:refactor-toml, r=weihanglo
fix(toml): Warn on unused workspace.dependencies keys on virtual workspaces

### What does this PR try to resolve?

This splits out refactors that build on #13589 in preparation for resolving #13456.

As part of those refactors, I noticed an inconsistency on when we warn for unused keys.  We have parallel code paths between `to_virtual_manifest` and `to_real_manifest` and only one got updated on a change.  This syncs them up.  Hopefully the end state this builds to will reduce duplication.

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

### Additional information
2024-03-28 17:49:42 +00:00
bors
3d9dea672a Auto merge of #13665 - weihanglo:locked-frozen, r=epage
docs: clarify `--locked` ensures Cargo uses dependency versions in lockfile
2024-03-28 16:49:40 +00:00
Weihang Lo
26b2e74e55
docs: clarify --locked disallows changes in Cargo.lock 2024-03-28 12:08:57 -04:00
bors
acd673bcc4 Auto merge of #13648 - RalfJung:RUSTC_WORKSPACE_WRAPPER, r=weihanglo
RUSTC_WORKSPACE_WRAPPER: clarify docs

Follow-up to [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Question.20about.20RUSTC_WORKSPACE_WRAPPER)
2024-03-28 15:23:13 +00:00