6631 Commits

Author SHA1 Message Date
bors
fd5f1a05c1 Auto merge of #14630 - epage:implicit-removal, r=weihanglo
fix: Remove implicit feature removal

### What does this PR try to resolve?

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.

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

### Additional information

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 20:06:46 +00:00
Weihang Lo
b4253e5057
fix(help): mention --config <PATH> in help text 2024-10-01 14:54:52 -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
Weihang Lo
dfa8f26ddc
test(test): unnecessay env_remove("RUST_BACKTRACE")
This is done for all tests in f3c7525a61d61b347ed9e2e278dd84cc8c943531
2024-09-30 14:23:47 -04:00
Weihang Lo
e965b41fa0
test(test): relax compiler panic assertions 2024-09-30 14:23:47 -04:00
Weihang Lo
c3a74f5c36
test(rustflags): relax compiler panic assertions 2024-09-30 14:23:47 -04:00
Weihang Lo
e2946ab9fb
test(install): relax compiler panic assertions 2024-09-30 14:23:47 -04:00
Weihang Lo
d6ebb14227
test(features2): relax compiler panic assertions 2024-09-30 14:23:47 -04:00
Weihang Lo
7cb5be34c0
test(bench): relax compiler panic assertions 2024-09-30 14:23:47 -04:00
Weihang Lo
3f1b82893a
test(artifact_dep): relax compiler panic assertions 2024-09-30 13:26:49 -04:00
Weihang Lo
8534276f0d
test(build-std): relax compiler panic assertions 2024-09-30 13:25:34 -04:00
Weihang Lo
b1f574a10d
test(jobserver): relax compiler panic assertions 2024-09-30 13:25:33 -04:00
Weihang Lo
e4e970d309
test(freshness): relax compiler panic assertions 2024-09-30 13:25:33 -04:00
bors
1fad770250 Auto merge of #14556 - Ifropc:lockfile-path-install, r=weihanglo
feat: lockfile path implies --locked on cargo install

Follow-up of https://github.com/rust-lang/cargo/issues/14421
Resolving one of the items
> cargo install should make --lockfile-path imply --locked

Simply mirrored behavior as if `--locked` was provided (on creating the workspace)
2024-09-27 16:57:50 +00:00
bors
b396f2c3aa Auto merge of #14591 - epage:autolib, r=weihanglo
feat(toml): Add `autolib`

### What does this PR try to resolve?

PR #5335 added `autobins`, etc for #5330.  Nowhere in there is
discussion of `autolib`.

Cargo script disables support for additional build-targets by disabling
discovery.
Except we don't have a way to disable discovery of `autolib`, leading to #14476.
By adding `autolib`, we can continue in that direction.

This also allows us to bypass inferring of libs on published packages,
like all other build-targets which were handled in #13849.

Fixes #14476

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

### Additional information

As this seems fairly low controversy, this insta-stabilizes the field.
In prior versions of Cargo, users will get an "unused manifest key"
warning.
For packages where this is set by `cargo publish`, the warning will be suppressed and things will work as normal.
For `cargo vendor`, the same except there will be some churn in the
vendored source as this field will now be set.
For local development, it should be rare to set `autolib` so the lack of
error by discovering a file when this is set shouldn't be a problem.
2024-09-27 12:25:16 +00:00
bors
a3b35a0ccc Auto merge of #14598 - yichi170:correct-error-count, r=weihanglo
fix: correct error count for `cargo check --message-format json`

Hi! This is my first time contributing to Cargo. If there is anything that I need to do, please let me know!
(I'm not sure whether the commit message is aligned with the Cargo's convention. If it doesn't, I'm willing to modify it!)

This PR resolves the issue with incorrect error count and ensures warnings are correctly displayed when using `cargo check --message-format json`.

Fixes #14472
2024-09-27 11:47:04 +00:00
yichi170
71c830ccef fix: correct error count for cargo check --message-format json 2024-09-26 23:07:51 -05:00
Weihang Lo
498ae399bf
test: relax panic output assertion
rust-lang/rust#122565 adds a new line to thread panic output.
To make the current test suites works on stable, beta, and nightly,
this relaxes the assertion around that by globbing everything.
2024-09-26 16:00:54 -04:00
bors
7cbdcf0b21 Auto merge of #14404 - Ifropc:cargo_manifest_path, r=weihanglo
feat: add CARGO_MANIFEST_PATH env variable

Adds `CARGO_MANIFEST_PATH` variable as part of https://github.com/rust-lang/cargo/issues/12207
Context: `CARGO_MANIFEST_DIR` is not very useful, because there is no `Cargo.toml` file when running a cargo script. In cases when multiple scripts are stored in the same folder, we can't tell which script exactly is being run using `CARGO_MANIFEST_DIR`
2024-09-26 13:01:01 +00:00
Ifropc
d4ac929563 test: add tests for CARGO_MANIFEST_PATH in build.rs
- Uses same checks as for already existing CARGO_MANIFEST_DIR
2024-09-26 01:43:16 -04:00
Ifropc
bf37cf7f32 feat: --lockfile-path add install support 2024-09-26 01:19:40 -04:00
bors
4b81a83267 Auto merge of #14579 - linyihai:issue-14560, r=epage
fix(config): Don't double-warn about `$CARGO_HOME/config`

### What does this PR try to resolve?

The core requirements for this bug are
- You have a `$CARGO_HOME/.config`
- Your project is inside of `$HOME`

We have a check to make sure we don't double-walk `$CARGO/config` but
that check is *after* we warn about there being no `.toml` extension.

To fix this, we just need to move that check outside of the file lookup.
This required changing the `seen` check from checking whether walked the
config file to checking if we've walked the config dir.  As we only have
one file per directory, this should work.

Fixes #14560

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

test commit added the test, fix commit fixed the issue.

### Additional information
2024-09-26 01:45:10 +00:00
Ed Page
fe917f224d fix(config): Don't double-warn about $CARGO_HOME/config
The core requirements for this bug are
- You have a `$CARGO_HOME/.config`
- Your project is inside of `$HOME`

We have a check to make sure we don't double-walk `$CARGO/config` but
that check is *after* we warn about there being no `.toml` extension.

To fix this, we just need to move that check outside of the file lookup.
This required changing the `seen` check from checking whether walked the
config file to checking if we've walked the config dir.  As we only have
one file per directory, this should work.
2024-09-25 12:03:39 -05:00
Weihang Lo
35bb3dee7e
fix(cargo-rustc): give trailing flags higher precedence
Previously `cargo rustc -- <flags>` got a lower precedence than
some of the flags set by cargo internal.
This is a bit unintuitive as Cargo generally treats user-provided
CLI flags with the highest priority.

This commit changes `cargo rustc -- <flags>` to a higher precedence:
higher than most of flags set by Cargo, and only lower than
`build.rustflags` family.

Unsure if this affects people's workflow, so this behavior is only
enabled on nightly for collectin feedback. A environment variable
`__CARGO_RUSTC_ORIG_ARGS_PRIO=1` is provided for users to opt-out.
If everything goes well, the nightly gate will be removed after a
few of releases.

See discussion on https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/rustflags.20precendence.20of.20.60cargo.20rustc.60
2024-09-25 09:28:12 -04:00
Weihang Lo
7ded268948
test(cargo-rustc): show the current precedence 2024-09-25 09:26:05 -04:00
Lin Yihai
d5cb6b532f test: Add test for issue-14560 2024-09-25 11:27:50 +08:00
bors
cf781daeb7 Auto merge of #14595 - weihanglo:lockfile-v4, r=epage
feat: make lockfile v4 the default

### What does this PR try to resolve?

This commit makes lockfile version 4 the default version when Cargo
tries to write to a lockfile.

The lockfile version 4 has been stabilized since 1.78.0,
and will become default in 1.83.0.
the length of transition period is pretty similar as before.

One caveat is that in other output from Cargo,
e.g., `cargo metatada`, status messages,
`SourceID` will display in the v4 URL encoded format.
This shouldn't affect the majority of Rust users,
as `SourceId` representation should be opaque to them,
unless comparing `SourceId` across different version of toolchains.

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

Some of those tests don't really need to be `version = 4`.
They were updated for consistency.

### Additional information

This was discussed in Cargo meeting on 2024-09-24.
2024-09-25 02:32:18 +00:00
Weihang Lo
5dfdd59009
feat: make lockfile v4 the default
This commit makes lockfile version 4 the default version when Cargo
tries to write to a lockfile.

The lockfile version 4 has been stabilized since 1.78.0,
and will become default in 1.83.0.
the length of transition period is pretty similar as before.

One caveat is that in other output from Cargo,
e.g., `cargo metatada`, status messages,
`SourceID` will display in the v4 URL encoded format.
This shouldn't affect the majority of Rust users,
as `SourceId` representation should be opaque to them,
unless comparing `SourceId` across different version of toolchains.
2024-09-24 20:43:02 -04:00
Weihang Lo
f3672cbf39
test(lockfile): default lockfile version is still v3
It will become v4 when we changes the default.
2024-09-24 17:34:25 -04:00
Ed Page
5e35e271bc feat(toml): Add autolib
PR #5335 added `autobins`, etc for #5330.  Nowhere in there is
discussion of `autolib`.

Cargo script disables support for additional build-targets by disabling
discovery.
Except we don't have a way to disable discovery of `autolib`, leading to #14476.
By adding `autolib`, we can continue in that direction.

This also allows us to bypass inferring of libs on published packages,
like all other build-targets which were handled in #13849.

As this seems fairly low controversy, this insta-stabilizes the field.
In prior versions of Cargo, users will get an "unused manifest key"
warning.
For packags where this is set by `cargo publish`, the warning will be suppressed and things will work as normal.
For `cargo vendor`, the same except there will be some churn in the
vendored source as this field will now be set.
For local development, it should be rare to set `autolib` so the lack of
error by discovering a file when this is set shouldn't be a problem.

Fixes #14476
2024-09-24 11:24:24 -05:00
Ed Page
fa8fd7f48a test(script): Show autolib bug from #14476 2024-09-24 10:22:44 -05:00
Ed Page
023f4c66ca test: Remove completion tests
The tests are intended to spot check that shell completions are
registered correctly.  That is a low change, low risk area.  For shell
integration, we're relying on `clap_complete`s tests.
For our own candidates, we should test the candidate generation
directly, rather than end-to-end.

This reverts parts of commit e7ca9bec80ab5c010c1a84690816da7b64008257, reversing
changes made to bd5f32bb1c7ca273b5d86815bf0ae4adba59ddd8.

Fixes #14545
2024-09-24 08:58:57 -05:00
bors
844457cf85 Auto merge of #14577 - epage:tests-basic, r=weihanglo
test: Migrate remaining with_stdout/with_stderr calls

### What does this PR try to resolve?

This is part of #14039 and is another step towards us not needing our own redaction logic.

Along the way, I switched us to using `expect` to make it easier to tell when `allow(deprecated)` should be removed.

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

### Additional information
2024-09-24 02:47:22 +00:00
Ed Page
e72ef0b10f test: Migrate remaining with_stdout/with_stderr calls 2024-09-23 20:44:14 -05:00
Ed Page
1f5f7021e5 fix(test):; Allow '0 files' to not be redacted 2024-09-23 20:44:14 -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
bors
d7bffc302e Auto merge of #14280 - Flowrey:dry-run-install, r=weihanglo
Add a `--dry-run` flag to the `install` command

### What does this PR try to resolve?

This PR add the `--dry-run` flag to the `cargo install` command (see #11123).
I've tried to do the bare minimal for this flag to work without changing anything in the output.

In my opinion, the `--dry-run` flag should mimic as close as possible the behavior of the normal command to avoid missing potential issue in the normal execution. ~~Currently we're missing information about where the binary will be installed.~~

Unlike #13598 this PR:
- Include as much of the compilation process as possible without actually compiling
- use the information provided by `BuildContext` instead of `InstallablePackage::new`
- in the same way as `unit_graph`, it add a `dry_run` to the `CompileOptions` and return a `Compilation::new` from the function `compile_ws` without actually compiling.
- keeps the output the same rather than adding  status messages indicating which very broad actions would be performed
- ~~remove some warning not relevant in the case of  a `--dry-run`~~

Like #13598, the version check and crate downloads still occur.

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

The first commit include a unit tests to ensure that no binary is actually installed after the dry run.
There is also a snapshot test that show the diff output of the `--help` flag.

### Additional information

Tests and documentation done in #13598, may be cherry picked into this PR if needed.
2024-09-21 00:35:19 +00:00
Flowrey
b0e08fcd32 feat: add --dry-run to install command 2024-09-21 01:10:19 +02:00
Flowrey
8424b5f3f4 test: add test for install without dry-run option 2024-09-21 01:07:06 +02:00
Ifropc
284b380e08 test: install without lockfile-path
- Showcase that install will require --locked and will put lockfile in a
  specific directory
2024-09-19 18:27:52 -07:00
Ed Page
94db932164 fix(resolve): Improve multi-MSRV workspaces
We do this by resolving for a package version that is compatible
with the most number of MSRVs within a workspace.

If a version requirement is just right, every package will get the
highest MSRV-compatible dependency.

If its too high, packages will get MSRV-incompatible dependency
versions.
This will happen regardless of what we do due to the nature of
`"fallback"`.

If its too low, packages with higher MSRVs will get older-than-necessary
dependency versions.
This is similar to the "some with and without MSRV" workspaces.
When locking dependencies, we do report to users when newer MSRV/SemVer
compatible dependencies are available to help guide them to upgrading if
desired.

Fixes #14414
2024-09-19 15:46:22 -05:00
Ed Page
64abeb2ba1 test(msrv): Show msrv resolver issue 2024-09-19 15:46:10 -05:00
Ed Page
892ad4148d test(msrv): Clarify the differences in deps 2024-09-19 15:44:11 -05:00
Ed Page
3a47885f4f test(msrv): Clarify role of deps 2024-09-19 15:29:05 -05:00
Ed Page
6b796471a0 test(msrv): Clarify version numbers 2024-09-19 15:26:14 -05:00
Ed Page
fd743dacdc fix(resolve): Don't list transitive, incompatible dependencies as available
This is part of #13908
2024-09-19 11:42:33 -05:00
Urgau
4c38aeed80 Cleanup duplicated check-cfg lints logic 2024-09-19 15:52:49 +02:00
bors
1eb49a1030 Auto merge of #14554 - Rustin170506:rustin-patch-notes, r=epage
refactor(info): Use the `shell.note` to print the note
2024-09-17 17:09:37 +00:00
bors
32f024f788 Auto merge of #14537 - Rustin170506:rustin-patch-suggest-cargo-info, r=epage
Suggest `cargo info` command in the `cargo search` result
2024-09-17 15:55:50 +00:00
Rustin170506
0ba7540858 Use the shell.note to print the note
Signed-off-by: Rustin170506 <29879298+Rustin170506@users.noreply.github.com>
2024-09-17 23:53:39 +08:00