Commit graph

13546 commits

Author SHA1 Message Date
bors 2f84e1a45c Auto merge of #11722 - Muscraft:add-clippy-lints, r=epage
Add clippy lints

It was discussed in a recent cargo team meeting that it would be okay to allow specific `clippy` lints to be `warn`/`deny` within cargo.

This PR adds a CI job that denies `clippy` warnings for cargo's `lib`. As well as sets [`clippy::self_named_module_files`](https://rust-lang.github.io/rust-clippy/master/index.html#self_named_module_files) to be a warning.

[`clippy::self_named_module_files`](https://rust-lang.github.io/rust-clippy/master/index.html#self_named_module_files): "Checks that module layout uses only `mod.rs` files". This allows cargo's structure to be consistent and enforced across the board.
2023-02-15 21:25:01 +00:00
Scott Schafer d7d27cd74c chore: Warn on clippy::self_named_module_files 2023-02-15 12:14:22 -06:00
Scott Schafer bf52c09991 ci: Add a job to deny clippy warnings 2023-02-15 12:13:21 -06:00
bors 25b8771541 Auto merge of #11719 - Muscraft:order-toml-deps, r=weihanglo
chore: Make dependencies alphabetical order

`[dependencies]` in some `Cargo.toml` were out of alphabetical order. This made it slightly more time-consuming to find if a dependency was in a `Cargo.toml`.

This PR makes it so that they are in alphabetical order.

Note: `rustc-workspace-hack` was left alone at the bottom as it is a special dependency.
2023-02-15 16:49:13 +00:00
Scott Schafer c3043d9a9e chore: Make dependencies alphabetical order 2023-02-15 09:22:08 -06:00
bors 2555e1c898 Auto merge of #11716 - weihanglo:bump-mdbook, r=Muscraft
chore: bump mdbook to 0.4.27

Previously mdbook was bumped in #11646 for contrib.yml worflow
but main.yaml workflow. This makes the two in sync and also
upgrades to the latest 0.4.27. (Though there is nothing really
changed for application users as us)
2023-02-15 14:44:09 +00:00
Weihang Lo 3e1f60fcb0
chore: bump mdbook to 0.4.27
Previously mdbook was bumped in #11646 for contrib.yml worflow
but main.yaml workflow. This makes the two in sync and also
upgrades to the latest 0.4.27. (Though there is nothing really
changed for application users as us)
2023-02-15 11:37:35 +00:00
bors a59ac81db4 Auto merge of #11715 - Enyium:amend-mdman-tests, r=weihanglo
Amend `mdman` tests.

- Revert most of changes to expected test output from commit 2a4ec9f2.
- Keep later changes to expected test output from commit 0263ef43.
- Change test input that's converted to trigger similar output as previously.

Following [this](https://github.com/rust-lang/cargo/pull/11646#discussion_r1105895081) comment from `@ehuss.`
2023-02-15 11:22:09 +00:00
Enyium 36d3a5e467 Amend mdman tests.
- Revert most of changes to expected test output from commit 2a4ec9f2.
- Keep later changes to expected test output from commit 0263ef43.
- Change test input that's converted to trigger similar output as previously.
2023-02-15 12:07:53 +01:00
bors bd8c8e789a Auto merge of #11712 - ehuss:ci-macos-nightly, r=weihanglo
Run CI for macOS on nightly

This adds coverage for macOS on nightly. Since Cargo is very platform-dependent, I think it would be good to have full coverage on most tier-1 platforms. This includes a small fix for a test that recently started failing on nightly.
2023-02-14 21:53:52 +00:00
Eric Huss fe8dd1b00c Run CI for macOS on nightly 2023-02-14 12:26:01 -08:00
bors fb00cbe723 Auto merge of #11711 - weihanglo:more-doc, r=epage
doc: doc comments and intra-doc links for `core::compiler`
2023-02-14 17:16:38 +00:00
Weihang Lo 63d97e5ba9
doc: enhancement of future_incompat 2023-02-14 17:05:05 +00:00
Weihang Lo 825b480f67
doc: enhancements of mods under compiler 2023-02-14 17:05:05 +00:00
Weihang Lo d2218246d7
doc: enhancment of core::compiler mod 2023-02-14 16:52:16 +00:00
Weihang Lo 4c507b45c3
doc: enhancement of compiler::links 2023-02-14 16:52:16 +00:00
bors 426263643a Auto merge of #11646 - Enyium:patch-1, r=weihanglo
Ensure em dashes are recognizable in markup

An em dash (—) isn't well-recognizable in a monospace font. There were already a couple of locations where a hyphen was used instead. These were also corrected to `—`. `—` should reduce the probability of a hyphen being used for new entries.
2023-02-14 10:13:40 +00:00
Enyium b1754b2aa2 Regenerate derived doc formats. 2023-02-14 08:24:20 +01:00
Enyium bed7dfb5fa Ensure em dashes are recognizable in markup.
Also correct some hyphens to em dashes.
2023-02-14 08:19:52 +01:00
Enyium 0263ef4379 Enable smart punctuation in mdBook. 2023-02-14 08:15:29 +01:00
Enyium 2a4ec9f2f1 Update pulldown-cmark to next breaking version. 2023-02-14 08:15:29 +01:00
Enyium 02d7942c54 Fix typos. 2023-02-14 08:15:29 +01:00
bors f0a4ee0fc6 Auto merge of #11705 - t-rapp:env-cargo-bin-name, r=epage
Set CARGO_BIN_NAME environment variable also for binary examples

### What does this PR try to resolve?

The existing CARGO_BIN_NAME environment variable is useful when building command-line programs. It lets the command know its binary name, e.g. for printing out simple usage instructions. This PR extends the CARGO_BIN_NAME environment variable to be set when building binary example targets, additional to "normal" binary targets.

Fixes #11689.

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

Create a new binary project with `cargo new hello-env`. Add a new file "examples/foo-bar.rs" with the following lines:

```
fn main() {
    let program = env!("CARGO_BIN_NAME");
    println!("{program}");
}
```

Building and running the example with `cargo run --example foo-bar` should print a line with the string "foo-bar".

Note that this PR extends the existing testcase for the CARGO_BIN_NAME environment variable with an example target.
2023-02-13 15:14:10 +00:00
Tobias Rapp 0fda7acf48 Set CARGO_BIN_NAME environment variable also for binary examples
Extend the existing CARGO_BIN_NAME environment variable to be set when
building binary example targets, additional to "normal" binary targets.

Closes #11689.
2023-02-13 14:25:35 +01:00
bors 39c13e67a5 Auto merge of #11618 - epage:toml, r=ehuss
chore: Update to toml v0.6, toml_edit v0.18

`toml` replaces `toml_edit::easy`, using `toml_edit` as its parser.
2023-02-12 02:01:08 +00:00
bors 6c49ea91d2 Auto merge of #11703 - weihanglo:more-doc, r=epage
doc: more doc comments and intra-doc links
2023-02-12 00:39:41 +00:00
Weihang Lo 25f5267c61
refactor: remove unnecessary function 2023-02-12 00:17:57 +00:00
Weihang Lo b59e827dba
refactor: make local function invisible 2023-02-12 00:17:55 +00:00
Weihang Lo 392db56a08
doc: enhancement of -Zrustdoc-map 2023-02-12 00:17:36 +00:00
Weihang Lo 2fa38a215f
doc: enhancement of compiler::artifact 2023-02-12 00:17:36 +00:00
Weihang Lo 92f89728b8
doc: enhancement of util::queue 2023-02-12 00:17:36 +00:00
Weihang Lo 7b92f0beff
doc: enhancement of compiler::job 2023-02-12 00:17:36 +00:00
Weihang Lo c08806d8f4
doc: enhancement of compiler::output_depinfo 2023-02-12 00:17:34 +00:00
bors 35e45fd2e4 Auto merge of #11699 - epage:warn, r=ehuss
Deny warnings in CI, not locally

### What does this PR try to resolve?

The problem with #![deny(warnings)] is it makes iteration more difficult as you might have intermediate states with warnings. Its slightly better that we defer this to cargo test --lib but that still means you can't run a subset of tests against your experiment until you've cleaned up all of your warnings. This can lead to users [working around the problem which could accidentally slip in](d92d04840c).

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

The first round for this PR includes a warning in the `cargo` crate to ensure it breaks CI.  It will then be reverted.

### Additional information

See also https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/.60.23!.5Bcfg_attr.28test.2C.20deny.28warnings.29.29.5D.60
2023-02-11 18:12:10 +00:00
bors 71138966da Auto merge of #11701 - Ethan-000:add_lto_comment, r=weihanglo
add comment to lto.rs
2023-02-11 14:31:53 +00:00
ethan-000 aefde60888 add comment to lto.rs
fix

change
2023-02-11 13:54:55 +00:00
bors b008a8dcca Auto merge of #11700 - cnpryer:export-new-project-kind, r=weihanglo
Re-export cargo_new::NewProjectKind as public

`NewProjectKind` needs to be exported since the module cargo_new is private. It's unreachable for use-cases interfacing with the library directly.

This is from the jonhoo stream. Apparently a maintainer is picking this up now, so feel free to close this out.
2023-02-11 00:36:07 +00:00
Chris Pryer 50f342a620
Re-export cargo_new::NewProjectKind as public 2023-02-10 19:13:22 -05:00
Ed Page d52f29897a chore: Deny warnings across entire cargo repo 2023-02-10 16:17:33 -06:00
Ed Page dca10d17db chore: Allow warnings during development 2023-02-10 15:58:06 -06:00
bors 74043673e6 Auto merge of #10952 - compenguy:cargo-change-dir-10098, r=epage
Add '-C' flag for changing current dir before build

This implements the suggestion in #10098 to make cargo change cwd before
completing config processing and starting the build. It is also an
alternative to `--manifest-path` that resolves the issue described
in #2930.

The behavior of this new flag makes cargo build function exactly the same when run at the root of the project as if run elsewhere outside of the project.  This is in contrast to `--manifest-path`, which, for example, results in a different series of directories being searched for `.cargo/config.toml` between the two cases.

Fixes #10098
Reduces impact of #2930 for many, possibly all impacted, by switching to this new cli argument.

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

The easiest way to reproduce the issue described in #2930 is to create an invalid `.cargo/config.toml` file in the root of a cargo project, for example `!` as the contents of the file.  Running cargo with the current working directory underneath the root of that project will quickly fail with an error, showing that the config file was processed.  This is correct and expected behavior.

Running the the same build with the current working directory set outside of the project, e.g. /tmp, and passing the `--manifest-path /path/to/project/Cargo.toml`.  The build will proceed without erroring as a result of reading the project's `.cargo/config.toml`, because config file searching is done from cwd (e.g. in `/tmp` and `/`) without including the project root, which is a surprising result in the context of the [cargo config documentation](https://doc.rust-lang.org/cargo/reference/config.html), which suggests that a `.cargo/config.toml` file checked into the root of a project's revision control will be processed during the build of that project.

Finally to demonstrate that this PR results in the expected behavior, run cargo similar to the previous run, from /tmp or similar, but instead of `--manifest-path /path/to/project/Cargo.toml`, pass `-C/path/to/project` to cargo (note the missing `Cargo.toml` at the end).  The build will provide the exact same (expected error) behavior as when running it within the project root directory.

### Additional information

~Passing a path with a trailing '/' will result in failure.  It is unclear whether this is a result of improper input sanitization, or whether the config.cwd value is being improperly handled on output.  In either case this needs to be resolved before this PR is merge-ready.~

(the above issue appears to have been a side effect of local corruption of my rustup toolchain, and unrelated to this change)

Because a `struct Config` gets created before command line arguments are processed, a config will exist with the actual cwd recorded, and it must then be replaced with the new value after command line arguments are processed but before anything tries to use the stored cwd value or any other value derived from it for anything.  This change effectively creates a difficult-to-document requirement during cargo initialization regarding the order of events.  For example, should a setting stored in a config file discovered via cwd+ancestors search be wanted before argument processing happens, this could result in unpleasant surprises in the exact use case this feature is being added to fix.

A long flag was deferred out to not block this on deciding what to name it.  A follow up issue will be created.
2023-02-10 20:41:41 +00:00
Will Page 6510cc5c4b Regenerated documentation with updated '-C' cargo option 2023-02-10 07:42:48 -08:00
Will Page 5406faf8fd Updating doc sources for new cargo option '-C' 2023-02-10 07:42:48 -08:00
Will Page 6dacf8ba17 revert #11080 and assert precondition for -C flag 2023-02-10 07:42:48 -08:00
Will Page 4de2c96021 Add '-C' flag for changing current dir before build
This implements the suggestion in #10098 to make cargo change cwd before
completing config processing and starting the build. It is also an
alternative to --manifest-path that resolves the issue described
in #2930.
2023-02-10 07:42:37 -08:00
bors a49049817d Auto merge of #11694 - weihanglo:issue-11623, r=epage
`-Zrustdoc-scrape-example` must fail with bad build script
2023-02-09 20:40:34 +00:00
Weihang Lo 0da332c66e
fix(docscrape): must fail with bad build script
When running `cargo doc -Zrustdoc-scrape-example`, it performs
additional type checks that a plain old `cargo doc` doesn't.
That leads to some extra failure when adopting scrape-example for docs.rs.

In de34d60 we introduced `unit_can_fail_for_docscraping` in order to
make `-Zrustdoc-scrape-example` not fail whenever `cargo doc` builds.
Build script executions were accidentally included in the list of
fallible units. A plain `cargo doc` does fail when a build script
fails. `-Zrustdoc-scrape-example` should follow that.
2023-02-09 20:32:24 +00:00
Weihang Lo a481387e7b
test(docscrape): must fail with bad build script 2023-02-09 20:14:18 +00:00
bors 389c03da99 Auto merge of #11690 - weihanglo:1.68-backport, r=ehuss
Update CHANGELOG for 1.68 backports
2023-02-09 14:36:28 +00:00
bors e54a0b5f11 Auto merge of #11692 - ehuss:update-1password, r=epage
Update 1password to the version 2 CLI

This updates the 1password credential manager integration to the version 2 `op` CLI. The new CLI changed the commands and output and behavior in various ways, documented at https://developer.1password.com/docs/cli/upgrade/.

If you have 1password, you can test this by building the `cargo-credential-1password` binary. I recommend enabling CLI integration in the app, but using the manual `op signin` process also works. Once signed in, you can test it with:

```sh
echo "this-is-my-token" | CARGO_REGISTRY_NAME_OPT=crates-io \
    CARGO_REGISTRY_INDEX_URL=https://github.com/rust-lang/crates.io-index
    ./target/debug/cargo-credential-1password store

CARGO_REGISTRY_INDEX_URL=https://github.com/rust-lang/crates.io-index
    ./target/debug/cargo-credential-1password get

CARGO_REGISTRY_INDEX_URL=https://github.com/rust-lang/crates.io-index
    ./target/debug/cargo-credential-1password erase
```
2023-02-09 12:30:50 +00:00