Repository: rust-lang/cargo (rust)

Issue:
`cargo-fmt` and `cargo-clippy` are not documented in The Cargo Book
### Problem

I am looking for documentation on `cargo fmt`

So I came to [here](https://doc.rust-lang.org/cargo/commands/index.html) 

It is an undocumented Cargo command.

It seems like a good place to document it.

thank you

### Proposed Solution

_No response_

### Notes

_No response_

Pull request:
docs: document official external commands
### What does this PR try to resolve?

This documents external commands that are distributed along with the Rust toolchain, including

* `cargo-clippy`
* `cargo-fmt`
* `cargo-miri`

The purpose of this is increasing the visibility of these tools, and redirecting people to the correct place to discuss and learn them.

Fixes #14640

<!-- homu-ignore:start -->

### How should we test and review this PR?

* Is “External commands” the right name to put in The Cargo Book?
* Do we really want to document the nightly-only `cargo miri`?
  * I feel like it is officially distributed, so we should.

### Additional information
<!-- homu-ignore:end -->



Patch:
diff --git a/.ignore b/.ignore
index 65290aeab..f10e171d3 100644
--- a/.ignore
+++ b/.ignore
@@ -2,5 +2,14 @@
 #
 # The goal is to help people find the right file to edit
 src/doc/man/generated_txt
-src/doc/src/commands
+src/doc/src/commands/*
 src/etc/man
+!src/doc/src/commands/build-commands.md
+!src/doc/src/commands/cargo-clippy.md
+!src/doc/src/commands/cargo-fmt.md
+!src/doc/src/commands/cargo-miri.md
+!src/doc/src/commands/general-commands.md
+!src/doc/src/commands/index.md
+!src/doc/src/commands/manifest-commands.md
+!src/doc/src/commands/package-commands.md
+!src/doc/src/commands/publishg-commands.md
diff --git a/src/bin/cargo/commands/run.rs b/src/bin/cargo/commands/run.rs
index 61feefeb3..c9e59770a 100644
--- a/src/bin/cargo/commands/run.rs
+++ b/src/bin/cargo/commands/run.rs
@@ -90,7 +90,9 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
 /// See also `util/toml/mod.rs`s `is_embedded`
 pub fn is_manifest_command(arg: &str) -> bool {
     let path = Path::new(arg);
-    1 < path.components().count() || path.extension() == Some(OsStr::new("rs"))
+    1 < path.components().count()
+        || path.extension() == Some(OsStr::new("rs"))
+        || path.file_name() == Some(OsStr::new("Cargo.toml"))
 }
 
 pub fn exec_manifest_command(gctx: &mut GlobalContext, cmd: &str, args: &[OsString]) -> CliResult {
diff --git a/src/doc/src/SUMMARY.md b/src/doc/src/SUMMARY.md
index 52fa6f7af..92324f2f6 100644
--- a/src/doc/src/SUMMARY.md
+++ b/src/doc/src/SUMMARY.md
@@ -59,14 +59,17 @@
         * [cargo build](commands/cargo-build.md)
         * [cargo check](commands/cargo-check.md)
         * [cargo clean](commands/cargo-clean.md)
+        * [cargo clippy](commands/cargo-clippy.md)
         * [cargo doc](commands/cargo-doc.md)
         * [cargo fetch](commands/cargo-fetch.md)
         * [cargo fix](commands/cargo-fix.md)
+        * [cargo fmt](commands/cargo-fmt.md)
+        * [cargo miri](commands/cargo-miri.md)
+        * [cargo report](commands/cargo-report.md)
         * [cargo run](commands/cargo-run.md)
         * [cargo rustc](commands/cargo-rustc.md)
         * [cargo rustdoc](commands/cargo-rustdoc.md)
         * [cargo test](commands/cargo-test.md)
-        * [cargo report](commands/cargo-report.md)
     * [Manifest Commands](commands/manifest-commands.md)
         * [cargo add](commands/cargo-add.md)
         * [cargo generate-lockfile](commands/cargo-generate-lockfile.md)
diff --git a/src/doc/src/commands/build-commands.md b/src/doc/src/commands/build-commands.md
index 5cc6fff96..f49f1916d 100644
--- a/src/doc/src/commands/build-commands.md
+++ b/src/doc/src/commands/build-commands.md
@@ -3,11 +3,14 @@
 * [cargo build](cargo-build.md)
 * [cargo check](cargo-check.md)
 * [cargo clean](cargo-clean.md)
+* [cargo clippy](cargo-clippy.md)
 * [cargo doc](cargo-doc.md)
 * [cargo fetch](cargo-fetch.md)
 * [cargo fix](cargo-fix.md)
+* [cargo fmt](cargo-fmt.md)
+* [cargo miri](cargo-miri.md)
+* [cargo report](cargo-report.md)
 * [cargo run](cargo-run.md)
 * [cargo rustc](cargo-rustc.md)
 * [cargo rustdoc](cargo-rustdoc.md)
 * [cargo test](cargo-test.md)
-* [cargo report](cargo-report.md)
diff --git a/src/doc/src/commands/cargo-clippy.md b/src/doc/src/commands/cargo-clippy.md
new file mode 100644
index 000000000..1a9d778d3
--- /dev/null
+++ b/src/doc/src/commands/cargo-clippy.md
@@ -0,0 +1,20 @@
+# cargo-clippy(1)
+
+## NAME
+
+cargo-miri --- Checks a package to catch common mistakes and improve your Rust code
+
+## DESCRIPTION
+
+This is an external command distributed with the Rust toolchain as an optional component.
+It is not built into Cargo, and may require additional installation.
+
+For information about usage and installation,
+see [Clippy Documentation](../../clippy/index.html).
+
+## SEE ALSO
+
+[cargo(1)](cargo.md),
+[cargo-fix(1)](cargo-fix.md),
+[cargo-fmt(1)](cargo-fmt.md),
+[Custom subcommands](../reference/external-tools.md#custom-subcommands)
diff --git a/src/doc/src/commands/cargo-fmt.md b/src/doc/src/commands/cargo-fmt.md
new file mode 100644
index 000000000..212f259d5
--- /dev/null
+++ b/src/doc/src/commands/cargo-fmt.md
@@ -0,0 +1,20 @@
+# cargo-fmt(1)
+
+## NAME
+
+carog-fmt --- Formats all bin and lib files of the current crate using rustfmt
+
+## DESCRIPTION
+
+This is an external command distributed with the Rust toolchain as an optional component.
+It is not built into Cargo, and may require additional installation.
+
+For information about usage and installation,
+see <https://github.com/rust-lang/rustfmt>.
+
+## SEE ALSO
+
+[cargo(1)](cargo.md),
+[cargo-fix(1)](cargo-fix.md),
+[cargo-clippy(1)](cargo-clippy.md),
+[Custom subcommands](../reference/external-tools.md#custom-subcommands)
diff --git a/src/doc/src/commands/cargo-miri.md b/src/doc/src/commands/cargo-miri.md
new file mode 100644
index 000000000..5665598c7
--- /dev/null
+++ b/src/doc/src/commands/cargo-miri.md
@@ -0,0 +1,22 @@
+# cargo-miri(1)
+
+## NAME
+
+cargo-miri --- Runs binary crates and tests in Miri
+
+## DESCRIPTION
+
+This is an external command distributed with the Rust toolchain as an optional component.
+It is not built into Cargo, and may require additional installation.
+
+This command is only available on the [nightly](https://doc.rust-lang.org/book/appendix-07-nightly-rust.html) channel.
+
+For information about usage and installation,
+see <https://github.com/rust-lang/miri>.
+
+## SEE ALSO
+
+[cargo(1)](cargo.md),
+[cargo-run(1)](cargo-run.md),
+[cargo-test(1)](cargo-test.md),
+[Custom subcommands](../reference/external-tools.md#custom-subcommands)


Test patch:
diff --git a/tests/testsuite/script.rs b/tests/testsuite/script.rs
index 9173ddda9..e5b3ac75a 100644
--- a/tests/testsuite/script.rs
+++ b/tests/testsuite/script.rs
@@ -68,6 +68,28 @@ args: []
         .run();
 }
 
+#[cargo_test]
+fn basic_cargo_toml() {
+    let p = cargo_test_support::project()
+        .file("src/main.rs", ECHO_SCRIPT)
+        .build();
+
+    p.cargo("-Zscript -v Cargo.toml")
+        .masquerade_as_nightly_cargo(&["script"])
+        .with_stdout_data(str![[r#"
+bin: target/debug/foo[EXE]
+args: []
+
+"#]])
+        .with_stderr_data(str![[r#"
+[COMPILING] foo v0.0.1 ([ROOT]/foo)
+[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
+[RUNNING] `target/debug/foo[EXE]`
+
+"#]])
+        .run();
+}
+
 #[cargo_test]
 fn path_required() {
     let p = cargo_test_support::project()