Commit Graph

15493 Commits

Author SHA1 Message Date
Ed Page 293f2250d6 feat(doc): Print the generated docs links
I've wanted something like this myself.  I dislike using `--open`
because I tend to move up to re-run my `cargo doc` run but then have to
edit it to remove `--open`.
Also makes it annoying when opening docs when `cargo doc` is wrapped by
a tool like `make`.

This was previously attempted in #5592:
- Unlike the request in #5562, this aligns with #5592 in always printing
  rather than using a flag as this seems generally useful
- Unlike #5592, this prints as an alternative to "Opening" to keep
  things light
- Unlike #5592, this prints afterwards as the link is only valid then

Fixes #5562
2023-10-19 10:51:56 -05:00
bors c26943919a Auto merge of #12837 - epage:remove, r=weihanglo
fix(remove): Preserve feature comments

### What does this PR try to resolve?

We've been having a hard time balancing leaving the feature list in a good looking start and preserving formatting.  With our new formatting policy (#12836), we can just choose to preserve formatting instead.

Fixes #11743

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

The first commit copies an existing test.  The second is where the fun begins, customizing the test for some weird cases.  The follow up commits do the slow walk for improving it.

We ended up preserving some line-trailing comments because they come after the comma and toml_edit treats that as part of the prefix of the next item.  Tracking removal of that was going to require us to determine if the newline existed in the suffix or in the next item's prefix and edit accordingly and I decided to skip that to keep this initial implementation simpler.

### Additional information
2023-10-19 15:36:20 +00:00
bors 220767c14b Auto merge of #12844 - shuoer86:master, r=weihanglo
docs: fix typo
2023-10-19 14:37:42 +00:00
Ed Page 51aeeb01ff fix(cli): Provide next steps for bad -Z flag
In #5546, they suggested we have a list of them but that would be hard
to keep up and works well enough to just always mention it.

Fixes #5546
2023-10-19 09:29:05 -05:00
bors a918b596b4 Auto merge of #12856 - weihanglo:triagebot, r=epage
chore(triagebot): auto label when PR review state changes
2023-10-19 13:46:15 +00:00
Weihang Lo 4830653705
chore(triagebot): auto label when PR review state changes 2023-10-19 09:43:07 -04:00
shuoer86 6c2579184a
docs: fix typos 2023-10-19 21:13:07 +08:00
bors 680a0f9d24 Auto merge of #12838 - epage:add, r=weihanglo
fix(add): Preserve more comments

### What does this PR try to resolve?

This was fixed in killercup/cargo-edit#725 and I forgot to carry it over to here.

I kept in some auto-formatting because there is little to preserve until the TOML 1.1 spec is out which will allow mult-line inline-tables which means there might be comments interspersed.  We'll see which comes first, `cargo fmt` support for `Cargo.toml` or the 1.1 spec.

Fixes #10850

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

First commit adds a test demonstrating the problem.  The second makes a lot of noise that the third cleans up, so its a mixed bag as to which commit to look at.

### Additional information
2023-10-19 02:31:46 +00:00
bors 5225467af0 Auto merge of #12853 - weihanglo:cname-warning, r=ehuss
ci: big ⚠️ to ensure the CNAME file is always there

### What does this PR try to resolve?

A request from <https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/doc.2Ecrates.2Eio.20CNAME.20missing>

The CNAME file is for GitHub to redirect requests to the custom domain.
Missing this may entail security hazard and domain takeover.
See <https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/managing-a-custom-domain-for-your-github-pages-site#securing-your-custom-domain>
2023-10-19 01:40:25 +00:00
Weihang Lo ec9c5b0b43
ci: big ⚠️ to ensure the CNAME file is always there 2023-10-18 21:31:10 -04:00
bors 5fab767241 Auto merge of #12850 - weihanglo:dashdashbench, r=epage
docs(cargo-bench): `--bench` is passed in unconditionally to bench harnesses
2023-10-18 21:25:14 +00:00
dependabot[bot] 8e157bbab8
chore(deps): bump rustix from 0.38.18 to 0.38.19
Bumps [rustix](https://github.com/bytecodealliance/rustix) from 0.38.18 to 0.38.19.
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.18...v0.38.19)

---
updated-dependencies:
- dependency-name: rustix
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-18 20:42:30 +00:00
bors 0820fa1933 Auto merge of #12846 - rust-lang:revert-12834-pr/contrib, r=epage
docs(contrib): generate redirection HTML pages in CI

### What does this PR try to resolve?

#12834 wiped out the old content of all link redirections. From my understanding it relies on the existing gh-pages hosting those files.

This PR pulls out the [`generate.py`](cff4125983/generate.py) from older `gh-pages` branch, and run it during the CI deploy job.

### How to review

It succeeds on my fork <https://github.com/weihanglo/cargo/tree/gh-pages> ([CI log](https://github.com/weihanglo/cargo/actions/runs/6564128361/job/17829881499#step:4:1)).

I don't think `.lock` or [`.nojekyll`](https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/) is needed. If it causes problem, we can add them back.
2023-10-18 19:44:34 +00:00
Weihang Lo ff376df716
docs(cargo-bench): `--bench` is passed in unconditionally to bench harnesses 2023-10-18 15:40:12 -04:00
bors 9b994157b3 Auto merge of #12842 - weihanglo:remove-notice, r=epage
docs: remove review capacity notice

The Cargo project is in a better state than it was when maintainers added this notice. I believe it's time to take it down, as maintainers have got more time on it, and more people are willing to contribute to the project constantly.

Note that this doesn't mean Cargo start accepting arbitrary pull requests or features. The reviewers are still a small handful of people. The guideline never change — issue, discuss, then pull request.
2023-10-18 18:41:08 +00:00
bors 141667875e Auto merge of #12841 - epage:help, r=weihanglo
fix(help):Clarify install's positional

### What does this PR try to resolve?

- That a version is accepted
- That you are selecting from the source a package which led to part of
  the confusion in #4830

I wonder if we should rename our `CRATE` value names to `PKG`/`PACKAGE`

While doing this, I decided to fix the inconsistency in how we handle value names in help.

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

### Additional information
2023-10-18 17:45:08 +00:00
Weihang Lo 6f3e30b773
docs: remove review capacity notice 2023-10-18 13:24:09 -04:00
Weihang Lo 4f0016d457
ci: generate link redirections when publising contrib doc 2023-10-18 12:59:06 -04:00
bors 16629e6a5a Auto merge of #12845 - Urgau:check-cfg-adjust-for-rustc, r=epage
Adjust `-Zcheck-cfg` for new rustc syntax and behavior

https://github.com/rust-lang/rust/pull/111072 introduced a new syntax for `rustc` `--check-cfg` argument. This PR adjust cargo `-Zcheck-cfg` for new that new syntax and behavior.

This PR removes all the `-Zcheck-cfg` options (`features`, `names`, `values`, `output`), as they don't make much sense now since with the new `rustc` behavior: `features`, `names` and `values` are all combine together and the `output` option was only here because the other were.

Now the new behavior from cargo is to always pass one `--check-cfg` argument to rustc for the `feature`s which implicitly enables well known names and values.
2023-10-18 16:29:03 +00:00
Urgau 2f79f15018 Update Cargo reference for new -Zcheck-cfg behavior and syntax 2023-10-18 18:11:54 +02:00
Weihang Lo 208922f1fc
ci: pull out generate.py from gh-pages branch 2023-10-18 12:08:28 -04:00
bors 67271fd7a9 Auto merge of #12806 - epage:replace, r=Eh2406
fix(replace): Partial-version spec support

### What does this PR try to resolve?

#12614 changed package ID specs to allow fields in the version number to be optional.  This earliest branch with this change is `rust-1.74.0` (beta).  While `@Eh2406` was investigating version metadata issues in #12772, problems with the partial version change were found
- `replace`s that specify version metadata were ignored **(fixed with this PR)**
  - This also extends out to any other place a PackageIDSpec may show up, like `cargo check -p <name>`@<spec>``
  - We explicitly kept the same semantics of version requirements that pre-releases require opt-in.  If nothing else, this gives us more room to change semantics in the future if we ever fix the semantics for pre-release.
- `replace`s that don't specify version metadata when the `Cargo.lock` contained a version metadata, it would previously be ignored (with a warning) but now match **(unchanged with this PR)**
  - When the version metadata in `Cargo.lock` differed from the overriding `Cargo.toml`, cargo would panic **(now an error in this PR)**

With this PR, we are acknowledging that we changed behavior in taking ignored replaces (because of differences with version metadata) and applying them.  Seeing as version metadata is relatively rare, replaces are relatively rare, and differences in it for registries is unsupported, the impact seems very small.

The questions before us are
- Do we revert #12614 in `master` and `rust-1.74.0` or merge this PR into `master`
- If we merge this PR into `master`, do we cherry-pick this into `rust-1.74.0` or revert #12614, giving ourselves more time to find problems

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

The initial commit adds tests that pass as of #12614.  Prior to #12614, these tests would have warned that the `replace` was unused and failed because `bar::bar` didn't exist.  Each commit then changes the behavior (or not) and updates the corresponding test.

### Additional information
2023-10-18 15:42:23 +00:00
Urgau 4b93690c9d Adjust -Zcheck-cfg for new rustc syntax and behavior
This commit removes all the -Zcheck-cfg options (features, names,
values, output), as they don't make much sense now since features, names
and values are all combine together for upstream rustc and the output
option was only here because the other were.

Now the new behavior from cargo is to always pass one `--check-cfg`
argument to rustc for the `feature`s which implicitly enables well known
names and values.
2023-10-18 15:10:25 +02:00
bors a275529de2 Auto merge of #12829 - Nilstrieb:verbosebuildrs, r=weihanglo
Print environment variables for build script executions with `-vv`

### What does this PR try to resolve?

When debugging complicated builds (I was trying to figure out how  `cargo-miri` cross-compiles compiler_builtins without needing a C cross compiler), it's useful to see all the environment variables passed to the build script.

This is also consistent with other commands.

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

I tested it locally by creating a small crate with an empty `build.rs` and building it. Additionally, a test is included.
2023-10-18 02:52:14 +00:00
bors 709ac17f62 Auto merge of #12840 - epage:suggest, r=hi-rustin
fix(cli): Suggest cargo-search on bad commands

This is a low-tech solution alternative to the options proposed in #4682
- Search `[[bin]]`s within all packages in the registry (which aren't tracked atm), suggesting to `cargo install` what is found
- Check if `cargo-<cmd>` is in the registry, suggesting `cargo install if it is

By suggesting `cargo search`, we are giving them a tool so they can verify if the package is what they want (a `cargo info` would help as a next step).

Is is needed?
- New users might not know of `cargo search` but they can search on crates.io
- New users might not be aware of the `cargo-<cmd>` naming pattern

Seems like this can still offer some benefit.

Fixes #4682
2023-10-18 01:51:13 +00:00
Ed Page 5f0596941f fix(help): Clarify install's positional
- That a version is accepted
- That you are selecting from the source a package which led to part of
  the confusion in #4830

I wonder if we should rename our `CRATE` value names to `PKG`/`PACKAGE`
2023-10-17 16:48:15 -05:00
Ed Page 99f917a67e fix(help): Consistently use SCREAMING_CASE for value names
- We have some positional value names that are SCREAMING_CASE and some
  that aren't
- All of the value names for our flags are already SCREAMING_CASE
2023-10-17 16:47:44 -05:00
bors 4cf7937fd5 Auto merge of #12836 - epage:fmt, r=weihanglo
docs(contrib): Policy on manifest editing

Based on https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Automatic.20edits.20to.20.60Cargo.2Ctoml.60
2023-10-17 20:03:08 +00:00
Ed Page ec3ed20d2a fix(cli): Suggest cargo-search on bad commands
This is a low-tech solution alternative to the options proposed in #4682
- Search `[[bin]]`s within all packages in the registry (which aren't
  tracked atm), suggesting to `cargo install` what is found
- Check if `cargo-<cmd>` is in the registry, suggesting `cargo install
  if it is

By suggesting `cargo search`, we are giving them a tool so they can
verify if the package is what they want (a `cargo info` would help as a
next step).

Is is needed?
- New users might not know of `cargo search` but they can search on
  crates.io
- New users might not be aware of the `cargo-<cmd>` naming pattern

Seems like this can still offer some benefit

Fixes #4682
2023-10-17 14:46:30 -05:00
bors f806be2dde Auto merge of #12835 - dvdhrm:pr/contrib-concurrency, r=weihanglo
ci/contrib: use separate concurrency group

Run the contrib workflow in its own concurrency group to avoid multiple runs causing conflicting git pushes.

The contrib workflow pushes to the gh-pages branch, and thus is not safe to be run multiple times in parallel. Given that github-actions can stall workflow runs for quite some time, multiple executions can overtake each other. By using concurrency groups, all workflow runs will wait until previous runs completed.

Given that the workflow uses orphan-branches and forced pushes, conflicting workflows will not fail, but might produce outdated data if they overtake each other.

We explicitly disable cancellation to get better diagnostics and more easily find the first possible run that failed. Since these workflow runs are rather fast, and only run on master, cancellation seems not necessary.
2023-10-17 19:04:23 +00:00
Ed Page 02dd917511 fix(add): Add back in some auto-formatting
This moves the auto-format to the correct place so it takes effect.
2023-10-17 12:48:45 -05:00
Ed Page 99e4847d78 fix(add): Stop auto-formatting content
Huh, overlooked the cargo side when I fixed this in killercup/cargo-edit#725

Fixes #10850
2023-10-17 12:48:08 -05:00
Ed Page 716ae6238f test(add): Check table formatting issues 2023-10-17 12:23:45 -05:00
Ed Page 6281109e5b fix(remove): Carry comments across removes 2023-10-17 11:56:54 -05:00
Ed Page c259063961 refactor(remove): Pull out array removal code 2023-10-17 11:51:46 -05:00
Ed Page 5374e8aa70 fix(remove): Leave formatting to the user
Fixes #11743
2023-10-17 11:51:45 -05:00
Ed Page b17a73df1d test(remove): Extend the formatting tested 2023-10-17 11:49:26 -05:00
Ed Page 253a944aca test(remove): Add a more extensive formatting test 2023-10-17 10:49:33 -05:00
Ed Page b5c63f6868 docs(contrib): Policy on manifest editing
Based on https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Automatic.20edits.20to.20.60Cargo.2Ctoml.60
2023-10-17 10:29:18 -05:00
Ed Page 1e34066360 test(replace): Clarify name for remaining new test 2023-10-17 10:09:45 -05:00
Ed Page 7502318a85 fix(replace): Error, rather than assert, on version mismatch 2023-10-17 10:09:45 -05:00
Ed Page d318ed4c14 fix(spec): Require opt-in for pre-release 2023-10-17 10:09:45 -05:00
Ed Page 0ec3274326 fix(spec): Ensure PackageIdSpec respects version 'build' field 2023-10-17 10:09:41 -05:00
bors 8537dffa1e Auto merge of #12834 - dvdhrm:pr/contrib, r=weihanglo
ci/contrib: do not fail on missing gh-pages

The current contrib deploy-hook fails if there is no `gh-pages` branch. Change the CI order to disregard the old `gh-pages` branch first.

The `contrib` deploy-hook always creates a fresh `gh-pages` commit and pushes it out. However, currently it relies on the old `gh-pages` branch to exist, since it does not ignore errors when pruning it. Fortunately, the code always creates a new orphan branch, since it does not want to keep history for deployments. Therefore, we can simply use:

    `git worktree --orphan -B <branch> <path>`

This will ensure to always create an orphan branch named `<branch>`, and override an existing branch if it exists (see `-b` vs `-B`). Hence, there is no need for us to prune the old branch, anymore.

Since we will recreate the branch on every push, we have to explicitly specify the remote to push to. We no longer set up branch tracking.

Note that running github-actions in a private fork is quite useful to avoid constantly pushing changes to a PR and triggering notifications. Unfortunately, private forks on github do not automatically clone the gh-pages branch. This PR fixes annoying CI failures when updating the master branch on private forks, since github does not automatically clone the gh-pages branch.
2023-10-17 14:25:13 +00:00
David Rheinsberg cdc7c1be02 ci/contrib: use separate concurrency group
Run the contrib workflow in its own concurrency group to avoid multiple
runs causing conflicting git pushes.

The contrib workflow pushes to the gh-pages branch, and thus is not safe
to be run multiple times in parallel. Given that github-actions can
stall workflow runs for quite some time, multiple executions can
overtake each other. By using concurrency groups, all workflow runs will
wait until previous runs completed.

We explicitly disable cancellation to get better diagnostics and more
easily find the first possible run that failed. Since these workflow
runs are rather fast, and only run on master, cancellation seems not
necessary.
2023-10-17 16:02:03 +02:00
bors ff768b45b3 Auto merge of #12823 - calavera:fix_remove_help_typos, r=weihanglo
Clarify flag behavior in `cargo remove --help`

### What does this PR try to resolve?

I noticed what I believe are typos in `cargo rm --help`:

```
Section:
      --dev              Remove as development dependency
      --build            Remove as build dependency
      --target <TARGET>  Remove as dependency from the given target platform
```

This change updates that section with a more appropriate description of those flags.

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

I've updated the relevant test for that help output.

### Additional information

Sorry for not opening an issue about this. I believe it's easy enough to approve it if my assumption is correct.
2023-10-17 12:51:31 +00:00
David Rheinsberg 1d261830a0 ci/contrib: do not fail on missing gh-pages
The current contrib deploy-hook fails if there is no `gh-pages` branch.
Change the CI order to disregard the old `gh-pages` branch first.

The `contrib` deploy-hook always creates a fresh `gh-pages` commit and
pushes it out. However, currently it relies on the old `gh-pages` branch
to exist, since it does not ignore errors when pruning it. Fortunately,
the code always creates a new orphan branch, since it does not want to
keep history for deployments. Therefore, we can simply use:

    `git worktree --orphan -B <branch> <path>`

This will ensure to always create an orphan branch named `<branch>`, and
override an existing branch if it exists (see `-b` vs `-B`). Hence,
there is no need for us to prune the old branch, anymore.

Since we will recreate the branch on every push, we have to explicitly
specify the remote to push to. We no longer set up branch tracking.
2023-10-17 14:28:23 +02:00
bors 8eb8acbb11 Auto merge of #12832 - weihanglo:cargo-login, r=ehuss
doc(cargo-login): mention args after `--` in manpage
2023-10-17 11:55:04 +00:00
David Calavera 8849d25218 Update rm help to be specific about the section.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2023-10-17 11:53:57 +02:00
Shankar Mathiah Nanjundan 901018c3db Fixes #2708
Warns about not using snake_case or kebab-case format when creating new packages with `cargo new` command.
2023-10-16 23:39:19 -07:00