Commit graph

5570 commits

Author SHA1 Message Date
hi-rustin 12d7818192 Add features to the default Cargo.toml file
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-11-19 22:03:57 +08:00
bors 9f3b4883e8 Auto merge of #12178 - weihanglo:dogfood-lints-table, r=epage
chore: dogfood Cargo `-Zlints` table feature
2023-11-16 19:40:13 +00:00
Mohammad AlSaleh 0bbabecbf3 Fix a rustflags test using a wrong buildfile name
The test seem to have always had the wrong buildfile `build.rs.rs`.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
2023-11-16 20:03:01 +03:00
Weihang Lo 7a4754a1d3
lint: allow print_stdout and print_stderr 2023-11-16 11:35:21 -05:00
Weihang Lo 870f9ea7b3
lint: allow disallow_methods 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
Eric Huss 0afd943dad Fix some test output validation. 2023-11-15 15:10:18 -08:00
bors 6658e1abe3 Auto merge of #12977 - Eh2406:bug_12941, r=epage
If the only path is a loop then counted as the shortest path.

This is a fix for #12941

This graph data structure is used to store dependency DAGs. Where each edge represents a dependency from a package to the package that fulfilled the dependency. Different parts of the resolver store this data in opposite directions, sometimes packages point at the things that depend on them other times packages point to the parents that required them. Error messages often need to report on why a package is in the graph, either by walking up toward parents or down toward children depending on how this graph is stored. #12678 unified the two different walking implementations, and replace them with a breadth first search so as to find the shortest path. This code ignored when edge pointed at a package that had already been reached, because that generally describes a longer path to an existing package.

Unfortunately, when I said this was a DAG that was a simplification. There can be cycles introduced as dev-dependencies. The existing code would reasonably ignore the cycles figuring that if we continue searching we would eventually find the root package (a package that nothing depended on). Missing the possibility that the root package created the cycle.

Now we search through the entire graph looking for a root package. If we do not find a root package we report the path to the last package we processed.
2023-11-15 16:09:00 +00:00
bors 0fcc90dc24 Auto merge of #12950 - epage:msrv, r=Eh2406
fix(resolver): Prefer MSRV, rather than ignore incompatible

### What does this PR try to resolve?

This is another experiment for #9930.

Comparing preferring over exclusively using MSRV compatible:

Benefits
- Better error messages
- `--ignore-rust-version` is implicitly sticky

Downsides
- Can't backtrack for MSRV compatible version
- Still requires workspace-wide MSRV (compared to our desired end state of declaring MSRV as yet another dependency)

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

### Additional information

Note: `--ignore-rust-version` is not yet implemented for the resolver.

This builds on #12930
2023-11-14 21:56:00 +00:00
Ed Page 0d29d3f71b fix(resolver): Prefer MSRV, rather than ignore incompatible
This is another experiment for #9930.

Comparing preferring over exclusively using MSRV compatible:

Benefits
- Better error messages
- `--ignore-rust-version` is implicitly sticky

Downsides
- Can't backtrack for MSRV compatible version
- Still requires workspace-wide MSRV (compared to our desired end state of declaring MSRV as yet another dependency)

This builds on #12930
2023-11-14 14:56:58 -06:00
Ed Page 0bc5d22285 test(resolver): Verify backtracking for MSRV resolver 2023-11-14 14:56:53 -06:00
Jacob Finkelman d19273c04d If the only path is a loop then counted as the shortest path. 2023-11-14 20:18:43 +00:00
Jacob Finkelman cd2e4e3912 add a test 2023-11-14 20:18:43 +00:00
David Hotham 962d89a8d8
fix error message for duplicate links 2023-11-14 17:53:58 +00:00
bors dd94e9d9ce Auto merge of #12944 - linyihai:issue_12790, r=weihanglo
Only filter out target if its in the package root

### What does this PR try to resolve?
Only filter out target if its in the package root. Fixed https://github.com/rust-lang/cargo/issues/12790

### How should we test and review this PR?
Add two testcase in tests/testsuite/package.rs for this PR.

- `include_files_called_target_project` testcase test the logic for none git repository. By the way, our PR was based on git repository,  so this testcase was a little irrelevant.
-  `include_files_called_target_git` testcase was made for git repository.  There are two cases here, one is the target in the uncommitted state, at this time should not be included, and one is the target in the committed state, at this time should be included

### Additional information
2023-11-14 13:39:28 +00:00
Lin Yihai b2b026bfbb Improve testcase include_files_called_target_git 2023-11-14 11:25:11 +08:00
Eric Huss 8161ba50cd Ignore changing_spec_relearns_crate_types on windows-gnu 2023-11-13 19:17:51 -08:00
bors a4764b0dd8 Auto merge of #12962 - hi-rustin:rustin-patch-cargo-search, r=weihanglo
Improve about information of `cargo search`
2023-11-13 12:40:10 +00:00
hi-rustin 918d32b34d Improve about information of cargo search
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-11-13 19:50:21 +08:00
Eric Huss 80ffb1de1c Fix --quiet being used with nested subcommands.
This fixes an issue where `--quiet` doesn't work with commands that have
subcommands. This is because `config_configure` only looks at the global
and top-level subcommand, and not deeper subcommands. The issue was that
`--quiet` was not defined as a global flag. This was changed in
https://github.com/rust-lang/cargo/pull/6358 in order to give a better
help message for `cargo test --quiet`. I don't remember if clap just
didn't support overriding at the time, or if we just didn't know how it
worked. Anyways, it seems to work to override it now, so I think it
should be fine to mark it as global.

This should bring in `--quiet` more in-line with how `--verbose` works.
This means that `--quiet` is now accepted with `cargo report`,
`cargo help`, and `cargo config`.

This also fixes `--quiet` with `cargo clean gc`.

This should also help with supporting `--quiet` with the new `cargo
owner` subcommands being added in
https://github.com/rust-lang/cargo/pull/11879.

Fixes #12957
2023-11-12 11:17:43 -08:00
Eric Huss 0cd970b1c0 Move gc options under a cargo clean gc subcommand.
This was requested to separate the interaction of `cargo clean` and the
cleaning of global cache data, and to minimize the impact of this
initial implementation.
2023-11-11 12:36:25 -08:00
Eric Huss 9a41a6110c Remove shared-target gc kind.
This kind is unlikely to be implemented in the foreseeable future, and
we don't really know what it is going to look like.
2023-11-11 10:56:58 -08:00
Eric Huss ead7904ad4 Add gc tracing target. 2023-11-11 10:56:58 -08:00
Eric Huss da3ca05677 Add a global cache garbage collector.
This adds a garbage collector which will remove old files from cargo's
global cache.

A general overview of the changes here:

- `cargo::core::global_cache_tracker` contains the `GlobalCacheTracker`
  which handles the interface to a sqlite database which stores
  timestamps of the last time a file was used.
- `DeferredGlobalLastUse` is a type that implements an optimization for
  collecting last-use timestamps so that they can be flushed to disk all
  at once.
- `cargo::core::gc` contains the `Gc` type which is the interface for
  performing garbage collection. It coordinates with the
  `GlobalCacheTracker` for determining what to delete.
- Garbage collection can either be automatic or manual. The automatic
  garbage collection supports some config options for defining when
  it runs and how much it deletes.
- Manual garbage collection can be performed via options to `cargo
  clean`.
- `cargo clean` uses the new package cache locking system to coordinate
  access to the package cache to prevent interference with other cargo
  commands running concurrently.
2023-11-11 10:56:58 -08:00
Lin Yihai 722d8f1c1d Add target folder but not committed 2023-11-10 15:49:57 +08:00
Lin Yihai 4577c0ec61 Correct the situation with git repository test cases 2023-11-10 14:22:03 +08:00
Karel Peeters 2c503f89c4 Add unit test for files called target.
https://github.com/rust-lang/cargo/issues/12790
2023-11-10 10:38:26 +08:00
bors 2ef56214b3 Auto merge of #12939 - hi-rustin:rustin-patch-feature-msg, r=epage
Fix the invalidate feature name message
2023-11-08 17:15:01 +00:00
hi-rustin 976835d045 Update the test for the msg change
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-11-08 23:40:24 +08:00
hi-rustin d61816465f Add test for empty feature name
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-11-08 22:52:35 +08:00
Ed Page e70e310ce0 fix: Report more detailed semver errors
For `cargo install` we'll now show a more specific parse error for
semver, much like other parts of cargo.

This came out of my work on #12801.  I was looking at what might be
appropriate to put in a `cargo-util-semver` crate and realized we have
the `ToSemver` trait that exists but doesn't do much, so I dropped it.
2023-11-06 15:24:32 -06:00
hi-rustin fb0bbe36f1 Search dep in other tables and update tests
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-11-07 09:33:44 +08:00
bors f095603db0 Auto merge of #12923 - Eh2406:bug_12920, r=epage
Bug 12920

Fix for #12920, a regression introduced in #12749.

This also as a test case for an existing Terrible error message.
2023-11-06 20:58:55 +00:00
Jacob Finkelman 7997306a0b restore error message 2023-11-06 20:16:26 +00:00
Jacob Finkelman 2352cbd1f9 add a test 2023-11-06 20:13:56 +00:00
bors 4300dd7394 Auto merge of #12911 - epage:manifest-schema, r=weihanglo
refactor(toml): Pull out the schema

### What does this PR try to resolve?

On its own, this PR is a net negative for readability / complexity.  It moves all of the serde types related to manifest from `toml/mod.rs` to `toml/schema.rs`, leaving a lot of the functions and some trait implementations back in `toml/mod.rs` (some basic functions that made sense for the type on their own were also moved).

So why do this?  This is an ooch towards having the schema broken out into a separate package (#12801).  To do this, we need to
- Identify what all types need to be put in the package.  This refactor highlights the dependence on `RustVersion` and `PackageIdSpec`
- Highlights what functionality we need to find a new home for

Follow up PRs would
- Find better homes for the logic in `toml/mod.rs`, moving us away from having `impl schema::Type` blocks.
- Pull out a `src/cargo/util_semver` package to own `PartialVersion` (at least) as prep for making a `cargo-util-semver` package
- Move `RustVersion` to `manifest-toml/schema.rs`, deciding what functionality needs to move with the type
- Move or copy `PackageIdSpec` into `manfest-toml/schema.rs`, deciding what functionality remain in `core/` and what moves over
- Move `toml/schema.rs` to `src/cargo/util_schema`
- Actually make `cargo-util-semver` and `cargo-util-manifest-schema` packages

So why do this now? This is a big change!  By being incremental
- Reduce churn for me and others
- Be easier to review
- Collect feedback as we go on the whole plan to avoid more painful changes later

We *can* back this out if needed but the further we go, the more painful it will be.

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

### Additional information
2023-11-06 19:49:14 +00:00
Ed Page c12c4c3f8d tests: Remove plugin tests
Compiler plugins were removed in rust-lang/rust#116412, so we don't need
these tests.

As for the `plugin` field on build-targets, it appears to be
[stable-but-deprecated](https://doc.rust-lang.org/cargo/reference/cargo-targets.html#the-plugin-field),
so I left it alone
2023-11-06 09:55:31 -06:00
bors 65e297d1ec Auto merge of #12915 - epage:test-targets, r=weihanglo
fix(cli): Clarify --test is for targets, not test functions

We already refer to test targets as "test targets" instead of "tests" in `--test` but not `--tests` or in the error output.  This makes it uniformly refer to them as "test targets", making it clearer that these aren't test functions.

Fixes #7864
2023-11-03 20:56:31 +00:00
Ed Page 76918a0e99 fix(cli): Clarify --test is for targets, not test functions
We already refer to test targets as "test targets" instead of "tests" in
`--test` but not `--tests` or in the error output.  This makes it
uniformly refer to them as "test targets", making it clearer that these
aren't test functions.

Fixes #7864
2023-11-03 15:45:00 -05:00
bors 6354bb3d81 Auto merge of #12908 - weihanglo:profile-merge-trim-paths, r=epage
fix: merge `trim-paths` from different profiles
2023-11-02 12:29:20 +00:00
Weihang Lo 7535971d8b
fix(trim-paths): merge trim-paths from different profiles
In 4d29af1 we forgot to add trim-paths to `fn merge()`.
This commit follows how `-Zprofile-rustflags` works ---
overriding instead of merging array.
2023-11-01 23:24:15 -04:00
Weihang Lo 618701921d
test(trim-paths): profile merge doesn't work
This demonstrate the buggy behavior that
profile merge on `trim-paths` doesn't work as expected.
2023-11-01 23:19:49 -04:00
Ed Page 9a1bbc9625 refactor(toml): Pull out schema
Remaining steps
- Decouple `toml/mod.rs` functionality from `toml/schema.rs`
- Pull out `core/` types referenced by `toml/schema.rs`
2023-11-01 20:59:46 -05:00
David Tolnay 649a14d470
Add regression test for issue 6915: features and transitive dev deps 2023-11-01 14:22:16 -07:00
renovate[bot] b4efcdbf32 chore(deps): update rust crate gix to 0.55.2 2023-11-01 00:12:37 +00:00
Weihang Lo dd0aea350c
feat(trim-paths): set env CARGO_TRIM_PATHS for build scripts 2023-10-31 12:00:48 -04:00
bors 4aee12c1f8 Auto merge of #12625 - weihanglo:rfc3127, r=epage
feat: implement RFC 3127 `-Ztrim-paths`
2023-10-31 02:23:00 +00:00
Weihang Lo 63cef2c4fc
feat(trim-paths): rustc invocation integration 2023-10-30 16:38:56 -04:00
Weihang Lo 557fc4fd3e
test(trim-paths): verify current behavior with -Ztrim-paths 2023-10-30 16:38:55 -04:00
Weihang Lo 08c5e35f60
test(trim-paths): parsing in mainfest and config 2023-10-30 16:38:55 -04:00