64 Commits

Author SHA1 Message Date
Eric Huss
1ce8023626 Rustfmt 2024 2025-07-05 19:50:36 -07:00
pudongair
6c7c360dec chore: fix some typos
Signed-off-by: pudongair <744355276@qq.com>
2025-03-19 21:05:18 +08:00
Ed Page
b45ca32bff refactor(source): Rename AlternativeVersions to RejectedVersions
Really, when we switch the req to a wildcard, it is an alternative
version, so for yanked and unsupported we need a different name.
2024-12-11 10:48:14 -06:00
Ed Page
d2fcf6b13f fix(resolver): Report unmatched versions, rather than saying no package 2024-12-05 12:55:16 -06:00
Ed Page
4d7913bfe3 refactor(source): Qualify what alternatives we look for 2024-12-05 12:55:16 -06:00
x-hgg-x
04e4270758 test: add more resolver helper methods 2024-10-08 08:04:43 +02:00
x-hgg-x
cc4c3e784a test: separate resolver tests into multiple files 2024-10-08 08:04:43 +02:00
Ed Page
5c87c14f9a docs: Declare support level for each crate in our Charter / docs
This is to bring us into conformance with the [Rust crate ownership
policy](https://forge.rust-lang.org/policies/crate-ownership.html).

Items of note
- `cargo-credential-1password` is declared as Experimental as it is
  intended for the community but I was unsure if we wanted to commit to
  full support for it.  In my mind, the ideal thing to do would be to
  expatriate this to 1password.
- `home` is declared as Internal despite its wide use within the
  ecosystem.
- `cargo-credential` is declared as Intentional as its an API intended
  for the wider ecosystem and I didn't see a reason to declare it
  experimental.
- `cargo-platform`, `cargo-util-schemas`, and `crates-io` are declared
  as Intentional as they are both used internally and intended for
  others to use for logic that integrates with cargo/registries.
  I wondered about these being Experimental or Internal instead.
2024-09-26 12:43:09 -05:00
x-hgg-x
6f1315be84 test: add support for features in the sat resolver 2024-09-27 22:09:32 +02:00
x-hgg-x
aece1f4623 test: refactor resolver test functions 2024-09-26 15:43:26 +02:00
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
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
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
Eric Huss
9835622853 Convert valid feature name warning to an error. 2023-06-20 12:39:27 -07:00
Ed Page
f3728d3250 feat: Expose 'rust_version' in the Summary 2023-04-26 15:59:22 -05:00
Julien Merzoug Cosnuau
4db4a13662 Fix typo 2022-12-16 22:02:41 +01: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
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
Dustin J. Mitchell
bd4a353e98 Prefer patched versions of dependencies
When selecting among several versions of a paackage, prefer versions
from `[patch]` sections over other versions, similar to how locked
versions are preferred.

Patches come in the form of a Dependency and not a PackageId, so this
preference is expressed with `prefer_patch_deps`, distinct from
`try_to_use`.
2021-07-09 18:23:21 +00:00
David Tolnay
396bdd3a89
Remove parsing of broken version syntax from 5 years ago 2021-05-26 14:37:39 -07:00
Eric Huss
10eb56f2c4 Update clippy lint allow set. 2021-04-13 09:02:07 -07:00
Eric Huss
378b086f2c Fix redundant_semicolons warning in resolver-tests. 2021-03-20 17:44:08 -07:00
Kornel
3f7f0942cd track_caller on custom assert functions 2021-03-03 17:17:07 +00:00