85 Commits

Author SHA1 Message Date
Lin Yihai
861429b113 doc: Add README for resolver-tests 2024-05-30 17:02:34 +08:00
bors
e08a81333c Auto merge of #13281 - LuuuXXX:issue-10729, r=epage
fix(add): Improve error when adding registry packages while vendored

### **What does this PR try to resolve?**

When a vendored directory is established, cargo add no longer adds new packages. Instead, it tries to translate a package name into a package that already exists in the vendored directory.
[More details](https://github.com/rust-lang/cargo/issues/10729#issue-1260548746)

Since `@epage` has done most of the work, here I do the rest of the finishing work.

Improves the error from #10729

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

The implementation procedure is as follows:
https://github.com/rust-lang/cargo/issues/10729#issuecomment-1191633351

Test steps:
1. Try to get an arbitrary crate and execute `cargo vendor` command.
2. Configure the vendor directory in .cargo/config.toml.
3. Add `alter-registry` to the config.toml file.
```
[registries]
alter-registry= { index = "XXX" }
```
4. run the same `cargo add` command.
```
cargo add another-crate --registry alter-registry
```
2024-02-22 17:28:17 +00:00
LuuuX
640c0774da Rename Fuzzy to Alternatives 2024-02-22 14:08:46 +08:00
LuuuX
a31184b9eb Added QueryKind::Normalized, and used it in cargo-add 2024-02-22 13:36:28 +08:00
Scott Schafer
305efa63cc
chore: Rename Config to GlobalContext 2024-02-20 11:55:15 -07:00
Eric Huss
daa884169c Fix redundant imports. 2024-02-20 09:57:03 -08:00
Weihang Lo
cd7cca369e
refactor: don't derive Default for ResolveVersion
This prevents a misuse of it.
2024-02-16 10:06:32 -05:00
Weihang Lo
fb95ac4887
feat: respect rust-version when generating lockfile
Respect `package.rust-version` when generating lockfile, so that
a package with an old MSRV will never get an incompatible lockfile,
even when using the latest Cargo.

Users are still able to edit the `version` field in the lockfile
manually, if they intend to switch to a specific lockfile version.
2024-02-16 10:06:00 -05:00
Ed Page
9438f80042 chore: Remove rust-version from private packages
I removed it from `cargo-test-support` and `cargo-test-macro`, despite
people depending on those (via git) because my long term plan is resting
on the `auto` value which won't affect git dependencies.
2024-01-18 15:24:25 -06:00
Ed Page
633929d3aa refactor(schemas): Pull out cargo-util-schemas crate
Fixes #12801
2023-12-15 13:22:25 -06:00
Ed Page
808e2a174f refactor(schema): Adopt RustVersion 2023-12-11 13:44:14 -06:00
Ed Page
378502bf20 refactor: Try to make PackageId conversion clearer 2023-12-01 10:48:14 -06:00
Ed Page
a43e09073c test(resolver): Don't bother generating public cases 2023-11-29 13:11:39 -06:00
Ed Page
e6da166c8b test(resolver-tests): Remove public dep support from SAT resolver 2023-11-29 12:17:26 -06:00
Ed Page
71172d52b5 fix(resolver): Remove unused public-deps error handling
To implement rust-lang/rfcs#3516, we need to decouple the resolver's
behavior from the unstable flag.  Since the code path is now dead, I
went ahead and removed it.
2023-11-22 15:20:10 -06:00
Weihang Lo
7a4754a1d3
lint: allow print_stdout and print_stderr 2023-11-16 11:35:21 -05:00
Weihang Lo
1539b3dfc1
lint: dogfood ourselves lints table in manifest
These lint rules are from src/lib.rs. We aim to remove
them in the source code once `Zlints` hit stable.
2023-11-16 11:35:21 -05:00
Jacob Finkelman
6835fa3867 query{_vec} should use IndexSummary 2023-11-13 19:39:25 +00:00
Ed Page
6bfc32a15e refactor(resolver): Pull MSRV handling to VersionPreferences 2023-11-07 20:39:35 -06:00
Ed Page
bf2987b09b refactor(resolver): Track minimal-versions in VersionPreferences
This had repurcussions on direct-minimal-versions as it before relied on
the ordering parameter to `sort_sumarries`.
2023-11-07 20:39:35 -06:00
Ed Page
3cdddbf033 test(resolver): Improve failure output 2023-11-07 20:39:35 -06:00
Jacob Finkelman
679d65103f shortest path is probably more informative than random path for error messages 2023-09-19 20:39:02 +00:00
Jacob Finkelman
245e69ce10 add a test for shortest path 2023-09-19 20:22:13 +00:00
Ed Page
4135f562b8 refactor(manifest): Clarify the specialized role of RustVersion 2023-09-13 21:59:26 -06:00
Weihang Lo
437942ee7e
lint: use eprintln for human-facing outputs 2023-09-14 13:43:47 +08:00
Weihang Lo
e575448574
refactor: flatten module path of SourceId 2023-09-07 21:06:35 +08:00
Weihang Lo
b6c4e47cc0
refactor: put Source trait under cargo::sources 2023-09-07 21:06:34 +08:00
Jacob Finkelman
16b330bc59 stop using lazy_static 2023-09-01 21:38:03 +00:00
Ed Page
4820624ce7 feat(resolver): Respect MSRV 2023-08-25 10:42:26 -05:00
Ed Page
423a334520 refactor: Parse, don't validate, rust_version
By using the `PartialVersion` type with serde, we get the context for
the error automatically.
2023-08-24 14:15:35 -05:00
Ed Page
7a65c826a0 fix: Set MSRV for internal packages
For now, I'm punting on packages we generally expect others to use
2023-08-22 16:46:47 -05:00
Ed Page
e4877cc701 refactor: Update resolver-tests to 2021 edition 2023-07-17 13:21:41 -05:00
Eric Huss
9835622853 Convert valid feature name warning to an error. 2023-06-20 12:39:27 -07:00
Weihang Lo
8cb220f5eb
refactor: use IsTerminal from std instead of is-terminal crate 2023-06-01 21:50:43 +01:00
Scott Schafer
34b8c39d77 chore: Use [workspace.dependencies] 2023-04-28 09:56:09 -05:00
bors
7a90ba1ecc Auto merge of #12043 - epage:rust-version, r=weihanglo
feat: Add `-Zmsrv-policy` feature flag

### What does this PR try to resolve?

Nothing noticeable....

The intent is to unblock experiments with different compatible MSRV policies like
- #9930
- #10653
- #10903

While I normally don't like PRs that do nothing on their own, this at least allows any one of those efforts to move forward with different people without juggling these base commits for whoever is first to include in their PR

While there isn't an RFC for this yet, this is intended to allow us to experiment to get a better idea of what we should put in an RFC.  In some cases, we first do an eRFC for this but I assumed this wouldn't be needed in this case as this builds on rust-lang/rfcs#2495 and, I'm assuming, will be more surgical in nature

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

The `Summary` changes are largely untested as they will be mostly tested through the future work that builds on this PR.  However, I wasn't too concerned about that because the code is relatively trivial.

### Additional information

I chose the name `msrv-policy` to distinguish this unstable feature from `rust-version`.  Though those appear in different places (`Cargo.toml` vs `-Z`), I can see them being confusing which was especially apparent when editing `unstable.md` which has an anchor for `rust-version`.
2023-04-28 14:55:25 +00:00
Ed Page
077b1bc311 chore: Mark unpublished crates as such
This is a follow up to #12039.
This makes it easier for tools to report less irrelevant information.

I did both `publish = false` and `version = "0.0.0"` to help draw
attention to the fact that these crates are internal (inspired by a
matklad post).

I left `cargo-test-macro` and `cargo-test-support` in for my own
personal bias of one day wanting to see those crates published...

The only one removed that had previously been published was `mdman` but
seeing as that was a `0.0.0`, I'm assuming that was a mistake or just
reserving the name.

Before:
```console
$ cargo unpublished
name published current
==== ========= =======
cargo-platform 0.1.2 0.1.3
cargo-test-macro - 0.1.0
cargo-test-support - 0.1.0
cargo-util 0.2.3 0.2.4
crates-io 0.36.0 0.36.1
mdman 0.0.0 0.1.0
resolver-tests - 0.1.0
cargo 0.70.1 0.72.0
semver-check - 0.1.0
cargo-credential 0.1.0 0.2.0
cargo-credential-1password 0.1.0 0.2.0
cargo-credential-gnome-secret 0.1.0 0.2.0
cargo-credential-macos-keychain 0.1.0 0.2.0
cargo-credential-wincred 0.1.0 0.2.0
benchsuite - 0.1.0
```

After:
```console
name published current
==== ========= =======
cargo-platform 0.1.2 0.1.3
cargo-test-macro - 0.1.0
cargo-test-support - 0.1.0
cargo-util 0.2.3 0.2.4
crates-io 0.36.0 0.36.1
cargo 0.70.1 0.72.0
cargo-credential 0.1.0 0.2.0
cargo-credential-1password 0.1.0 0.2.0
cargo-credential-gnome-secret 0.1.0 0.2.0
cargo-credential-macos-keychain 0.1.0 0.2.0
cargo-credential-wincred 0.1.0 0.2.0
```
2023-04-26 17:51:16 -05:00
Ed Page
f3728d3250 feat: Expose 'rust_version' in the Summary 2023-04-26 15:59:22 -05:00
Eric Huss
3e20ffda68 Update proptest 2023-03-25 13:13:24 -07:00
Ed Page
1d153f1d64 feat(resolver): -Zdirect-minimal-versions
This is an alternative to `-Zminimal-versions` as discussed in #5657.

The problem with `-Zminimal-versions` is it requires the root most
dependencies to verify it and we then percolate that up the stack.  This
requires a massive level of cooperation to accomplish and so far there
have been mixed results with it to the point that cargo's unstable
documentation discourages its use.

`-Zdirect-minimal-versions` instead only applies this rule to your
direct dependencies, allowing anyone in the stack to immediately adopt
it, independent of everyone else.

Special notes
- Living up to the name and the existing design, this ignores yanked
  crates.  This makes sense for `^1.1` version requirements but might
  look weird for `^1.1.1` version requirements as it could select
  `1.1.2`.
- This will error if an indirect dependency requires a newer version.
  Your version requirement will need to capture what you use **and** all
  of you dependencies.  An alternative design would have tried to merge
  the result of minimum versions for direct dependencies and maximum
  versions for indirect dependencies.  This would have been complex and
  led to weird corner cases, making it harder to predict.  I also suspect
  the value gained would be relatively low as you can't verify that
  version requirement in any other way.
  - The error could be improved to call out that this was from minimal
    versions but I felt getting this out now and starting to collect
    feedback was more important.
2023-02-14 15:44:30 -06:00
Scott Schafer
c3043d9a9e chore: Make dependencies alphabetical order 2023-02-15 09:22:08 -06:00
Julien Merzoug Cosnuau
4db4a13662 Fix typo 2022-12-16 22:02:41 +01:00
Ed Page
48895b1681 fix: Move off atty to resolve soundness issue
There is a soundness issue with atty when building on Windows with a
custom allocator.

This PR switches direct dependencies on atty to is-terminal.  New semver
compatible versions of clap and snapbox remove atty. #11417 upgrades
env_logger to remove it from there.

Fixes #11415
2022-11-25 06:28:01 -06:00
Ed Page
a645c4fef0 refactor(source): Replace bool with enum 2022-07-21 09:27:01 -05:00
Ed Page
6a62d35458 refactor(registry): Move query out-param to be last 2022-07-20 12:54:16 -05:00
Arlo Siemsen
82093ad9dc Registry functions return task::Poll to enable parallel fetching of index data. 2022-02-28 12:22:11 -08:00
Alex Crichton
c687d83ada Remove authors directives from Cargo crates
Most of these are pretty dated and Cargo defaults nowadays to not
emitting an `authors` field so this commit also removes them from the
manifests.
2021-10-22 10:27:20 -07:00
Weihang Lo
0afd40b4de
Update tests to display dep-req info for dep-chain 2021-08-24 00:39:38 +08:00
Alik Aslanyan
8ee76f6082
Weather is not nice today.. 2021-07-23 17:15:14 +04:00
Dustin J. Mitchell
76a079cbd9 Factor version preferences into a struct
This concentrates all of the "prefer this version" logic previously
handled with `try_to_use` and `prefer_patch_deps` parameters into a
struct that hides both the reason a package version might be preferred
and the form that preference took (Dependency or PackageId).  Besides
simplifying `RegistryQuerier::query` slightly, this invites further
refinements to version preferences to support new cargo features.
2021-07-18 21:05:16 +00:00