6610 Commits

Author SHA1 Message Date
Ed Page
fa8fd7f48a test(script): Show autolib bug from #14476 2024-09-24 10:22:44 -05: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
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
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
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
Rustin170506
52f8487c79 Suggest cargo info command in the cargo search result 2024-09-17 23:51:57 +08:00
bors
468f1500bd Auto merge of #14546 - ehuss:disable-shell-completions, r=weihanglo
Disable the shell_completions tests

The shell_completions tests have a few issues that are causing some problems. See https://github.com/rust-lang/cargo/issues/14545 for a description. This disables the tests until those can get resolved.
2024-09-14 19:24:54 +00:00
Eric Huss
47f4cdc093 Disable the shell_completions tests 2024-09-14 11:53:00 -07:00
Guillaume Dallenne
a53b81a49d
fix(vendor): trust crate version only when coming from registries 2024-09-12 09:10:30 +02:00
Guillaume Dallenne
5fa43ee1c5
test(vendor): add test case updating git dependency without version change 2024-09-12 09:03:49 +02:00
bors
e7ca9bec80 Auto merge of #14493 - shannmu:dynamic_switch, r=epage
feat: Add native comlpetion with CompleteEnv under the nightly

### What does this PR try to resolve?

Related issue https://github.com/rust-lang/cargo/issues/6645
Tracking issue https://github.com/rust-lang/cargo/issues/14520
This PR is the first step to move cargo shell completions to native completions by using `clap_complete` crate. It makes users could complete cargo subcommand and flags.

By using `clap_complete` crate, we could extend the supported shells to Bash, Zsh, Elvish, Fish, and PowerShell. However, at the current stage, the support for PowerShell in `clap_complete` is not fully developed.
See https://github.com/clap-rs/clap/issues/3166 to get more context about what features `clap_complete` has supported.

### How to test and review this PR?

1. Build a test environment, including the necessary short completion scripts, and the `complete` function to start an interactive shell with the help of a pty device and obtain completion results.
2. Simply test the completion results of subcommands in bash, zsh, fish, elvish.
2024-09-10 13:59:53 +00:00
shannmu
7b0b97789c ci: Install zsh, fish and elvish on ubuntu-lastest for the test and test_gitoxide jobs 2024-09-10 16:03:30 +08:00
shannmu
84caa8301a feat: Add native completions with CompleteEnv and under the nightly features 2024-09-10 15:08:19 +08:00
bors
bd5f32bb1c Auto merge of #14505 - epage:new, r=weihanglo
fix(new): Add to workspace relative to manifest, not current-dir

### What does this PR try to resolve?

We were correctly doing this for cases like `cargo new foo` or
`cargo new deeper/than/this/directory/foo` but not `cargo new ../foo`.

This came up when discussing #14501

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

### Additional information
2024-09-09 22:17:11 +00:00
bors
0b390cd484 Auto merge of #14499 - felixmoebius:rustc-crate-type-parsing, r=weihanglo
Fix parsing of comma separated values in --crate-type flag

### What does this PR try to resolve?

According to the documentation the `--crate-type` flag accepts a comma separated list of crate types. However, these are never actually split into individual items and passed verbatim to rustc.

Since cargo fails to associate cases such as 'staticlib,cdylib' to a specific crate type internally, it has to invoke rustc to determine the output file types for this unknown crate type, which returns only the first file type of the first crate type in the list. Consequently cargo will be looking only for a single '.a' artifact on Linux to be copied to the target directory.

Fix this by splitting the list of provided crate types into individual items before further processing them.

Fixes #14498

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

Updated corresponding test cases

### Additional information
2024-09-09 18:46:29 +00:00
shannmu
f25806c472 test: Add test codebase for shell completions 2024-09-09 23:39:21 +08:00
Ethan Brierley
fe9600675e
feat: include public/private dependency status in cargo metadata output 2024-09-07 07:28:28 +01:00
Ethan Brierley
6829bf7ae0
test: public dependencies don't show up in cargo-metadata 2024-09-07 07:28:28 +01:00
bors
2ddc46a2a5 Auto merge of #14507 - epage:public-on-stable, r=weihanglo
fix(toml): Don't require MSRV bump for pub/priv

### What does this PR try to resolve?

In #13308, we decided to make the feature gate for public/private dependencies non-blocking.
Generally, people opt-in to a feature that is non-blocking through `-Z` but some nightly users want an "always on" mode for this, so we offered both in #13340.
In #13340, we made both feature gates work but we did not make them non-blocking for stable, only nightly.

This change makes the feature gate non-blocking on stable.

Unfortunately, this means that 1.83 will be the MSRV for people using public dependencies.  Good thing the feature is indefinitely blocked in rustc as that gives us more time.

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

### Additional information
2024-09-07 01:41:42 +00:00
Ed Page
1c8509b219 fix(toml): Don't require MSRV bump for pub/priv
In #13308, we decided to make the feature gate for public/private
dependencies non-blocking.
Generally, people opt-in to a feature that is non-blocking through `-Z`
but some nightly users want an "always on" mode for this, so we offered
both in #13340.
In #13340, we made both feature gates work but we did not make them
non-blocking for stable, only nightly.

This change makes the feature gate non-blocking on stable.
2024-09-06 14:49:43 -05:00
bors
dcb4ef9a10 Auto merge of #14448 - stupendoussuperpowers:bail, r=epage
bail before packaging on same version

Fixes #3662. Cleaned up commits from #14338.
2024-09-06 19:40:40 +00:00
sanchitlegalai
6ede1e2b27 fix(publish): Bail on existing version 2024-09-06 13:25:55 -05:00
sanchitlegalai
e0a1918cf2 test(publish): Show publishing existing version 2024-09-06 13:24:29 -05:00
Daniel Paoliello
8de55540f0 Implement path-bases (RFC 3529) 2/n: cargo add support
RFC: https://github.com/rust-lang/rfcs/pull/3529
Tracking Issue: https://github.com/rust-lang/cargo/issues/14355

This PR adds the `--base` option to `cargo add` to allow adding a path dependency with a path base.
2024-09-06 10:01:49 -07:00
Ed Page
f8467c641c fix(new): Add to workspace relative to manifest, not current-dir
We were correctly doing this for cases like `cargo new foo` or
`cargo new deeper/than/this/directory/foo` but not `cargo new ../foo`.

This came up when discussing #14501
2024-09-06 09:45:19 -05:00
Ed Page
c015a0061a test(new): Verify ../path behavior with workspaces 2024-09-06 09:30:53 -05:00