Commit graph

3623 commits

Author SHA1 Message Date
bors 71de58d5cf Auto merge of #12799 - marchiore:warn_add_package_name, r=epage
feat: add package name and version to warning messages

### What does this PR try to resolve?

Hi, this PR Fixes #8018, where i add the package name and version on warning messages.
As this is my first contribution to the project, if anything is not in compliance in the PR let me know and I will be happy to correct it.
2023-10-11 19:59:57 +00:00
Matheus Z Marchiore 380719da35 feat: add package name and version to warning messages 2023-10-11 16:52:30 -03:00
bors 90fb62fc65 Auto merge of #12796 - dtolnay-contrib:switching, r=epage
Do not call it "Downgrading" when difference is only build metadata

### What does this PR try to resolve?

When a `cargo update --precise` changes a dependency between 2 versions which differ only in build metadata, Cargo prints a log referring to it as "Updating" or "Downgrading" the dependency, depending on a comparison between the build metadatas.

This is usually not meaningful, given that build metadata is often stuff like git commit hashes, which are not meaningfully ordered.

```console
    Updating crates.io index
 Downgrading foo v0.0.1+43ef4fe -> v0.0.1+2c65d16
    Updating bar v0.0.2+bc17664 -> v0.0.2+c144a98
```

~~This PR changes to the word "Switching" when the version major, minor, patch, and pre-release value are not being changed.~~
This PR uses the word "Updating" when the version major, minor, patch, and pre-release value are unchanged, regardless of whether the build metadata is going up or down.

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

- `cargo test`
- `cargo build --release`
- `/path/to/cargo/target/release/cargo add tonic_datastore_v1`
- `/path/to/cargo/target/release/cargo update -p tonic_datastore_v1 --precise 0.1.0+3562b6cb3`
- `/path/to/cargo/target/release/cargo update -p tonic_datastore_v1 --precise 0.1.0+ee9e8e4e6`

Before:
<img src="https://github.com/rust-lang/cargo/assets/1940490/93e377e7-928e-4cec-aff6-451166ef7c81" width="500">

~~After:~~
<img src="https://github.com/rust-lang/cargo/assets/1940490/bb71459e-469a-4e09-bb8a-4083f34bce79" width="500">

After:
<img src="https://github.com/rust-lang/cargo/assets/1940490/8804e2fe-d0de-4c9e-b463-a5742daf9446" width="500">
2023-10-11 14:21:44 +00:00
hi-rustin b514ca5e24 Add unsupported short flag suggestion for --exclude flag
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-10-11 09:41:05 +08:00
hi-rustin 718b69ce19 Add test for unsupported short exclude flag
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-10-11 09:39:13 +08:00
hi-rustin 819a836e9a Add unsupported short flag suggestion for --target flag
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-10-11 09:16:26 +08:00
hi-rustin 2f90430110 Add test for unsupported short target triple flag
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-10-11 09:13:55 +08:00
Weihang Lo a263a7dc31
test(build): generalize test assertion for non-rustup env 2023-10-10 17:52:46 -04:00
bors 8ba1c316ee Auto merge of #12798 - epage:msrv-install, r=ehuss
fix(install): Suggest an alternative version on MSRV failure

### What does this PR try to resolve?

Moves users from a bad error message, suggesting `--locked` which won't do anything, to suggesting a version of a package to use instead.

The side benefit is errors get reported sooner
- Before downloading the `.crate`
- When installing multiple packages, before building the first

This comes at the cost of an extra `rustc` invocation.

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

Per-commit this builds it up, from tests to the final design.

### Additional information

This is also written in a way to align fairly well with how we'd likely implement #10903.
This improved error message will still be useful after that issue is resolved when the MSRV compatible version is outside of the version req.
2023-10-10 20:03:41 +00:00
Michael Howell f0d3cdf191 rustdoc: remove the word "Version" from test cases
Needed for https://github.com/rust-lang/rust/pull/115948 to merge.
2023-10-10 11:19:57 -07:00
bors c97c906b79 Auto merge of #12788 - hi-rustin:rustin-patch-short-Z, r=epage
Add unsupported lowercase `-z` flag suggestion for `-Z` flag
2023-10-10 01:33:31 +00:00
Ed Page 9b32be7f89 fix(install): Suggest an alternative version on MSRV failure
The next step would be to also automatically install an MSRV compatible
version if compatible with the version req (#10903).
This improved error message will still be useful if the MSRV compatible
version is outside of the version req.

I did this as the first step
- Helps people now, not needing to wait on `-Zmsrv-policy` to be stabilized
- Has fewer questions on how it should be done (or if it should be)
2023-10-09 20:22:54 -05:00
Ed Page 2976e2ac66 fix(install): Don't suggest --locked for MSRV when its root package
This will also report the error without having to download the `.crate`
first.

If installing multiple packages, this will also report it immediately,
rather than waiting for the other packages to be installed first.

This also offers us more flexibility in the error we report,
like suggesting more appropriate fixes.
2023-10-09 16:31:30 -05:00
David Tolnay 985e1eeef5
Do not call it "Downgrading" when difference is only build metadata 2023-10-09 13:53:47 -07:00
Ed Page 699b30a5f4 test(install): Verify existing top-level MSRV behavior 2023-10-09 15:48:53 -05:00
David Tolnay 4d1bf29a2c
Add test of update with version that differ only in build metadata 2023-10-09 10:36:46 -07:00
Eric Huss fd6185193a Rewrite the cache locker to use functions instead of macros. 2023-10-08 14:16:51 -07:00
Eric Huss b4982adfd9 Add a new package cache locking system.
This introduces a new `CacheLocker` which manages locks on the package
cache. Instead of either being "locked" or "not locked", the new locker
supports multiple modes:

- Shared lock: Cargo can read from the package sources, along with any
  other cargos reading at the same time.
- Download exclusive lock: Only one cargo can perform downloads.
  Download locks do not interfere with Shared locks, since it is
  expected that downloading does not modify existing files (only adds
  new ones).
- Mutate exclusive lock: Only one cargo can have this lock, and it also
  prevents shared locks. This is so that the cargo can modify the
  package cache (such as deleting files) without breaking concurrent
  processes.
2023-10-08 14:16:51 -07:00
Eric Huss b37c8f35c0 Add ConfigBuilder::root
This adds the `root` method to set the root directory to be able to
override paths::root().
2023-10-08 14:16:51 -07:00
hi-rustin f9719dcf4e add unsupported lowercase flag suggestion for -Z flag
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-10-08 08:36:49 +08:00
hi-rustin 0108d5b0dc Add test for unsupported short unstable feature flag
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-10-08 08:36:09 +08:00
bors fc790e7b2d Auto merge of #12781 - dvdhrm:pr/target-typo, r=epage
cargo/targets: fix error-message typo

Fix typo: "with with" -> "with"
2023-10-06 13:59:27 +00:00
David Rheinsberg 4aa1a95714 cargo/targets: fix error-message typo
Fix typo: "with with" -> "with"
2023-10-06 15:08:48 +02:00
hi-rustin 2400e42652 add unsupported short suggestion for --config flag
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-10-06 16:27:31 +08:00
hi-rustin 914119940b Add test for unsupported short config flag 2023-10-06 16:16:35 +08:00
Scott Schafer b2b3cfa524
feat: Add Edition2024 2023-10-04 13:11:52 -06:00
hi-rustin 7bd0f81257 Add unsupported short suggestion for --out-dir flag 2023-10-04 13:15:09 +08:00
hi-rustin f67b58f93f Add test for unsupported short out dir flag 2023-10-04 12:41:19 +08:00
bors 9a94183771 Auto merge of #12744 - tompscanlan:atomic-write, r=epage
fix bug: corruption when cargo killed while writing

### What does this PR try to resolve?

fix  #11386, superseding #12362

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

Added unit test showing basic equivalency to existing `write(path, content)`. Full test suite should exercise write.
Added tests for cargo add and remove. These are timing tests, so take a bit of time to run. 5-10s each.  They may not fail every time, but do so regularly.  Making the change to these two writes seems to prevent me from failing these tests at all.

### Additional information

This uses tempfile::persist which was an existing dependency. atomicwrites crate, an alternative option for this fix, indicates `tempfile::persist` is the same thing.  Since we already use tempfile as a dep, I stuck with that.
2023-10-02 13:34:00 +00:00
bors 1f94bf2db8 Auto merge of #12763 - ehuss:custom_bin_target-windows-gnu, r=weihanglo
Disable custom_target::custom_bin_target on windows-gnu

The `custom_target::custom_bin_target` test has been crashing frequently in CI on the x86_64-pc-windows-gnu target since the last LLVM 17 update. This disables the test to reduce the disruption in CI. The issue is being tracked in https://github.com/rust-lang/rust/issues/115985.
2023-10-02 04:12:23 +00:00
Eric Huss 704a5d32b5 Disable custom_target::custom_bin_target on windows-gnu 2023-10-01 19:14:46 -07:00
Tom Scanlan aee8c75410
bug: corruption when killed while writing 2023-10-01 08:29:24 -04:00
bors e3acdd321f Auto merge of #12723 - hi-rustin:rustin-patch-silent, r=weihanglo
Add better suggestion for the unsupported silent flag
2023-09-28 07:06:25 +00:00
hi-rustin 44d955b15d Fix test on windows 2023-09-28 10:10:19 +08:00
hi-rustin 5d8009a189 Better suggestion for unsupported silent flag 2023-09-28 09:25:17 +08:00
bors 25dc3bdc5d Auto merge of #12681 - epage:frontmatter, r=Muscraft
feat(embedded): Hack in code fence support

### What does this PR try to resolve?

This is to allow us to get feedback on the design proposed
[on zulip](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Embedding.20cargo.20manifests.20in.20rust.20source/near/391427092)
to verify we want to make an RFC for this syntax.

````rust
#!/usr/bin/env cargo
```cargo
[dependencies]
clap = { version = "4.2", features = ["derive"] }
```

use clap::Parser;

#[derive(Parser, Debug)]
#[clap(version)]
struct Args {
    #[clap(short, long, help = "Path to config")]
    config: Option<std::path::PathBuf>,
}

fn main() {
    let args = Args::parse();
    println!("{:?}", args);
}
````

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

The tests were updated in a separate commit to ensure there was no regression while then migrating to the new syntax to make sure it worked.

This involves some future work
- Removing doc comment support
- Getting the syntax approved and implemented
- Migrating to rustc support for the syntax

#12207 was updated to record these items so we don't lose track of them
2023-09-26 15:35:38 +00:00
bors 0b6cc3c75f Auto merge of #12732 - tompscanlan:12576-registry-error-msg, r=epage
more specific registry index not found msg

### What does this PR try to resolve?

covers #12576

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

test covers exact text, so a review and passing tests.
2023-09-25 17:41:03 +00:00
Tom Scanlan 3393fdc528
more specific registry index not found msg 2023-09-24 15:43:18 -04:00
Eric Huss ebea09d8f4 Fix spurious errors with networking tests. 2023-09-22 13:37:26 -07:00
hi-rustin 61648f583e Add test for unsupported silent flag 2023-09-22 10:50:23 +08:00
Weihang Lo a30d9fde98
test: verify source replacement displays registry key 2023-09-21 12:53:24 +08:00
bors 5bf83d8146 Auto merge of #12693 - hi-rustin:rustin-patch-unsupported-flags, r=epage
Better suggestion for unsupported mode in build command
2023-09-21 02:40:07 +00:00
hi-rustin 97656fbf87 Correct the helper name and the tip message 2023-09-21 10:12:03 +08:00
hi-rustin 817c2cbbb5 Better suggestion for unsupported mode in install command 2023-09-20 11:31:36 +08:00
hi-rustin 7644a4bd96 Add test for using unsupported mode in install command 2023-09-20 11:27:56 +08:00
hi-rustin ed86337492 Better suggestion for unsupported mode in build command 2023-09-20 11:24:44 +08:00
hi-rustin f262297e9a Add test for using unsupported mode in build command 2023-09-20 11:23:01 +08:00
Eric Huss c2047345bd Don't display paths with cargo clean --dry-run without --verbose
The paths themselves aren't particularly interesting.
2023-09-19 18:24:45 -07:00
Eric Huss f61d42d5ef Add a warning to cargo clean --dry-run
This makes it more consistent with other `--dry-run` commands, and
makes it clearer to the user that cargo did not do anything.
2023-09-19 18:24:45 -07:00
Eric Huss ebee726d8f Separately track files and directories removed.
The previous status line was a little awkward in the way it combined
both counts. I don't think showing the directories is particularly
interesting, so they are only displayed when no files are deleted.
2023-09-19 18:24:37 -07:00