]> git.proxmox.com Git - cargo.git/commitdiff
Stabilize named profiles.
authorEric Huss <eric@huss.org>
Fri, 24 Sep 2021 04:55:42 +0000 (21:55 -0700)
committerEric Huss <eric@huss.org>
Fri, 24 Sep 2021 17:00:42 +0000 (10:00 -0700)
60 files changed:
src/cargo/core/features.rs
src/cargo/core/profiles.rs
src/cargo/util/command_prelude.rs
src/doc/man/cargo-bench.md
src/doc/man/cargo-build.md
src/doc/man/cargo-check.md
src/doc/man/cargo-clean.md
src/doc/man/cargo-doc.md
src/doc/man/cargo-fix.md
src/doc/man/cargo-install.md
src/doc/man/cargo-run.md
src/doc/man/cargo-rustc.md
src/doc/man/cargo-rustdoc.md
src/doc/man/cargo-test.md
src/doc/man/generated_txt/cargo-bench.txt
src/doc/man/generated_txt/cargo-build.txt
src/doc/man/generated_txt/cargo-check.txt
src/doc/man/generated_txt/cargo-clean.txt
src/doc/man/generated_txt/cargo-doc.txt
src/doc/man/generated_txt/cargo-fix.txt
src/doc/man/generated_txt/cargo-install.txt
src/doc/man/generated_txt/cargo-run.txt
src/doc/man/generated_txt/cargo-rustc.txt
src/doc/man/generated_txt/cargo-rustdoc.txt
src/doc/man/generated_txt/cargo-test.txt
src/doc/man/includes/options-profile-legacy-check.md [new file with mode: 0644]
src/doc/man/includes/options-profile.md
src/doc/man/includes/options-release.md
src/doc/man/includes/section-profiles.md [deleted file]
src/doc/src/commands/cargo-bench.md
src/doc/src/commands/cargo-build.md
src/doc/src/commands/cargo-check.md
src/doc/src/commands/cargo-clean.md
src/doc/src/commands/cargo-doc.md
src/doc/src/commands/cargo-fix.md
src/doc/src/commands/cargo-install.md
src/doc/src/commands/cargo-run.md
src/doc/src/commands/cargo-rustc.md
src/doc/src/commands/cargo-rustdoc.md
src/doc/src/commands/cargo-test.md
src/doc/src/guide/build-cache.md
src/doc/src/images/profile-selection.svg [deleted file]
src/doc/src/reference/environment-variables.md
src/doc/src/reference/profiles.md
src/doc/src/reference/unstable.md
src/etc/man/cargo-bench.1
src/etc/man/cargo-build.1
src/etc/man/cargo-check.1
src/etc/man/cargo-clean.1
src/etc/man/cargo-doc.1
src/etc/man/cargo-fix.1
src/etc/man/cargo-install.1
src/etc/man/cargo-run.1
src/etc/man/cargo-rustc.1
src/etc/man/cargo-rustdoc.1
src/etc/man/cargo-test.1
tests/testsuite/lto.rs
tests/testsuite/profile_config.rs
tests/testsuite/profile_custom.rs
tests/testsuite/profile_targets.rs

index 524985dcaa306fb64139b674d3f8d011b460ba1e..d944ba833d1936fca89688a5d454ed7025b9ec1d 100644 (file)
@@ -387,7 +387,7 @@ features! {
     (unstable, public_dependency, "", "reference/unstable.html#public-dependency"),
 
     // Allow to specify profiles other than 'dev', 'release', 'test', etc.
-    (unstable, named_profiles, "", "reference/unstable.html#custom-named-profiles"),
+    (stable, named_profiles, "1.57", "reference/profiles.html#custom-profiles"),
 
     // Opt-in new-resolver behavior.
     (stable, resolver, "1.51", "reference/resolver.html#resolver-versions"),
@@ -643,7 +643,6 @@ unstable_cli_options!(
     minimal_versions: bool = ("Resolve minimal dependency versions instead of maximum"),
     mtime_on_use: bool = ("Configure Cargo to update the mtime of used files"),
     multitarget: bool = ("Allow passing multiple `--target` flags to the cargo subcommand selected"),
-    named_profiles: bool = ("Allow defining custom profiles"),
     namespaced_features: bool = ("Allow features with `dep:` prefix"),
     no_index_update: bool = ("Do not update the registry index even if the cache is outdated"),
     panic_abort_tests: bool = ("Enable support to run tests with -Cpanic=abort"),
@@ -699,6 +698,10 @@ const STABILIZED_CONFIGURABLE_ENV: &str = "The [env] section is now always enabl
 
 const STABILIZED_PATCH_IN_CONFIG: &str = "The patch-in-config feature is now always enabled.";
 
+const STABILIZED_NAMED_PROFILES: &str = "The named-profiles feature is now always enabled.\n\
+    See https://doc.rust-lang.org/nightly/cargo/reference/profiles.html#custom-profiles \
+    for more information";
+
 fn deserialize_build_std<'de, D>(deserializer: D) -> Result<Option<Vec<String>>, D::Error>
 where
     D: serde::Deserializer<'de>,
@@ -830,7 +833,7 @@ impl CliUnstable {
             "dual-proc-macros" => self.dual_proc_macros = parse_empty(k, v)?,
             // can also be set in .cargo/config or with and ENV
             "mtime-on-use" => self.mtime_on_use = parse_empty(k, v)?,
-            "named-profiles" => self.named_profiles = parse_empty(k, v)?,
+            "named-profiles" => stabilized_warn(k, "1.57", STABILIZED_NAMED_PROFILES),
             "binary-dep-depinfo" => self.binary_dep_depinfo = parse_empty(k, v)?,
             "build-std" => {
                 self.build_std = Some(crate::core::compiler::standard_lib::parse_unstable_flag(v))
index ac167f173638bbbbe28aa76c4f0f7e2a4bbc96be..a028ca571fc7514a4e47e4880f0b548432aa2d4b 100644 (file)
@@ -20,6 +20,11 @@ pub struct Profiles {
     dir_names: HashMap<InternedString, InternedString>,
     /// The profile makers. Key is the profile name.
     by_name: HashMap<InternedString, ProfileMaker>,
+    /// The original profiles written by the user in the manifest and config.
+    ///
+    /// This is here to assist with error reporting, as the `ProfileMaker`
+    /// values have the inherits chains all merged together.
+    original_profiles: BTreeMap<InternedString, TomlProfile>,
     /// Whether or not unstable "named" profiles are enabled.
     named_profiles_enabled: bool,
     /// The profile the user requested to use.
@@ -44,6 +49,7 @@ impl Profiles {
                 named_profiles_enabled: false,
                 dir_names: Self::predefined_dir_names(),
                 by_name: HashMap::new(),
+                original_profiles: profiles.clone(),
                 requested_profile,
                 rustc_host,
             };
@@ -97,6 +103,7 @@ impl Profiles {
             named_profiles_enabled: true,
             dir_names: Self::predefined_dir_names(),
             by_name: HashMap::new(),
+            original_profiles: profiles.clone(),
             requested_profile,
             rustc_host,
         };
@@ -420,6 +427,19 @@ impl Profiles {
         resolve: &Resolve,
     ) -> CargoResult<()> {
         for (name, profile) in &self.by_name {
+            // If the user did not specify an override, skip this. This is here
+            // to avoid generating errors for inherited profiles which don't
+            // specify package overrides. The `by_name` profile has had the inherits
+            // chain merged, so we need to look at the original source to check
+            // if an override was specified.
+            if self
+                .original_profiles
+                .get(name)
+                .and_then(|orig| orig.package.as_ref())
+                .is_none()
+            {
+                continue;
+            }
             let found = validate_packages_unique(resolve, name, &profile.toml)?;
             // We intentionally do not validate unmatched packages for config
             // profiles, in case they are defined in a central location. This
@@ -456,6 +476,10 @@ struct ProfileMaker {
     /// The starting, hard-coded defaults for the profile.
     default: Profile,
     /// The TOML profile defined in `Cargo.toml` or config.
+    ///
+    /// This is None if the user did not specify one, in which case the
+    /// `default` is used. Note that the built-in defaults for test/bench/doc
+    /// always set this since they need to declare the `inherits` value.
     toml: Option<TomlProfile>,
 }
 
index bab36a9a94d5e1e0ee4042ccddcc98d5277ec75c..afe3d68abff7b5c387bcb3e2405556502d2cd7ac 100644 (file)
@@ -353,7 +353,7 @@ pub trait ArgMatchesExt {
 
     fn get_profile_name(
         &self,
-        config: &Config,
+        _config: &Config,
         default: &str,
         profile_checking: ProfileChecking,
     ) -> CargoResult<InternedString> {
@@ -369,10 +369,6 @@ pub trait ArgMatchesExt {
             _ => {}
         }
 
-        if specified_profile.is_some() && !config.cli_unstable().unstable_options {
-            bail!("usage of `--profile` requires `-Z unstable-options`");
-        }
-
         let conflict = |flag: &str, equiv: &str, specified: &str| -> anyhow::Error {
             anyhow::format_err!(
                 "conflicting usage of --profile={} and --{flag}\n\
index 9c62c2d1e83451e2e82597ae3b7afc8a24d00ad0..ded8e2b361f172241f717cffa36b3cc955cbe793 100644 (file)
@@ -46,6 +46,14 @@ function to handle running benchmarks.
 > running benchmarks on the stable channel, such as
 > [Criterion](https://crates.io/crates/criterion).
 
+By default, `cargo bench` uses the [`bench` profile], which enables
+optimizations and disables debugging information. If you need to debug a
+benchmark, you can use the `--profile=dev` command-line option to switch to
+the dev profile. You can then run the debug-enabled benchmark within a
+debugger.
+
+[`bench` profile]: ../reference/profiles.html#bench
+
 ## OPTIONS
 
 ### Benchmark Options
@@ -83,6 +91,8 @@ target.
 
 {{> options-target-triple }}
 
+{{> options-profile }}
+
 {{> options-ignore-rust-version }}
 
 {{/options}}
@@ -129,23 +139,6 @@ Rust test harness runs benchmarks serially in a single thread.
 {{> options-jobs }}
 {{/options}}
 
-## PROFILES
-
-Profiles may be used to configure compiler options such as optimization levels
-and debug settings. See
-[the reference](../reference/profiles.html)
-for more details.
-
-Benchmarks are always built with the `bench` profile. Binary and lib targets
-are built separately as benchmarks with the `bench` profile. Library targets
-are built with the `release` profiles when linked to binaries and benchmarks.
-Dependencies use the `release` profile.
-
-If you need a debug build of a benchmark, try building it with
-{{man "cargo-build" 1}} which will use the `test` profile which is by default
-unoptimized and includes debug information. You can then run the debug-enabled
-benchmark manually.
-
 {{> section-environment }}
 
 {{> section-exit-status }}
index ceca80d2929f26800a796147e3241c92d6a879d6..8b5aa47179140bc2c3f978b90672be6440b95c35 100644 (file)
@@ -35,6 +35,8 @@ they have `required-features` that are missing.
 
 {{> options-release }}
 
+{{> options-profile }}
+
 {{> options-ignore-rust-version }}
 
 {{/options}}
@@ -89,8 +91,6 @@ See <https://github.com/rust-lang/cargo/issues/5579> for more information.
 {{> options-jobs }}
 {{/options}}
 
-{{> section-profiles }}
-
 {{> section-environment }}
 
 {{> section-exit-status }}
index c31411a9183cf4e27874c29ca6cd05d47c625ba7..5264043f93827215e1c556ab28ae50aaa7a64f86 100644 (file)
@@ -40,7 +40,7 @@ they have `required-features` that are missing.
 
 {{> options-release }}
 
-{{> options-profile }}
+{{> options-profile-legacy-check }}
 
 {{> options-ignore-rust-version }}
 
@@ -76,8 +76,6 @@ they have `required-features` that are missing.
 {{> options-jobs }}
 {{/options}}
 
-{{> section-profiles }}
-
 {{> section-environment }}
 
 {{> section-exit-status }}
index d7d50840a9c70b3f794932f452186a17fd0552eb..aa63156324832db639a3a5e341e0af138bb813af 100644 (file)
@@ -40,7 +40,11 @@ the target directory.
 {{/option}}
 
 {{#option "`--release`" }}
-Clean all artifacts that were built with the `release` or `bench` profiles.
+Remove all artifacts in the `release` directory.
+{{/option}}
+
+{{#option "`--profile` _name_" }}
+Remove all artifacts in the directory with the given profile name.
 {{/option}}
 
 {{> options-target-dir }}
index b0289a8368f89c67bdf17bad491e8710939bd29a..551adfcf9515d99b55239cafe28764e8a244a58f 100644 (file)
@@ -74,6 +74,8 @@ and supports common Unix glob patterns.
 
 {{> options-release }}
 
+{{> options-profile }}
+
 {{> options-ignore-rust-version }}
 
 {{/options}}
@@ -108,8 +110,6 @@ and supports common Unix glob patterns.
 {{> options-jobs }}
 {{/options}}
 
-{{> section-profiles }}
-
 {{> section-environment }}
 
 {{> section-exit-status }}
index de8a39a5d0d2f61ba80e7598812b19168129a0c2..2d96efd42177965a17109a7f59e26dc4f1317238 100644 (file)
@@ -120,7 +120,7 @@ When no target selection options are given, `cargo fix` will fix all targets
 
 {{> options-release }}
 
-{{> options-profile }}
+{{> options-profile-legacy-check }}
 
 {{> options-ignore-rust-version }}
 
@@ -156,8 +156,6 @@ When no target selection options are given, `cargo fix` will fix all targets
 {{> options-jobs }}
 {{/options}}
 
-{{> section-profiles }}
-
 {{> section-environment }}
 
 {{> section-exit-status }}
index 95f55002134aed40acc0de0136a2ab3a02b54ccb..bea6ec37c4f719ec48f8d65d0f3431648e50e496 100644 (file)
@@ -42,7 +42,7 @@ change, then Cargo will reinstall the package:
 - The package version and source.
 - The set of binary names installed.
 - The chosen features.
-- The release mode (`--debug`).
+- The profile (`--profile`).
 - The target (`--target`).
 
 Installing with `--path` will always build and install, unless there are
@@ -162,8 +162,11 @@ Directory to install packages into.
 
 {{#option "`--debug`" }}
 Build with the `dev` profile instead the `release` profile.
+See also the `--profile` option for choosing a specific profile by name.
 {{/option}}
 
+{{> options-profile }}
+
 {{/options}}
 
 ### Manifest Options
index 7ba63c91eaf70518e6ac1d595f9e4d976f896cf0..b4e1d06695f4a70e3b16dc1583011a95047fc5f2 100644 (file)
@@ -50,6 +50,8 @@ Run the specified example.
 
 {{> options-release }}
 
+{{> options-profile }}
+
 {{> options-ignore-rust-version }}
 
 {{/options}}
@@ -88,8 +90,6 @@ Run the specified example.
 {{> options-jobs }}
 {{/options}}
 
-{{> section-profiles }}
-
 {{> section-environment }}
 
 {{> section-exit-status }}
index 178580a2edb21fe51e7b1e7bc17f5e3a5e3f90d8..de0159e54d3432d4b2cb70e587c19e5a1714eddc 100644 (file)
@@ -47,6 +47,23 @@ binary and library targets of the selected package.
 
 {{> options-release }}
 
+{{#option "`--profile` _name_" }}
+Build with the given profile.
+
+The `rustc` subcommand will treat the following named profiles with special behaviors:
+
+* `check` â€” Builds in the same way as the {{man "cargo-check" 1}} command with
+  the `dev` profile.
+* `test` â€” Builds in the same way as the {{man "cargo-test" 1}} command,
+  enabling building in test mode which will enable tests and enable the `test`
+  cfg option. See [rustc
+  tests](https://doc.rust-lang.org/rustc/tests/index.html) for more detail.
+* `bench` â€” Builds in the same was as the {{man "cargo-bench" 1}} command,
+  similar to the `test` profile.
+
+See the [the reference](../reference/profiles.html) for more details on profiles.
+{{/option}}
+
 {{> options-ignore-rust-version }}
 
 {{/options}}
@@ -85,8 +102,6 @@ binary and library targets of the selected package.
 {{> options-jobs }}
 {{/options}}
 
-{{> section-profiles }}
-
 {{> section-environment }}
 
 {{> section-exit-status }}
index 40aaff20018bce3f8dbe7b14dbd32eecc71db11e..278c569646c48f7e09d7b0c8642806a3f14d4fbb 100644 (file)
@@ -62,6 +62,8 @@ if its name is the same as the lib target. Binaries are skipped if they have
 
 {{> options-release }}
 
+{{> options-profile }}
+
 {{> options-ignore-rust-version }}
 
 {{/options}}
@@ -96,8 +98,6 @@ if its name is the same as the lib target. Binaries are skipped if they have
 {{> options-jobs }}
 {{/options}}
 
-{{> section-profiles }}
-
 {{> section-environment }}
 
 {{> section-exit-status }}
index eb352e46e7b690f29e211831eca977ac86c73600..2381a9e6ff7f1fafdb45fed42127d36c6b5d073b 100644 (file)
@@ -102,6 +102,8 @@ target options.
 
 {{> options-release }}
 
+{{> options-profile }}
+
 {{> options-ignore-rust-version }}
 
 {{/options}}
@@ -154,16 +156,6 @@ includes an option to control the number of threads used:
 
 {{/options}}
 
-{{> section-profiles }}
-
-Unit tests are separate executable artifacts which use the `test`/`bench`
-profiles. Example targets are built the same as with `cargo build` (using the
-`dev`/`release` profiles) unless you are building them with the test harness
-(by setting `test = true` in the manifest or using the `--example` flag) in
-which case they use the `test`/`bench` profiles. Library targets are built
-with the `dev`/`release` profiles when linked to an integration test, binary,
-or doctest.
-
 {{> section-environment }}
 
 {{> section-exit-status }}
index 5a933063709ca1105202ac905cfe4a0b8e9c6e00..fcb476b8f5570e255f90fc75a49f38b104c69549 100644 (file)
@@ -41,6 +41,13 @@ DESCRIPTION
           benchmarks on the stable channel, such as Criterion
           <https://crates.io/crates/criterion>.
 
+       By default, cargo bench uses the bench profile
+       <https://doc.rust-lang.org/cargo/reference/profiles.html#bench>, which
+       enables optimizations and disables debugging information. If you need to
+       debug a benchmark, you can use the --profile=dev command-line option to
+       switch to the dev profile. You can then run the debug-enabled benchmark
+       within a debugger.
+
 OPTIONS
    Benchmark Options
        --no-run
@@ -202,6 +209,11 @@ OPTIONS
            <https://doc.rust-lang.org/cargo/guide/build-cache.html>
            documentation for more details.
 
+       --profile name
+           Benchmark with the given profile. See the the reference
+           <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
+           details on profiles.
+
        --ignore-rust-version
            Benchmark the target even if the selected Rust compiler is older
            than the required Rust version as configured in the project's
@@ -329,22 +341,6 @@ OPTIONS
            <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to
            the number of CPUs.
 
-PROFILES
-       Profiles may be used to configure compiler options such as optimization
-       levels and debug settings. See the reference
-       <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
-       details.
-
-       Benchmarks are always built with the bench profile. Binary and lib
-       targets are built separately as benchmarks with the bench profile.
-       Library targets are built with the release profiles when linked to
-       binaries and benchmarks. Dependencies use the release profile.
-
-       If you need a debug build of a benchmark, try building it with
-       cargo-build(1) which will use the test profile which is by default
-       unoptimized and includes debug information. You can then run the
-       debug-enabled benchmark manually.
-
 ENVIRONMENT
        See the reference
        <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
index 4b321d9f7cb187d2ae359c850a793d6b5fa10fe5..4eb1e072a8c4e8133abb9baf437ab9f07d12464a 100644 (file)
@@ -143,8 +143,13 @@ OPTIONS
            documentation for more details.
 
        --release
-           Build optimized artifacts with the release profile. See the PROFILES
-           section for details on how this affects profile selection.
+           Build optimized artifacts with the release profile. See also the
+           --profile option for choosing a specific profile by name.
+
+       --profile name
+           Build with the given profile. See the the reference
+           <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
+           details on profiles.
 
        --ignore-rust-version
            Build the target even if the selected Rust compiler is older than
@@ -282,28 +287,6 @@ OPTIONS
            <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to
            the number of CPUs.
 
-PROFILES
-       Profiles may be used to configure compiler options such as optimization
-       levels and debug settings. See the reference
-       <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
-       details.
-
-       Profile selection depends on the target and crate being built. By
-       default the dev or test profiles are used. If the --release flag is
-       given, then the release or bench profiles are used.
-
-       +----------------------------------------+-------------+--------------+
-       | Target                                 | Default     | --release    |
-       |                                        | Profile     | Profile      |
-       +----------------------------------------+-------------+--------------+
-       | lib, bin, example                      | dev         | release      |
-       +----------------------------------------+-------------+--------------+
-       | test, bench, or any target in "test"   | test        | bench        |
-       | or "bench" mode                        |             |              |
-       +----------------------------------------+-------------+--------------+
-
-       Dependencies use the dev/release profiles.
-
 ENVIRONMENT
        See the reference
        <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
index ce8281c6a2717a67ded21616f847eeda2eda995c..2ca78e6e9ac4eadc7c87246988aca15fd3cdee2e 100644 (file)
@@ -149,14 +149,20 @@ OPTIONS
            documentation for more details.
 
        --release
-           Check optimized artifacts with the release profile. See the PROFILES
-           section for details on how this affects profile selection.
+           Check optimized artifacts with the release profile. See also the
+           --profile option for choosing a specific profile by name.
 
        --profile name
-           Changes check behavior. Currently only test is supported, which will
-           check with the #[cfg(test)] attribute enabled. This is useful to
-           have it check unit tests which are usually excluded via the cfg
-           attribute. This does not change the actual profile used.
+           Check with the given profile.
+
+           As a special case, specifying the test profile will also enable
+           checking in test mode which will enable checking tests and enable
+           the test cfg option. See rustc tests
+           <https://doc.rust-lang.org/rustc/tests/index.html> for more detail.
+
+           See the the reference
+           <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
+           details on profiles.
 
        --ignore-rust-version
            Check the target even if the selected Rust compiler is older than
@@ -275,28 +281,6 @@ OPTIONS
            <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to
            the number of CPUs.
 
-PROFILES
-       Profiles may be used to configure compiler options such as optimization
-       levels and debug settings. See the reference
-       <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
-       details.
-
-       Profile selection depends on the target and crate being built. By
-       default the dev or test profiles are used. If the --release flag is
-       given, then the release or bench profiles are used.
-
-       +----------------------------------------+-------------+--------------+
-       | Target                                 | Default     | --release    |
-       |                                        | Profile     | Profile      |
-       +----------------------------------------+-------------+--------------+
-       | lib, bin, example                      | dev         | release      |
-       +----------------------------------------+-------------+--------------+
-       | test, bench, or any target in "test"   | test        | bench        |
-       | or "bench" mode                        |             |              |
-       +----------------------------------------+-------------+--------------+
-
-       Dependencies use the dev/release profiles.
-
 ENVIRONMENT
        See the reference
        <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
index 192217e8b8ed848e5521ea7f48992db223298990..9f4530a7ea8db950aa4344cc457f72ef46e6df61 100644 (file)
@@ -27,8 +27,10 @@ OPTIONS
            in the target directory.
 
        --release
-           Clean all artifacts that were built with the release or bench
-           profiles.
+           Remove all artifacts in the release directory.
+
+       --profile name
+           Remove all artifacts in the directory with the given profile name.
 
        --target-dir directory
            Directory for all generated artifacts and intermediate files. May
index de1589d6304d8984208bce7495c8b13c1fc680d5..648c55e2017b9c26338f216dc89835b4454c587c 100644 (file)
@@ -127,8 +127,13 @@ OPTIONS
            documentation for more details.
 
        --release
-           Document optimized artifacts with the release profile. See the
-           PROFILES section for details on how this affects profile selection.
+           Document optimized artifacts with the release profile. See also the
+           --profile option for choosing a specific profile by name.
+
+       --profile name
+           Document with the given profile. See the the reference
+           <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
+           details on profiles.
 
        --ignore-rust-version
            Document the target even if the selected Rust compiler is older than
@@ -247,28 +252,6 @@ OPTIONS
            <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to
            the number of CPUs.
 
-PROFILES
-       Profiles may be used to configure compiler options such as optimization
-       levels and debug settings. See the reference
-       <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
-       details.
-
-       Profile selection depends on the target and crate being built. By
-       default the dev or test profiles are used. If the --release flag is
-       given, then the release or bench profiles are used.
-
-       +----------------------------------------+-------------+--------------+
-       | Target                                 | Default     | --release    |
-       |                                        | Profile     | Profile      |
-       +----------------------------------------+-------------+--------------+
-       | lib, bin, example                      | dev         | release      |
-       +----------------------------------------+-------------+--------------+
-       | test, bench, or any target in "test"   | test        | bench        |
-       | or "bench" mode                        |             |              |
-       +----------------------------------------+-------------+--------------+
-
-       Dependencies use the dev/release profiles.
-
 ENVIRONMENT
        See the reference
        <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
index 450023a7241fc285267873f47ce7d253b8f6b6dc..60aec632e004b3d2c95eb161d3fd04d8cecff582 100644 (file)
@@ -222,14 +222,20 @@ OPTIONS
            documentation for more details.
 
        --release
-           Fix optimized artifacts with the release profile. See the PROFILES
-           section for details on how this affects profile selection.
+           Fix optimized artifacts with the release profile. See also the
+           --profile option for choosing a specific profile by name.
 
        --profile name
-           Changes fix behavior. Currently only test is supported, which will
-           fix with the #[cfg(test)] attribute enabled. This is useful to have
-           it fix unit tests which are usually excluded via the cfg attribute.
-           This does not change the actual profile used.
+           Fix with the given profile.
+
+           As a special case, specifying the test profile will also enable
+           checking in test mode which will enable checking tests and enable
+           the test cfg option. See rustc tests
+           <https://doc.rust-lang.org/rustc/tests/index.html> for more detail.
+
+           See the the reference
+           <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
+           details on profiles.
 
        --ignore-rust-version
            Fix the target even if the selected Rust compiler is older than the
@@ -348,28 +354,6 @@ OPTIONS
            <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to
            the number of CPUs.
 
-PROFILES
-       Profiles may be used to configure compiler options such as optimization
-       levels and debug settings. See the reference
-       <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
-       details.
-
-       Profile selection depends on the target and crate being built. By
-       default the dev or test profiles are used. If the --release flag is
-       given, then the release or bench profiles are used.
-
-       +----------------------------------------+-------------+--------------+
-       | Target                                 | Default     | --release    |
-       |                                        | Profile     | Profile      |
-       +----------------------------------------+-------------+--------------+
-       | lib, bin, example                      | dev         | release      |
-       +----------------------------------------+-------------+--------------+
-       | test, bench, or any target in "test"   | test        | bench        |
-       | or "bench" mode                        |             |              |
-       +----------------------------------------+-------------+--------------+
-
-       Dependencies use the dev/release profiles.
-
 ENVIRONMENT
        See the reference
        <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
index ce009c0cb681fe4cd0d90c8a887fac9f331e4a01..09a2094237694bce7bdaa8b09011c58e86cc6fa2 100644 (file)
@@ -51,7 +51,7 @@ DESCRIPTION
 
        o  The chosen features.
 
-       o  The release mode (--debug).
+       o  The profile (--profile).
 
        o  The target (--target).
 
@@ -197,7 +197,13 @@ OPTIONS
            workspace of the local crate unless --target-dir is specified.
 
        --debug
-           Build with the dev profile instead the release profile.
+           Build with the dev profile instead the release profile. See also the
+           --profile option for choosing a specific profile by name.
+
+       --profile name
+           Install with the given profile. See the the reference
+           <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
+           details on profiles.
 
    Manifest Options
        --frozen, --locked
index 918f161b5d2ef8ced60801d243059b680c7a0aa6..7afb34ae04e815b1a50c0e4f831d777b2ce457ea 100644 (file)
@@ -72,8 +72,13 @@ OPTIONS
            documentation for more details.
 
        --release
-           Run optimized artifacts with the release profile. See the PROFILES
-           section for details on how this affects profile selection.
+           Run optimized artifacts with the release profile. See also the
+           --profile option for choosing a specific profile by name.
+
+       --profile name
+           Run with the given profile. See the the reference
+           <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
+           details on profiles.
 
        --ignore-rust-version
            Run the target even if the selected Rust compiler is older than the
@@ -192,28 +197,6 @@ OPTIONS
            <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to
            the number of CPUs.
 
-PROFILES
-       Profiles may be used to configure compiler options such as optimization
-       levels and debug settings. See the reference
-       <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
-       details.
-
-       Profile selection depends on the target and crate being built. By
-       default the dev or test profiles are used. If the --release flag is
-       given, then the release or bench profiles are used.
-
-       +----------------------------------------+-------------+--------------+
-       | Target                                 | Default     | --release    |
-       |                                        | Profile     | Profile      |
-       +----------------------------------------+-------------+--------------+
-       | lib, bin, example                      | dev         | release      |
-       +----------------------------------------+-------------+--------------+
-       | test, bench, or any target in "test"   | test        | bench        |
-       | or "bench" mode                        |             |              |
-       +----------------------------------------+-------------+--------------+
-
-       Dependencies use the dev/release profiles.
-
 ENVIRONMENT
        See the reference
        <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
index d8d18ccaedf55e1f35bf52989858aab3089b5e9a..1a02a7e05c8f032158865b69a906b1373fc4600f 100644 (file)
@@ -134,8 +134,30 @@ OPTIONS
            documentation for more details.
 
        --release
-           Build optimized artifacts with the release profile. See the PROFILES
-           section for details on how this affects profile selection.
+           Build optimized artifacts with the release profile. See also the
+           --profile option for choosing a specific profile by name.
+
+       --profile name
+           Build with the given profile.
+
+           The rustc subcommand will treat the following named profiles with
+           special behaviors:
+
+           o  check â€” Builds in the same way as the cargo-check(1) command
+              with the dev profile.
+
+           o  test â€” Builds in the same way as the cargo-test(1) command,
+              enabling building in test mode which will enable tests and enable
+              the test cfg option. See rustc tests
+              <https://doc.rust-lang.org/rustc/tests/index.html> for more
+              detail.
+
+           o  bench â€” Builds in the same was as the cargo-bench(1) command,
+              similar to the test profile.
+
+           See the the reference
+           <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
+           details on profiles.
 
        --ignore-rust-version
            Build the target even if the selected Rust compiler is older than
@@ -254,28 +276,6 @@ OPTIONS
            <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to
            the number of CPUs.
 
-PROFILES
-       Profiles may be used to configure compiler options such as optimization
-       levels and debug settings. See the reference
-       <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
-       details.
-
-       Profile selection depends on the target and crate being built. By
-       default the dev or test profiles are used. If the --release flag is
-       given, then the release or bench profiles are used.
-
-       +----------------------------------------+-------------+--------------+
-       | Target                                 | Default     | --release    |
-       |                                        | Profile     | Profile      |
-       +----------------------------------------+-------------+--------------+
-       | lib, bin, example                      | dev         | release      |
-       +----------------------------------------+-------------+--------------+
-       | test, bench, or any target in "test"   | test        | bench        |
-       | or "bench" mode                        |             |              |
-       +----------------------------------------+-------------+--------------+
-
-       Dependencies use the dev/release profiles.
-
 ENVIRONMENT
        See the reference
        <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
index 628bbcfe595382e248fa5c25b3e666501e147cd7..4d47a2318aa9d3865e143e4a373fe7090d0d92b3 100644 (file)
@@ -143,8 +143,13 @@ OPTIONS
            documentation for more details.
 
        --release
-           Document optimized artifacts with the release profile. See the
-           PROFILES section for details on how this affects profile selection.
+           Document optimized artifacts with the release profile. See also the
+           --profile option for choosing a specific profile by name.
+
+       --profile name
+           Document with the given profile. See the the reference
+           <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
+           details on profiles.
 
        --ignore-rust-version
            Document the target even if the selected Rust compiler is older than
@@ -263,28 +268,6 @@ OPTIONS
            <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to
            the number of CPUs.
 
-PROFILES
-       Profiles may be used to configure compiler options such as optimization
-       levels and debug settings. See the reference
-       <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
-       details.
-
-       Profile selection depends on the target and crate being built. By
-       default the dev or test profiles are used. If the --release flag is
-       given, then the release or bench profiles are used.
-
-       +----------------------------------------+-------------+--------------+
-       | Target                                 | Default     | --release    |
-       |                                        | Profile     | Profile      |
-       +----------------------------------------+-------------+--------------+
-       | lib, bin, example                      | dev         | release      |
-       +----------------------------------------+-------------+--------------+
-       | test, bench, or any target in "test"   | test        | bench        |
-       | or "bench" mode                        |             |              |
-       +----------------------------------------+-------------+--------------+
-
-       Dependencies use the dev/release profiles.
-
 ENVIRONMENT
        See the reference
        <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
index e554e938c38b91fc28eedb5588371b81b6c713a6..e0a4c1d94ccf76d6119624d7c611f71a11c207d1 100644 (file)
@@ -220,8 +220,13 @@ OPTIONS
            documentation for more details.
 
        --release
-           Test optimized artifacts with the release profile. See the PROFILES
-           section for details on how this affects profile selection.
+           Test optimized artifacts with the release profile. See also the
+           --profile option for choosing a specific profile by name.
+
+       --profile name
+           Test with the given profile. See the the reference
+           <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
+           details on profiles.
 
        --ignore-rust-version
            Test the target even if the selected Rust compiler is older than the
@@ -352,36 +357,6 @@ OPTIONS
            <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to
            the number of CPUs.
 
-PROFILES
-       Profiles may be used to configure compiler options such as optimization
-       levels and debug settings. See the reference
-       <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
-       details.
-
-       Profile selection depends on the target and crate being built. By
-       default the dev or test profiles are used. If the --release flag is
-       given, then the release or bench profiles are used.
-
-       +----------------------------------------+-------------+--------------+
-       | Target                                 | Default     | --release    |
-       |                                        | Profile     | Profile      |
-       +----------------------------------------+-------------+--------------+
-       | lib, bin, example                      | dev         | release      |
-       +----------------------------------------+-------------+--------------+
-       | test, bench, or any target in "test"   | test        | bench        |
-       | or "bench" mode                        |             |              |
-       +----------------------------------------+-------------+--------------+
-
-       Dependencies use the dev/release profiles.
-
-       Unit tests are separate executable artifacts which use the test/bench
-       profiles. Example targets are built the same as with cargo build (using
-       the dev/release profiles) unless you are building them with the test
-       harness (by setting test = true in the manifest or using the --example
-       flag) in which case they use the test/bench profiles. Library targets
-       are built with the dev/release profiles when linked to an integration
-       test, binary, or doctest.
-
 ENVIRONMENT
        See the reference
        <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
diff --git a/src/doc/man/includes/options-profile-legacy-check.md b/src/doc/man/includes/options-profile-legacy-check.md
new file mode 100644 (file)
index 0000000..0ec82e6
--- /dev/null
@@ -0,0 +1,10 @@
+{{#option "`--profile` _name_" }}
+{{actionverb}} with the given profile.
+
+As a special case, specifying the `test` profile will also enable checking in
+test mode which will enable checking tests and enable the `test` cfg option.
+See [rustc tests](https://doc.rust-lang.org/rustc/tests/index.html) for more
+detail.
+
+See the [the reference](../reference/profiles.html) for more details on profiles.
+{{/option}}
index 275bbef7bb2ea4dfd77ed132767d22963a7230ff..2452e7b1441c4a1d0d32506fbb8468245a8ffb83 100644 (file)
@@ -1,7 +1,4 @@
 {{#option "`--profile` _name_" }}
-Changes {{lower actionverb}} behavior. Currently only `test` is supported,
-which will {{lower actionverb}} with the `#[cfg(test)]` attribute enabled.
-This is useful to have it {{lower actionverb}} unit tests which are usually
-excluded via the `cfg` attribute. This does not change the actual profile
-used.
+{{actionverb}} with the given profile.
+See the [the reference](../reference/profiles.html) for more details on profiles.
 {{/option}}
index 4ee0fe6d628e6144878d2556443e9a1a414a67b1..ad77c274e4a750e24f60cc77beb9b743c1565074 100644 (file)
@@ -1,5 +1,4 @@
 {{#option "`--release`"}}
-{{actionverb}} optimized artifacts with the `release` profile. See the
-[PROFILES](#profiles) section for details on how this affects profile
-selection.
+{{actionverb}} optimized artifacts with the `release` profile.
+See also the `--profile` option for choosing a specific profile by name.
 {{/option}}
diff --git a/src/doc/man/includes/section-profiles.md b/src/doc/man/includes/section-profiles.md
deleted file mode 100644 (file)
index d0a4072..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-## PROFILES
-
-Profiles may be used to configure compiler options such as optimization levels
-and debug settings. See [the reference](../reference/profiles.html) for more
-details.
-
-Profile selection depends on the target and crate being built. By default the
-`dev` or `test` profiles are used. If the `--release` flag is given, then the
-`release` or `bench` profiles are used.
-
-Target | Default Profile | `--release` Profile
--------|-----------------|---------------------
-lib, bin, example | `dev` | `release`
-test, bench, or any target in "test" or "bench" mode | `test` | `bench`
-
-Dependencies use the `dev`/`release` profiles.
index ce58f230758b9795eb0870fe5f4307a85ccb3e60..3352230b5f7fb676808ed27187dc711644452493 100644 (file)
@@ -46,6 +46,14 @@ function to handle running benchmarks.
 > running benchmarks on the stable channel, such as
 > [Criterion](https://crates.io/crates/criterion).
 
+By default, `cargo bench` uses the [`bench` profile], which enables
+optimizations and disables debugging information. If you need to debug a
+benchmark, you can use the `--profile=dev` command-line option to switch to
+the dev profile. You can then run the debug-enabled benchmark within a
+debugger.
+
+[`bench` profile]: ../reference/profiles.html#bench
+
 ## OPTIONS
 
 ### Benchmark Options
@@ -245,6 +253,12 @@ target artifacts are placed in a separate directory. See the
 
 
 
+<dt class="option-term" id="option-cargo-bench---profile"><a class="option-anchor" href="#option-cargo-bench---profile"></a><code>--profile</code> <em>name</em></dt>
+<dd class="option-desc">Benchmark with the given profile.
+See the <a href="../reference/profiles.html">the reference</a> for more details on profiles.</dd>
+
+
+
 <dt class="option-term" id="option-cargo-bench---ignore-rust-version"><a class="option-anchor" href="#option-cargo-bench---ignore-rust-version"></a><code>--ignore-rust-version</code></dt>
 <dd class="option-desc">Benchmark the target even if the selected Rust compiler is older than the
 required Rust version as configured in the project's <code>rust-version</code> field.</dd>
@@ -402,23 +416,6 @@ the number of CPUs.</dd>
 
 </dl>
 
-## PROFILES
-
-Profiles may be used to configure compiler options such as optimization levels
-and debug settings. See
-[the reference](../reference/profiles.html)
-for more details.
-
-Benchmarks are always built with the `bench` profile. Binary and lib targets
-are built separately as benchmarks with the `bench` profile. Library targets
-are built with the `release` profiles when linked to binaries and benchmarks.
-Dependencies use the `release` profile.
-
-If you need a debug build of a benchmark, try building it with
-[cargo-build(1)](cargo-build.html) which will use the `test` profile which is by default
-unoptimized and includes debug information. You can then run the debug-enabled
-benchmark manually.
-
 ## ENVIRONMENT
 
 See [the reference](../reference/environment-variables.html) for
index fb372dc0007bd69e098cbeb16fff757a99d96d90..c7f5d6290f9abc19575eccba825f2464fbc376ca 100644 (file)
@@ -182,9 +182,14 @@ target artifacts are placed in a separate directory. See the
 
 
 <dt class="option-term" id="option-cargo-build---release"><a class="option-anchor" href="#option-cargo-build---release"></a><code>--release</code></dt>
-<dd class="option-desc">Build optimized artifacts with the <code>release</code> profile. See the
-<a href="#profiles">PROFILES</a> section for details on how this affects profile
-selection.</dd>
+<dd class="option-desc">Build optimized artifacts with the <code>release</code> profile.
+See also the <code>--profile</code> option for choosing a specific profile by name.</dd>
+
+
+
+<dt class="option-term" id="option-cargo-build---profile"><a class="option-anchor" href="#option-cargo-build---profile"></a><code>--profile</code> <em>name</em></dt>
+<dd class="option-desc">Build with the given profile.
+See the <a href="../reference/profiles.html">the reference</a> for more details on profiles.</dd>
 
 
 
@@ -351,24 +356,6 @@ the number of CPUs.</dd>
 
 </dl>
 
-## PROFILES
-
-Profiles may be used to configure compiler options such as optimization levels
-and debug settings. See [the reference](../reference/profiles.html) for more
-details.
-
-Profile selection depends on the target and crate being built. By default the
-`dev` or `test` profiles are used. If the `--release` flag is given, then the
-`release` or `bench` profiles are used.
-
-Target | Default Profile | `--release` Profile
--------|-----------------|---------------------
-lib, bin, example | `dev` | `release`
-test, bench, or any target in "test" or "bench" mode | `test` | `bench`
-
-Dependencies use the `dev`/`release` profiles.
-
-
 ## ENVIRONMENT
 
 See [the reference](../reference/environment-variables.html) for
index 28340b26ac9222c41ebda6c85f5a27806f078423..a1f319a2bc6fc6cbca39f0017cac0d3b34ec5f03 100644 (file)
@@ -187,18 +187,18 @@ target artifacts are placed in a separate directory. See the
 
 
 <dt class="option-term" id="option-cargo-check---release"><a class="option-anchor" href="#option-cargo-check---release"></a><code>--release</code></dt>
-<dd class="option-desc">Check optimized artifacts with the <code>release</code> profile. See the
-<a href="#profiles">PROFILES</a> section for details on how this affects profile
-selection.</dd>
+<dd class="option-desc">Check optimized artifacts with the <code>release</code> profile.
+See also the <code>--profile</code> option for choosing a specific profile by name.</dd>
 
 
 
 <dt class="option-term" id="option-cargo-check---profile"><a class="option-anchor" href="#option-cargo-check---profile"></a><code>--profile</code> <em>name</em></dt>
-<dd class="option-desc">Changes check behavior. Currently only <code>test</code> is supported,
-which will check with the <code>#[cfg(test)]</code> attribute enabled.
-This is useful to have it check unit tests which are usually
-excluded via the <code>cfg</code> attribute. This does not change the actual profile
-used.</dd>
+<dd class="option-desc">Check with the given profile.</p>
+<p>As a special case, specifying the <code>test</code> profile will also enable checking in
+test mode which will enable checking tests and enable the <code>test</code> cfg option.
+See <a href="https://doc.rust-lang.org/rustc/tests/index.html">rustc tests</a> for more
+detail.</p>
+<p>See the <a href="../reference/profiles.html">the reference</a> for more details on profiles.</dd>
 
 
 
@@ -347,24 +347,6 @@ the number of CPUs.</dd>
 
 </dl>
 
-## PROFILES
-
-Profiles may be used to configure compiler options such as optimization levels
-and debug settings. See [the reference](../reference/profiles.html) for more
-details.
-
-Profile selection depends on the target and crate being built. By default the
-`dev` or `test` profiles are used. If the `--release` flag is given, then the
-`release` or `bench` profiles are used.
-
-Target | Default Profile | `--release` Profile
--------|-----------------|---------------------
-lib, bin, example | `dev` | `release`
-test, bench, or any target in "test" or "bench" mode | `test` | `bench`
-
-Dependencies use the `dev`/`release` profiles.
-
-
 ## ENVIRONMENT
 
 See [the reference](../reference/environment-variables.html) for
index 33d6dc0e9363c5a1a12285348cdb9eab4471cc9a..ba32e8bfdfa31299f5f7d8019d1409596dcc80bc 100644 (file)
@@ -41,7 +41,11 @@ the target directory.</dd>
 
 
 <dt class="option-term" id="option-cargo-clean---release"><a class="option-anchor" href="#option-cargo-clean---release"></a><code>--release</code></dt>
-<dd class="option-desc">Clean all artifacts that were built with the <code>release</code> or <code>bench</code> profiles.</dd>
+<dd class="option-desc">Remove all artifacts in the <code>release</code> directory.</dd>
+
+
+<dt class="option-term" id="option-cargo-clean---profile"><a class="option-anchor" href="#option-cargo-clean---profile"></a><code>--profile</code> <em>name</em></dt>
+<dd class="option-desc">Remove all artifacts in the directory with the given profile name.</dd>
 
 
 <dt class="option-term" id="option-cargo-clean---target-dir"><a class="option-anchor" href="#option-cargo-clean---target-dir"></a><code>--target-dir</code> <em>directory</em></dt>
index 774169816c9e11f005ce7f70637f51b03e23b049..51f37dedd74baf28f059ac4d0b79957f11d0a5df 100644 (file)
@@ -165,9 +165,14 @@ target artifacts are placed in a separate directory. See the
 
 
 <dt class="option-term" id="option-cargo-doc---release"><a class="option-anchor" href="#option-cargo-doc---release"></a><code>--release</code></dt>
-<dd class="option-desc">Document optimized artifacts with the <code>release</code> profile. See the
-<a href="#profiles">PROFILES</a> section for details on how this affects profile
-selection.</dd>
+<dd class="option-desc">Document optimized artifacts with the <code>release</code> profile.
+See also the <code>--profile</code> option for choosing a specific profile by name.</dd>
+
+
+
+<dt class="option-term" id="option-cargo-doc---profile"><a class="option-anchor" href="#option-cargo-doc---profile"></a><code>--profile</code> <em>name</em></dt>
+<dd class="option-desc">Document with the given profile.
+See the <a href="../reference/profiles.html">the reference</a> for more details on profiles.</dd>
 
 
 
@@ -316,24 +321,6 @@ the number of CPUs.</dd>
 
 </dl>
 
-## PROFILES
-
-Profiles may be used to configure compiler options such as optimization levels
-and debug settings. See [the reference](../reference/profiles.html) for more
-details.
-
-Profile selection depends on the target and crate being built. By default the
-`dev` or `test` profiles are used. If the `--release` flag is given, then the
-`release` or `bench` profiles are used.
-
-Target | Default Profile | `--release` Profile
--------|-----------------|---------------------
-lib, bin, example | `dev` | `release`
-test, bench, or any target in "test" or "bench" mode | `test` | `bench`
-
-Dependencies use the `dev`/`release` profiles.
-
-
 ## ENVIRONMENT
 
 See [the reference](../reference/environment-variables.html) for
index 534520188d3a389bcd388ee9f3d6aeaf6fb0a81a..100da109e7ec4b8cc73789b60af410224a66ed7b 100644 (file)
@@ -267,18 +267,18 @@ target artifacts are placed in a separate directory. See the
 
 
 <dt class="option-term" id="option-cargo-fix---release"><a class="option-anchor" href="#option-cargo-fix---release"></a><code>--release</code></dt>
-<dd class="option-desc">Fix optimized artifacts with the <code>release</code> profile. See the
-<a href="#profiles">PROFILES</a> section for details on how this affects profile
-selection.</dd>
+<dd class="option-desc">Fix optimized artifacts with the <code>release</code> profile.
+See also the <code>--profile</code> option for choosing a specific profile by name.</dd>
 
 
 
 <dt class="option-term" id="option-cargo-fix---profile"><a class="option-anchor" href="#option-cargo-fix---profile"></a><code>--profile</code> <em>name</em></dt>
-<dd class="option-desc">Changes fix behavior. Currently only <code>test</code> is supported,
-which will fix with the <code>#[cfg(test)]</code> attribute enabled.
-This is useful to have it fix unit tests which are usually
-excluded via the <code>cfg</code> attribute. This does not change the actual profile
-used.</dd>
+<dd class="option-desc">Fix with the given profile.</p>
+<p>As a special case, specifying the <code>test</code> profile will also enable checking in
+test mode which will enable checking tests and enable the <code>test</code> cfg option.
+See <a href="https://doc.rust-lang.org/rustc/tests/index.html">rustc tests</a> for more
+detail.</p>
+<p>See the <a href="../reference/profiles.html">the reference</a> for more details on profiles.</dd>
 
 
 
@@ -427,24 +427,6 @@ the number of CPUs.</dd>
 
 </dl>
 
-## PROFILES
-
-Profiles may be used to configure compiler options such as optimization levels
-and debug settings. See [the reference](../reference/profiles.html) for more
-details.
-
-Profile selection depends on the target and crate being built. By default the
-`dev` or `test` profiles are used. If the `--release` flag is given, then the
-`release` or `bench` profiles are used.
-
-Target | Default Profile | `--release` Profile
--------|-----------------|---------------------
-lib, bin, example | `dev` | `release`
-test, bench, or any target in "test" or "bench" mode | `test` | `bench`
-
-Dependencies use the `dev`/`release` profiles.
-
-
 ## ENVIRONMENT
 
 See [the reference](../reference/environment-variables.html) for
index 1639b28cb6ee481c0beee3f4abdd38e6529abd0f..acb98dbb79ce9b7dc6f21569118273867de5a8c2 100644 (file)
@@ -49,7 +49,7 @@ change, then Cargo will reinstall the package:
 - The package version and source.
 - The set of binary names installed.
 - The chosen features.
-- The release mode (`--debug`).
+- The profile (`--profile`).
 - The target (`--target`).
 
 Installing with `--path` will always build and install, unless there are
@@ -226,7 +226,14 @@ is specified.</dd>
 
 
 <dt class="option-term" id="option-cargo-install---debug"><a class="option-anchor" href="#option-cargo-install---debug"></a><code>--debug</code></dt>
-<dd class="option-desc">Build with the <code>dev</code> profile instead the <code>release</code> profile.</dd>
+<dd class="option-desc">Build with the <code>dev</code> profile instead the <code>release</code> profile.
+See also the <code>--profile</code> option for choosing a specific profile by name.</dd>
+
+
+<dt class="option-term" id="option-cargo-install---profile"><a class="option-anchor" href="#option-cargo-install---profile"></a><code>--profile</code> <em>name</em></dt>
+<dd class="option-desc">Install with the given profile.
+See the <a href="../reference/profiles.html">the reference</a> for more details on profiles.</dd>
+
 
 
 </dl>
index d7cf9ec5fb9cf805ed1f659afa50a2852a02a368..79c51ab19c257ba048c1e18af5e1e0bfc955845b 100644 (file)
@@ -100,9 +100,14 @@ target artifacts are placed in a separate directory. See the
 
 
 <dt class="option-term" id="option-cargo-run---release"><a class="option-anchor" href="#option-cargo-run---release"></a><code>--release</code></dt>
-<dd class="option-desc">Run optimized artifacts with the <code>release</code> profile. See the
-<a href="#profiles">PROFILES</a> section for details on how this affects profile
-selection.</dd>
+<dd class="option-desc">Run optimized artifacts with the <code>release</code> profile.
+See also the <code>--profile</code> option for choosing a specific profile by name.</dd>
+
+
+
+<dt class="option-term" id="option-cargo-run---profile"><a class="option-anchor" href="#option-cargo-run---profile"></a><code>--profile</code> <em>name</em></dt>
+<dd class="option-desc">Run with the given profile.
+See the <a href="../reference/profiles.html">the reference</a> for more details on profiles.</dd>
 
 
 
@@ -255,24 +260,6 @@ the number of CPUs.</dd>
 
 </dl>
 
-## PROFILES
-
-Profiles may be used to configure compiler options such as optimization levels
-and debug settings. See [the reference](../reference/profiles.html) for more
-details.
-
-Profile selection depends on the target and crate being built. By default the
-`dev` or `test` profiles are used. If the `--release` flag is given, then the
-`release` or `bench` profiles are used.
-
-Target | Default Profile | `--release` Profile
--------|-----------------|---------------------
-lib, bin, example | `dev` | `release`
-test, bench, or any target in "test" or "bench" mode | `test` | `bench`
-
-Dependencies use the `dev`/`release` profiles.
-
-
 ## ENVIRONMENT
 
 See [the reference](../reference/environment-variables.html) for
index 65dbeee3fffc7001ce5f5477e6531036bcfb3154..99b780d14af0fd8f946a3904fc31e60a41ffb582 100644 (file)
@@ -169,12 +169,27 @@ target artifacts are placed in a separate directory. See the
 
 
 <dt class="option-term" id="option-cargo-rustc---release"><a class="option-anchor" href="#option-cargo-rustc---release"></a><code>--release</code></dt>
-<dd class="option-desc">Build optimized artifacts with the <code>release</code> profile. See the
-<a href="#profiles">PROFILES</a> section for details on how this affects profile
-selection.</dd>
+<dd class="option-desc">Build optimized artifacts with the <code>release</code> profile.
+See also the <code>--profile</code> option for choosing a specific profile by name.</dd>
 
 
 
+<dt class="option-term" id="option-cargo-rustc---profile"><a class="option-anchor" href="#option-cargo-rustc---profile"></a><code>--profile</code> <em>name</em></dt>
+<dd class="option-desc">Build with the given profile.</p>
+<p>The <code>rustc</code> subcommand will treat the following named profiles with special behaviors:</p>
+<ul>
+<li><code>check</code> â€” Builds in the same way as the <a href="cargo-check.html">cargo-check(1)</a> command with
+the <code>dev</code> profile.</li>
+<li><code>test</code> â€” Builds in the same way as the <a href="cargo-test.html">cargo-test(1)</a> command,
+enabling building in test mode which will enable tests and enable the <code>test</code>
+cfg option. See <a href="https://doc.rust-lang.org/rustc/tests/index.html">rustc
+tests</a> for more detail.</li>
+<li><code>bench</code> â€” Builds in the same was as the <a href="cargo-bench.html">cargo-bench(1)</a> command,
+similar to the <code>test</code> profile.</li>
+</ul>
+<p>See the <a href="../reference/profiles.html">the reference</a> for more details on profiles.</dd>
+
+
 <dt class="option-term" id="option-cargo-rustc---ignore-rust-version"><a class="option-anchor" href="#option-cargo-rustc---ignore-rust-version"></a><code>--ignore-rust-version</code></dt>
 <dd class="option-desc">Build the target even if the selected Rust compiler is older than the
 required Rust version as configured in the project's <code>rust-version</code> field.</dd>
@@ -324,24 +339,6 @@ the number of CPUs.</dd>
 
 </dl>
 
-## PROFILES
-
-Profiles may be used to configure compiler options such as optimization levels
-and debug settings. See [the reference](../reference/profiles.html) for more
-details.
-
-Profile selection depends on the target and crate being built. By default the
-`dev` or `test` profiles are used. If the `--release` flag is given, then the
-`release` or `bench` profiles are used.
-
-Target | Default Profile | `--release` Profile
--------|-----------------|---------------------
-lib, bin, example | `dev` | `release`
-test, bench, or any target in "test" or "bench" mode | `test` | `bench`
-
-Dependencies use the `dev`/`release` profiles.
-
-
 ## ENVIRONMENT
 
 See [the reference](../reference/environment-variables.html) for
index 96de095f821b6cad6a70c0f9f836463584a9ad7a..a7847f1ed7c2446534c5e9cf70c35aee179cc85b 100644 (file)
@@ -184,9 +184,14 @@ target artifacts are placed in a separate directory. See the
 
 
 <dt class="option-term" id="option-cargo-rustdoc---release"><a class="option-anchor" href="#option-cargo-rustdoc---release"></a><code>--release</code></dt>
-<dd class="option-desc">Document optimized artifacts with the <code>release</code> profile. See the
-<a href="#profiles">PROFILES</a> section for details on how this affects profile
-selection.</dd>
+<dd class="option-desc">Document optimized artifacts with the <code>release</code> profile.
+See also the <code>--profile</code> option for choosing a specific profile by name.</dd>
+
+
+
+<dt class="option-term" id="option-cargo-rustdoc---profile"><a class="option-anchor" href="#option-cargo-rustdoc---profile"></a><code>--profile</code> <em>name</em></dt>
+<dd class="option-desc">Document with the given profile.
+See the <a href="../reference/profiles.html">the reference</a> for more details on profiles.</dd>
 
 
 
@@ -335,24 +340,6 @@ the number of CPUs.</dd>
 
 </dl>
 
-## PROFILES
-
-Profiles may be used to configure compiler options such as optimization levels
-and debug settings. See [the reference](../reference/profiles.html) for more
-details.
-
-Profile selection depends on the target and crate being built. By default the
-`dev` or `test` profiles are used. If the `--release` flag is given, then the
-`release` or `bench` profiles are used.
-
-Target | Default Profile | `--release` Profile
--------|-----------------|---------------------
-lib, bin, example | `dev` | `release`
-test, bench, or any target in "test" or "bench" mode | `test` | `bench`
-
-Dependencies use the `dev`/`release` profiles.
-
-
 ## ENVIRONMENT
 
 See [the reference](../reference/environment-variables.html) for
index e2daf71f6813f3bbed68bc81271e30030b7ade35..1eef72fc2d0bfd87d9eff960b47b23d86ba51a74 100644 (file)
@@ -263,9 +263,14 @@ target artifacts are placed in a separate directory. See the
 
 
 <dt class="option-term" id="option-cargo-test---release"><a class="option-anchor" href="#option-cargo-test---release"></a><code>--release</code></dt>
-<dd class="option-desc">Test optimized artifacts with the <code>release</code> profile. See the
-<a href="#profiles">PROFILES</a> section for details on how this affects profile
-selection.</dd>
+<dd class="option-desc">Test optimized artifacts with the <code>release</code> profile.
+See also the <code>--profile</code> option for choosing a specific profile by name.</dd>
+
+
+
+<dt class="option-term" id="option-cargo-test---profile"><a class="option-anchor" href="#option-cargo-test---profile"></a><code>--profile</code> <em>name</em></dt>
+<dd class="option-desc">Test with the given profile.
+See the <a href="../reference/profiles.html">the reference</a> for more details on profiles.</dd>
 
 
 
@@ -432,32 +437,6 @@ the number of CPUs.</dd>
 
 </dl>
 
-## PROFILES
-
-Profiles may be used to configure compiler options such as optimization levels
-and debug settings. See [the reference](../reference/profiles.html) for more
-details.
-
-Profile selection depends on the target and crate being built. By default the
-`dev` or `test` profiles are used. If the `--release` flag is given, then the
-`release` or `bench` profiles are used.
-
-Target | Default Profile | `--release` Profile
--------|-----------------|---------------------
-lib, bin, example | `dev` | `release`
-test, bench, or any target in "test" or "bench" mode | `test` | `bench`
-
-Dependencies use the `dev`/`release` profiles.
-
-
-Unit tests are separate executable artifacts which use the `test`/`bench`
-profiles. Example targets are built the same as with `cargo build` (using the
-`dev`/`release` profiles) unless you are building them with the test harness
-(by setting `test = true` in the manifest or using the `--example` flag) in
-which case they use the `test`/`bench` profiles. Library targets are built
-with the `dev`/`release` profiles when linked to an integration test, binary,
-or doctest.
-
 ## ENVIRONMENT
 
 See [the reference](../reference/environment-variables.html) for
index 18bb2df0b7a80f6d172037ebe987fc1be8a18d4a..a8453f615fbdd3456624ef0ce337ad51488296b1 100644 (file)
@@ -9,21 +9,27 @@ value, or the `--target-dir` command-line flag.
 The directory layout depends on whether or not you are using the `--target`
 flag to build for a specific platform. If `--target` is not specified, Cargo
 runs in a mode where it builds for the host architecture. The output goes into
-the root of the target directory, separated based on whether or not it is a
-release build:
+the root of the target directory, with each [profile] stored in a separate
+subdirectory:
 
 Directory | Description
 ----------|------------
-<code style="white-space: nowrap">target/debug/</code> | Contains debug build output.
-<code style="white-space: nowrap">target/release/</code> | Contains release build output (with `--release` flag).
+<code style="white-space: nowrap">target/debug/</code> | Contains output for the `dev` profile.
+<code style="white-space: nowrap">target/release/</code> | Contains output for the `release` profile (with the `--release` option).
+<code style="white-space: nowrap">target/foo/</code> | Contains build output for the `foo` profile (with the `--profile=foo` option).
+
+For historical reasons, the `dev` and `test` profiles are stored in the
+`debug` directory, and the `release` and `bench` profiles are stored in the
+`release` directory. User-defined profiles are stored in a directory with the
+same name as the profile.
 
 When building for another target with `--target`, the output is placed in a
 directory with the name of the target:
 
 Directory | Example
 ----------|--------
-<code style="white-space: nowrap">target/&lt;triple&gt;/debug/</code> | <code style="white-space: nowrap">target/thumbv7em-none-eabihf/debug/</code>
-<code style="white-space: nowrap">target/&lt;triple&gt;/release/</code> | <code style="white-space: nowrap">target/thumbv7em-none-eabihf/release/</code>
+<code style="white-space: nowrap">target/&lt;triple&gt;/debug/</code> | <code style="white-space: nowrap">target/thumbv7em-none-eabihf/debug/</code>
+<code style="white-space: nowrap">target/&lt;triple&gt;/release/</code> | <code style="white-space: nowrap">target/thumbv7em-none-eabihf/release/</code>
 
 > **Note**: When not using `--target`, this has a consequence that Cargo will
 > share your dependencies with build scripts and proc macros. [`RUSTFLAGS`]
@@ -31,13 +37,13 @@ Directory | Example
 > build scripts and proc macros are built separately (for the host
 > architecture), and do not share `RUSTFLAGS`.
 
-Within the profile directory (`debug` or `release`), artifacts are placed into
-the following directories:
+Within the profile directory (such as `debug` or `release`), artifacts are
+placed into the following directories:
 
 Directory | Description
 ----------|------------
-<code style="white-space: nowrap">target/debug/</code> | Contains the output of the package being built (the `[[bin]]` executables and `[lib]` library targets).
-<code style="white-space: nowrap">target/debug/examples/</code> | Contains examples (`[[example]]` targets).
+<code style="white-space: nowrap">target/debug/</code> | Contains the output of the package being built (the [binary executables] and [library targets]).
+<code style="white-space: nowrap">target/debug/examples/</code> | Contains [example targets].
 
 Some commands place their output in dedicated directories in the top level of
 the `target` directory:
@@ -53,9 +59,9 @@ change. Some of these directories are:
 
 Directory | Description
 ----------|------------
-<code style="white-space: nowrap">target/debug/deps/</code> | Â Dependencies and other artifacts.
-<code style="white-space: nowrap">target/debug/incremental/</code> | Â `rustc` [incremental output], a cache used to speed up subsequent builds.
-<code style="white-space: nowrap">target/debug/build/</code> | Â Output from [build scripts].
+<code style="white-space: nowrap">target/debug/deps/</code> | Dependencies and other artifacts.
+<code style="white-space: nowrap">target/debug/incremental/</code> | `rustc` [incremental output], a cache used to speed up subsequent builds.
+<code style="white-space: nowrap">target/debug/build/</code> | Output from [build scripts].
 
 ### Dep-info files
 
@@ -95,3 +101,7 @@ configuration][config]. Refer to sccache documentation for more details.
 [environment variable]: ../reference/environment-variables.md
 [incremental output]: ../reference/profiles.md#incremental
 [sccache]: https://github.com/mozilla/sccache
+[profile]: ../reference/profiles.md
+[binary executables]: ../reference/cargo-targets.md#binaries
+[library targets]: ../reference/cargo-targets.md#library
+[example targets]: ../reference/cargo-targets.md#examples
diff --git a/src/doc/src/images/profile-selection.svg b/src/doc/src/images/profile-selection.svg
deleted file mode 100644 (file)
index 4975383..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-<svg xmlns="http://www.w3.org/2000/svg" style="background-color: rgb(255, 255, 255);" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="445px" height="277px" viewBox="-0.5 -0.5 445 277"><defs/><g><rect x="170" y="91" width="100" height="40" rx="6" ry="6" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(190.5,97.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="59" height="27" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 60px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">lib<br />profile: dev</div></div></foreignObject><text x="30" y="20" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">lib&lt;br&gt;profile: dev</text></switch></g><rect x="330" y="191" width="100" height="40" rx="6" ry="6" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/><g transform="translate(347.5,197.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="65" height="27" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 66px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">lib (unit test)<br />profile: test</div></div></foreignObject><text x="33" y="20" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><rect x="10" y="41" width="100" height="40" rx="6" ry="6" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(23.5,47.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="72" height="27" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 73px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;"><div>dependency1<br /></div>profile: dev</div></div></foreignObject><text x="36" y="20" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><rect x="330" y="91" width="100" height="40" rx="6" ry="6" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/><g transform="translate(340.5,97.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="79" height="27" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 80px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">integration test<br />profile: test</div></div></foreignObject><text x="40" y="20" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><rect x="330" y="141" width="100" height="40" rx="6" ry="6" fill="#dae8fc" stroke="#6c8ebf" pointer-events="all"/><g transform="translate(345.5,147.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="69" height="27" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 70px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">bin (unit test)<br />profile: test</div></div></foreignObject><text x="35" y="20" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><rect x="330" y="41" width="100" height="40" rx="6" ry="6" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(337.5,47.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="85" height="27" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 86px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">bin (executable)<br />profile: dev</div></div></foreignObject><text x="43" y="20" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">bin (executable)&lt;br&gt;profile: dev</text></switch></g><rect x="10" y="91" width="100" height="40" rx="6" ry="6" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(23.5,97.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="72" height="27" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 73px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;"><div>dependency2<br /></div>profile: dev</div></div></foreignObject><text x="36" y="20" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><rect x="10" y="141" width="100" height="40" rx="6" ry="6" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(23.5,147.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="72" height="27" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 73px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;"><div>dependency3<br /></div>profile: dev</div></div></foreignObject><text x="36" y="20" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">[Not supported by viewer]</text></switch></g><path d="M 110 61 L 120 61 Q 130 61 130 71 L 130 101 Q 130 111 140 111 L 163.63 111" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 168.88 111 L 161.88 114.5 L 163.63 111 L 161.88 107.5 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><path d="M 110 111 L 163.63 111" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 168.88 111 L 161.88 114.5 L 163.63 111 L 161.88 107.5 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><path d="M 110 161 L 120 161 Q 130 161 130 151 L 130 121 Q 130 111 140 111 L 163.63 111" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 168.88 111 L 161.88 114.5 L 163.63 111 L 161.88 107.5 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><path d="M 270 111 L 290 111 Q 300 111 300 101 L 300 71 Q 300 61 310 61 L 323.63 61" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 328.88 61 L 321.88 64.5 L 323.63 61 L 321.88 57.5 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><path d="M 270 111 L 323.63 111" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 328.88 111 L 321.88 114.5 L 323.63 111 L 321.88 107.5 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><path d="M 270 111 L 290 111 Q 300 111 300 121 L 300 151 Q 300 161 310 161 L 323.63 161" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 328.88 161 L 321.88 164.5 L 323.63 161 L 321.88 157.5 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><rect x="360" y="11" width="40" height="20" fill="none" stroke="none" pointer-events="all"/><g transform="translate(325.5,9.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="109" height="22" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 20px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 110px; white-space: nowrap; overflow-wrap: normal; text-decoration: underline; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;"><div style="font-size: 20px">Executables</div></div></div></foreignObject><text x="55" y="21" fill="#000000" text-anchor="middle" font-size="20px" font-family="Helvetica" text-decoration="underline">[Not supported by viewer]</text></switch></g><rect x="22.5" y="241" width="395" height="25.48" fill="none" stroke="none" pointer-events="all"/><g transform="translate(71.5,242.5)"><switch><foreignObject style="overflow:visible;" pointer-events="all" width="296" height="22" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 20px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 297px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">Profile selection for <font face="Courier New">cargo test</font></div></div></foreignObject><text x="148" y="21" fill="#000000" text-anchor="middle" font-size="20px" font-family="Helvetica">Profile selection for &lt;font face="Courier New"&gt;cargo test&lt;/font&gt;</text></switch></g><path d="M 150 114 L 150 201 Q 150 211 160 211 L 323.63 211" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><ellipse cx="150" cy="111" rx="3" ry="3" fill="#000000" stroke="#000000" pointer-events="all"/><path d="M 328.88 211 L 321.88 214.5 L 323.63 211 L 321.88 207.5 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/></g></svg>
\ No newline at end of file
index 72f035d68e085ac1b11573ae4d9f8cdc7cceb804..b0a2bb34d63297e004f58d1ae8247ad012d4131e 100644 (file)
@@ -333,7 +333,11 @@ let out_dir = env::var("OUT_DIR").unwrap();
                compatible [jobserver] for sub-make invocations.
 * `OPT_LEVEL`, `DEBUG` â€” values of the corresponding variables for the
                          profile currently being built.
-* `PROFILE` â€” `release` for release builds, `debug` for other builds.
+* `PROFILE` â€” `release` for release builds, `debug` for other builds. This is
+  determined based on if the [profile] inherits from the [`dev`] or
+  [`release`] profile. Using this environment variable is not recommended.
+  Using other environment variables like `OPT_LEVEL` provide a more correct
+  view of the actual settings being used.
 * `DEP_<name>_<key>` â€” For more information about this set of environment
                        variables, see build script documentation about [`links`][links].
 * `RUSTC`, `RUSTDOC` â€” the compiler and documentation generator that Cargo has
@@ -371,6 +375,9 @@ let out_dir = env::var("OUT_DIR").unwrap();
 [cargo-config]: config.md
 [Target Triple]: ../appendix/glossary.md#target
 [variables set for crates]: #environment-variables-cargo-sets-for-crates
+[profile]: profiles.md
+[`dev`]: profiles.md#dev
+[`release`]: profiles.md#release
 
 ### Environment variables Cargo sets for 3rd party subcommands
 
index 1f4248a15332242259b98990f110d4729378d857..1732c491e72039f905dabc53bf61addb85328998 100644 (file)
@@ -3,10 +3,10 @@
 Profiles provide a way to alter the compiler settings, influencing things like
 optimizations and debugging symbols.
 
-Cargo has 4 built-in profiles: `dev`, `release`, `test`, and `bench`. It
-automatically chooses the profile based on which command is being run, the
-package and target that is being built, and command-line flags like
-`--release`. The selection process is [described below](#profile-selection).
+Cargo has 4 built-in profiles: `dev`, `release`, `test`, and `bench`. The
+profile is automatically chosen based on which command is being run if a
+profile is not specified on the command-line. In addition to the built-in
+profiles, custom user-defined profiles can also be specified.
 
 Profile settings can be changed in [`Cargo.toml`](manifest.md) with the
 `[profile]` table. Within each named profile, individual settings can be changed
@@ -267,44 +267,14 @@ rpath = false
 #### test
 
 The `test` profile is used for building tests, or when benchmarks are built in
-debug mode with `cargo build`.
-
-The default settings for the `test` profile are:
-
-```toml
-[profile.test]
-opt-level = 0
-debug = 2
-split-debuginfo = '...'  # Platform-specific.
-debug-assertions = true
-overflow-checks = true
-lto = false
-panic = 'unwind'    # This setting is always ignored.
-incremental = true
-codegen-units = 256
-rpath = false
-```
+debug mode with `cargo build`. By default, the `test` profile inherits the
+settings from the [`dev`](#dev) profile.
 
 #### bench
 
 The `bench` profile is used for building benchmarks, or when tests are built
-with the `--release` flag.
-
-The default settings for the `bench` profile are:
-
-```toml
-[profile.bench]
-opt-level = 3
-debug = false
-split-debuginfo = '...'  # Platform-specific.
-debug-assertions = false
-overflow-checks = false
-lto = false
-panic = 'unwind'    # This setting is always ignored.
-incremental = false
-codegen-units = 16
-rpath = false
-```
+with the `--release` flag. By default, the `bench` profile inherits the
+settings from the [`release`](#release) profile.
 
 #### Build Dependencies
 
@@ -325,35 +295,50 @@ codegen-units = 256
 Build dependencies otherwise inherit settings from the active profile in use, as
 described below.
 
-### Profile selection
+### Custom profiles
+
+In addition to the built-in profiles, additional custom profiles can be
+defined. These may be useful for setting up multiple workflows and build
+modes. When defining a custom profile, you must specify the `inherits` key to
+specify which profile the custom profile inherits settings from when the
+setting is not specified.
+
+For example, let's say you want to compare a normal release build with a
+release build with [LTO](#lto) optimizations, you can specify something like
+the following in `Cargo.toml`:
+
+```toml
+[profile.release-lto]
+inherits = "release"
+lto = true
+```
 
-The profile used depends on the command, the package, the Cargo target, and
-command-line flags like `--release`.
+The `--profile` flag can then be used to choose this custom profile:
 
-Build commands like [`cargo build`], [`cargo rustc`], [`cargo check`], and
-[`cargo run`] default to using the `dev` profile. The `--release` flag may be
-used to switch to the `release` profile.
+```console
+cargo build --profile release-lto
+```
 
-The [`cargo install`] command defaults to the `release` profile, and may use
-the `--debug` flag to switch to the `dev` profile.
+The output for each profile will be placed in a directory of the same name
+as the profile in the [`target` directory]. As in the example above, the
+output would go into the `target/release-lto` directory.
 
-Test targets are built with the `test` profile by default. The `--release`
-flag switches tests to the `bench` profile.
+[`target` directory]: ../guide/build-cache.md
 
-Bench targets are built with the `bench` profile by default. The [`cargo
-build`] command can be used to build a bench target with the `test` profile to
-enable debugging.
+### Profile selection
 
-Note that when using the [`cargo test`] and [`cargo bench`] commands, the
-`test`/`bench` profiles only apply to the final test executable. Dependencies
-will continue to use the `dev`/`release` profiles. Also note that when a
-library is built for unit tests, then the library is built with the `test`
-profile. However, when building an integration test target, the library target
-is built with the `dev` profile and linked into the integration test
-executable.
+The profile used depends on the command, the command-line flags like
+`--release` or `--profile`, and the package (in the case of
+[overrides](#overrides)). The default profile if none is specified is:
 
-![Profile selection for cargo test](../images/profile-selection.svg)
+* Build commands like [`cargo build`], [`cargo rustc`], [`cargo check`], and
+[`cargo run`]: [`dev` profile](#dev)
+* [`cargo test`]: [`test` profile](#test)
+* [`cargo bench`]: [`bench` profile](#bench)
+* [`cargo install`]: [`release` profile](#release)
 
+The profile for specific packages can be specified with
+[overrides](#overrides), described below.
 
 [`cargo bench`]: ../commands/cargo-bench.md
 [`cargo build`]: ../commands/cargo-build.md
index c27b00855822ff897ad4592029900f4a577434af..ae550d7e5c2760ed9ef923ab429aa0831daa71b1 100644 (file)
@@ -87,7 +87,6 @@ Each new feature described below should explain how to use it.
     * [`doctest-in-workspace`](#doctest-in-workspace) â€” Fixes workspace-relative paths when running doctests.
     * [rustdoc-map](#rustdoc-map) â€” Provides mappings for documentation to link to external sites like [docs.rs](https://docs.rs/).
 * `Cargo.toml` extensions
-    * [Custom named profiles](#custom-named-profiles) â€” Adds custom named profiles in addition to the standard names.
     * [Profile `strip` option](#profile-strip-option) â€” Forces the removal of debug information and symbols from executables.
     * [per-package-target](#per-package-target) â€” Sets the `--target` to use for each individual package.
 * Information and metadata
@@ -238,49 +237,6 @@ or running tests for both targets:
 cargo test --target x86_64-unknown-linux-gnu --target i686-unknown-linux-gnu
 ```
 
-### Custom named profiles
-
-* Tracking Issue: [rust-lang/cargo#6988](https://github.com/rust-lang/cargo/issues/6988)
-* RFC: [#2678](https://github.com/rust-lang/rfcs/pull/2678)
-
-With this feature you can define custom profiles having new names. With the
-custom profile enabled, build artifacts can be emitted by default to
-directories other than `release` or `debug`, based on the custom profile's
-name.
-
-For example:
-
-```toml
-cargo-features = ["named-profiles"]
-
-[profile.release-lto]
-inherits = "release"
-lto = true
-````
-
-An `inherits` key is used in order to receive attributes from other profiles,
-so that a new custom profile can be based on the standard `dev` or `release`
-profile presets. Cargo emits errors in case `inherits` loops are detected. When
-considering inheritance hierarchy, all profiles directly or indirectly inherit
-from either from `release` or from `dev`.
-
-Valid profile names are: must not be empty, use only alphanumeric characters or
-`-` or `_`.
-
-Passing `--profile` with the profile's name to various Cargo commands, directs
-operations to use the profile's attributes. Overrides that are specified in the
-profiles from which the custom profile inherits are inherited too.
-
-For example, using `cargo build` with `--profile` and the manifest from above:
-
-```sh
-cargo +nightly build --profile release-lto -Z unstable-options
-```
-
-When a custom profile is used, build artifacts go to a different target by
-default. In the example above, you can expect to see the outputs under
-`target/release-lto`.
-
 
 #### New `dir-name` attribute
 
@@ -1421,3 +1377,8 @@ information.
 The 2021 edition has been stabilized in the 1.56 release.
 See the [`edition` field](manifest.md#the-edition-field) for more information on setting the edition.
 See [`cargo fix --edition`](../commands/cargo-fix.md) and [The Edition Guide](../../edition-guide/index.html) for more information on migrating existing projects.
+
+### Custom named profiles
+
+Custom named profiles have been stabilized in the 1.57 release. See the
+[profiles chapter](profiles.md#custom-profiles) for more information.
index a8239d002d963922d4862fbca6c7128b41835302..5d8df036bfbd87ce2772211fd8281bcb3c4dff30 100644 (file)
@@ -50,6 +50,12 @@ running benchmarks on the stable channel, such as
 .br
 .RE
 .ll
+.sp
+By default, \fBcargo bench\fR uses the \fI\f(BIbench\fI profile\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html#bench>, which enables
+optimizations and disables debugging information. If you need to debug a
+benchmark, you can use the \fB\-\-profile=dev\fR command\-line option to switch to
+the dev profile. You can then run the debug\-enabled benchmark within a
+debugger.
 .SH "OPTIONS"
 .SS "Benchmark Options"
 .sp
@@ -251,6 +257,12 @@ target artifacts are placed in a separate directory. See the
 \fIbuild cache\fR <https://doc.rust\-lang.org/cargo/guide/build\-cache.html> documentation for more details.
 .RE
 .sp
+\fB\-\-profile\fR \fIname\fR
+.RS 4
+Benchmark with the given profile.
+See the \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more details on profiles.
+.RE
+.sp
 \fB\-\-ignore\-rust\-version\fR
 .RS 4
 Benchmark the target even if the selected Rust compiler is older than the
@@ -420,21 +432,6 @@ Number of parallel jobs to run. May also be specified with the
 \fBbuild.jobs\fR \fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&. Defaults to
 the number of CPUs.
 .RE
-.SH "PROFILES"
-Profiles may be used to configure compiler options such as optimization levels
-and debug settings. See
-\fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html>
-for more details.
-.sp
-Benchmarks are always built with the \fBbench\fR profile. Binary and lib targets
-are built separately as benchmarks with the \fBbench\fR profile. Library targets
-are built with the \fBrelease\fR profiles when linked to binaries and benchmarks.
-Dependencies use the \fBrelease\fR profile.
-.sp
-If you need a debug build of a benchmark, try building it with
-\fBcargo\-build\fR(1) which will use the \fBtest\fR profile which is by default
-unoptimized and includes debug information. You can then run the debug\-enabled
-benchmark manually.
 .SH "ENVIRONMENT"
 See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/environment\-variables.html> for
 details on environment variables that Cargo reads.
index 4eaea1bc5a72446259ca32c992c8383ddf355a94..bdee1436b9432639138591705acae457d3255672 100644 (file)
@@ -171,9 +171,14 @@ target artifacts are placed in a separate directory. See the
 .sp
 \fB\-\-release\fR
 .RS 4
-Build optimized artifacts with the \fBrelease\fR profile. See the
-PROFILES section for details on how this affects profile
-selection.
+Build optimized artifacts with the \fBrelease\fR profile.
+See also the \fB\-\-profile\fR option for choosing a specific profile by name.
+.RE
+.sp
+\fB\-\-profile\fR \fIname\fR
+.RS 4
+Build with the given profile.
+See the \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more details on profiles.
 .RE
 .sp
 \fB\-\-ignore\-rust\-version\fR
@@ -354,43 +359,6 @@ Number of parallel jobs to run. May also be specified with the
 \fBbuild.jobs\fR \fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&. Defaults to
 the number of CPUs.
 .RE
-.SH "PROFILES"
-Profiles may be used to configure compiler options such as optimization levels
-and debug settings. See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more
-details.
-.sp
-Profile selection depends on the target and crate being built. By default the
-\fBdev\fR or \fBtest\fR profiles are used. If the \fB\-\-release\fR flag is given, then the
-\fBrelease\fR or \fBbench\fR profiles are used.
-
-.TS
-allbox tab(:);
-lt lt lt.
-T{
-Target
-T}:T{
-Default Profile
-T}:T{
-\fB\-\-release\fR Profile
-T}
-T{
-lib, bin, example
-T}:T{
-\fBdev\fR
-T}:T{
-\fBrelease\fR
-T}
-T{
-test, bench, or any target in "test" or "bench" mode
-T}:T{
-\fBtest\fR
-T}:T{
-\fBbench\fR
-T}
-.TE
-.sp
-.sp
-Dependencies use the \fBdev\fR/\fBrelease\fR profiles.
 .SH "ENVIRONMENT"
 See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/environment\-variables.html> for
 details on environment variables that Cargo reads.
index 7c6b2ea17d23ceefd705c8308ed9321d7cae3ed3..a1456e9832e1d1720bcfb51f0a4791520f781765 100644 (file)
@@ -176,18 +176,20 @@ target artifacts are placed in a separate directory. See the
 .sp
 \fB\-\-release\fR
 .RS 4
-Check optimized artifacts with the \fBrelease\fR profile. See the
-PROFILES section for details on how this affects profile
-selection.
+Check optimized artifacts with the \fBrelease\fR profile.
+See also the \fB\-\-profile\fR option for choosing a specific profile by name.
 .RE
 .sp
 \fB\-\-profile\fR \fIname\fR
 .RS 4
-Changes check behavior. Currently only \fBtest\fR is supported,
-which will check with the \fB#[cfg(test)]\fR attribute enabled.
-This is useful to have it check unit tests which are usually
-excluded via the \fBcfg\fR attribute. This does not change the actual profile
-used.
+Check with the given profile.
+.sp
+As a special case, specifying the \fBtest\fR profile will also enable checking in
+test mode which will enable checking tests and enable the \fBtest\fR cfg option.
+See \fIrustc tests\fR <https://doc.rust\-lang.org/rustc/tests/index.html> for more
+detail.
+.sp
+See the \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more details on profiles.
 .RE
 .sp
 \fB\-\-ignore\-rust\-version\fR
@@ -347,43 +349,6 @@ Number of parallel jobs to run. May also be specified with the
 \fBbuild.jobs\fR \fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&. Defaults to
 the number of CPUs.
 .RE
-.SH "PROFILES"
-Profiles may be used to configure compiler options such as optimization levels
-and debug settings. See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more
-details.
-.sp
-Profile selection depends on the target and crate being built. By default the
-\fBdev\fR or \fBtest\fR profiles are used. If the \fB\-\-release\fR flag is given, then the
-\fBrelease\fR or \fBbench\fR profiles are used.
-
-.TS
-allbox tab(:);
-lt lt lt.
-T{
-Target
-T}:T{
-Default Profile
-T}:T{
-\fB\-\-release\fR Profile
-T}
-T{
-lib, bin, example
-T}:T{
-\fBdev\fR
-T}:T{
-\fBrelease\fR
-T}
-T{
-test, bench, or any target in "test" or "bench" mode
-T}:T{
-\fBtest\fR
-T}:T{
-\fBbench\fR
-T}
-.TE
-.sp
-.sp
-Dependencies use the \fBdev\fR/\fBrelease\fR profiles.
 .SH "ENVIRONMENT"
 See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/environment\-variables.html> for
 details on environment variables that Cargo reads.
index 0836166e67717675f2cf046563858bee2cb931ec..01823d991d8732b645fc877d408caa21ed2eaa62 100644 (file)
@@ -33,7 +33,12 @@ the target directory.
 .sp
 \fB\-\-release\fR
 .RS 4
-Clean all artifacts that were built with the \fBrelease\fR or \fBbench\fR profiles.
+Remove all artifacts in the \fBrelease\fR directory.
+.RE
+.sp
+\fB\-\-profile\fR \fIname\fR
+.RS 4
+Remove all artifacts in the directory with the given profile name.
 .RE
 .sp
 \fB\-\-target\-dir\fR \fIdirectory\fR
index 045795bb3acc51f2b1d5e2a01486ef320cb5237e..32ac9feaf112220ee97d18921cc37ce4d32c7297 100644 (file)
@@ -149,9 +149,14 @@ target artifacts are placed in a separate directory. See the
 .sp
 \fB\-\-release\fR
 .RS 4
-Document optimized artifacts with the \fBrelease\fR profile. See the
-PROFILES section for details on how this affects profile
-selection.
+Document optimized artifacts with the \fBrelease\fR profile.
+See also the \fB\-\-profile\fR option for choosing a specific profile by name.
+.RE
+.sp
+\fB\-\-profile\fR \fIname\fR
+.RS 4
+Document with the given profile.
+See the \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more details on profiles.
 .RE
 .sp
 \fB\-\-ignore\-rust\-version\fR
@@ -311,43 +316,6 @@ Number of parallel jobs to run. May also be specified with the
 \fBbuild.jobs\fR \fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&. Defaults to
 the number of CPUs.
 .RE
-.SH "PROFILES"
-Profiles may be used to configure compiler options such as optimization levels
-and debug settings. See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more
-details.
-.sp
-Profile selection depends on the target and crate being built. By default the
-\fBdev\fR or \fBtest\fR profiles are used. If the \fB\-\-release\fR flag is given, then the
-\fBrelease\fR or \fBbench\fR profiles are used.
-
-.TS
-allbox tab(:);
-lt lt lt.
-T{
-Target
-T}:T{
-Default Profile
-T}:T{
-\fB\-\-release\fR Profile
-T}
-T{
-lib, bin, example
-T}:T{
-\fBdev\fR
-T}:T{
-\fBrelease\fR
-T}
-T{
-test, bench, or any target in "test" or "bench" mode
-T}:T{
-\fBtest\fR
-T}:T{
-\fBbench\fR
-T}
-.TE
-.sp
-.sp
-Dependencies use the \fBdev\fR/\fBrelease\fR profiles.
 .SH "ENVIRONMENT"
 See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/environment\-variables.html> for
 details on environment variables that Cargo reads.
index 57eb1da015ff2eebe0de5f0042f6f7ccde9f62a7..97c34bb01392ea166f8ec533a8725ad7698058ae 100644 (file)
@@ -271,18 +271,20 @@ target artifacts are placed in a separate directory. See the
 .sp
 \fB\-\-release\fR
 .RS 4
-Fix optimized artifacts with the \fBrelease\fR profile. See the
-PROFILES section for details on how this affects profile
-selection.
+Fix optimized artifacts with the \fBrelease\fR profile.
+See also the \fB\-\-profile\fR option for choosing a specific profile by name.
 .RE
 .sp
 \fB\-\-profile\fR \fIname\fR
 .RS 4
-Changes fix behavior. Currently only \fBtest\fR is supported,
-which will fix with the \fB#[cfg(test)]\fR attribute enabled.
-This is useful to have it fix unit tests which are usually
-excluded via the \fBcfg\fR attribute. This does not change the actual profile
-used.
+Fix with the given profile.
+.sp
+As a special case, specifying the \fBtest\fR profile will also enable checking in
+test mode which will enable checking tests and enable the \fBtest\fR cfg option.
+See \fIrustc tests\fR <https://doc.rust\-lang.org/rustc/tests/index.html> for more
+detail.
+.sp
+See the \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more details on profiles.
 .RE
 .sp
 \fB\-\-ignore\-rust\-version\fR
@@ -442,43 +444,6 @@ Number of parallel jobs to run. May also be specified with the
 \fBbuild.jobs\fR \fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&. Defaults to
 the number of CPUs.
 .RE
-.SH "PROFILES"
-Profiles may be used to configure compiler options such as optimization levels
-and debug settings. See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more
-details.
-.sp
-Profile selection depends on the target and crate being built. By default the
-\fBdev\fR or \fBtest\fR profiles are used. If the \fB\-\-release\fR flag is given, then the
-\fBrelease\fR or \fBbench\fR profiles are used.
-
-.TS
-allbox tab(:);
-lt lt lt.
-T{
-Target
-T}:T{
-Default Profile
-T}:T{
-\fB\-\-release\fR Profile
-T}
-T{
-lib, bin, example
-T}:T{
-\fBdev\fR
-T}:T{
-\fBrelease\fR
-T}
-T{
-test, bench, or any target in "test" or "bench" mode
-T}:T{
-\fBtest\fR
-T}:T{
-\fBbench\fR
-T}
-.TE
-.sp
-.sp
-Dependencies use the \fBdev\fR/\fBrelease\fR profiles.
 .SH "ENVIRONMENT"
 See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/environment\-variables.html> for
 details on environment variables that Cargo reads.
index 1840182a2585eb10e73ec8b5beeea6f2ebfcb2ef..139140279cb4f4fc641b6f509fbd4f4791355ffd 100644 (file)
@@ -71,7 +71,7 @@ change, then Cargo will reinstall the package:
 .RE
 .sp
 .RS 4
-\h'-04'\(bu\h'+02'The release mode (\fB\-\-debug\fR).
+\h'-04'\(bu\h'+02'The profile (\fB\-\-profile\fR).
 .RE
 .sp
 .RS 4
@@ -258,6 +258,13 @@ is specified.
 \fB\-\-debug\fR
 .RS 4
 Build with the \fBdev\fR profile instead the \fBrelease\fR profile.
+See also the \fB\-\-profile\fR option for choosing a specific profile by name.
+.RE
+.sp
+\fB\-\-profile\fR \fIname\fR
+.RS 4
+Install with the given profile.
+See the \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more details on profiles.
 .RE
 .SS "Manifest Options"
 .sp
index c4ff6e444bf28eeed808d0ca596a57daa7dffd2b..c332d94bda48ec256dbbfcbe2acc07879dad2021 100644 (file)
@@ -82,9 +82,14 @@ target artifacts are placed in a separate directory. See the
 .sp
 \fB\-\-release\fR
 .RS 4
-Run optimized artifacts with the \fBrelease\fR profile. See the
-PROFILES section for details on how this affects profile
-selection.
+Run optimized artifacts with the \fBrelease\fR profile.
+See also the \fB\-\-profile\fR option for choosing a specific profile by name.
+.RE
+.sp
+\fB\-\-profile\fR \fIname\fR
+.RS 4
+Run with the given profile.
+See the \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more details on profiles.
 .RE
 .sp
 \fB\-\-ignore\-rust\-version\fR
@@ -244,43 +249,6 @@ Number of parallel jobs to run. May also be specified with the
 \fBbuild.jobs\fR \fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&. Defaults to
 the number of CPUs.
 .RE
-.SH "PROFILES"
-Profiles may be used to configure compiler options such as optimization levels
-and debug settings. See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more
-details.
-.sp
-Profile selection depends on the target and crate being built. By default the
-\fBdev\fR or \fBtest\fR profiles are used. If the \fB\-\-release\fR flag is given, then the
-\fBrelease\fR or \fBbench\fR profiles are used.
-
-.TS
-allbox tab(:);
-lt lt lt.
-T{
-Target
-T}:T{
-Default Profile
-T}:T{
-\fB\-\-release\fR Profile
-T}
-T{
-lib, bin, example
-T}:T{
-\fBdev\fR
-T}:T{
-\fBrelease\fR
-T}
-T{
-test, bench, or any target in "test" or "bench" mode
-T}:T{
-\fBtest\fR
-T}:T{
-\fBbench\fR
-T}
-.TE
-.sp
-.sp
-Dependencies use the \fBdev\fR/\fBrelease\fR profiles.
 .SH "ENVIRONMENT"
 See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/environment\-variables.html> for
 details on environment variables that Cargo reads.
index 5a69821c6e1abba76bf7c8ffc38fd502ecc313b5..6daf5a3f37e4ba7fc02bdaf3c8408c7c78aaa3bb 100644 (file)
@@ -157,9 +157,34 @@ target artifacts are placed in a separate directory. See the
 .sp
 \fB\-\-release\fR
 .RS 4
-Build optimized artifacts with the \fBrelease\fR profile. See the
-PROFILES section for details on how this affects profile
-selection.
+Build optimized artifacts with the \fBrelease\fR profile.
+See also the \fB\-\-profile\fR option for choosing a specific profile by name.
+.RE
+.sp
+\fB\-\-profile\fR \fIname\fR
+.RS 4
+Build with the given profile.
+.sp
+The \fBrustc\fR subcommand will treat the following named profiles with special behaviors:
+.sp
+.RS 4
+\h'-04'\(bu\h'+02'\fBcheck\fR \[em] Builds in the same way as the \fBcargo\-check\fR(1) command with
+the \fBdev\fR profile.
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+02'\fBtest\fR \[em] Builds in the same way as the \fBcargo\-test\fR(1) command,
+enabling building in test mode which will enable tests and enable the \fBtest\fR
+cfg option. See \fIrustc
+tests\fR <https://doc.rust\-lang.org/rustc/tests/index.html> for more detail.
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+02'\fBbench\fR \[em] Builds in the same was as the \fBcargo\-bench\fR(1) command,
+similar to the \fBtest\fR profile.
+.RE
+.sp
+See the \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more details on profiles.
 .RE
 .sp
 \fB\-\-ignore\-rust\-version\fR
@@ -319,43 +344,6 @@ Number of parallel jobs to run. May also be specified with the
 \fBbuild.jobs\fR \fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&. Defaults to
 the number of CPUs.
 .RE
-.SH "PROFILES"
-Profiles may be used to configure compiler options such as optimization levels
-and debug settings. See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more
-details.
-.sp
-Profile selection depends on the target and crate being built. By default the
-\fBdev\fR or \fBtest\fR profiles are used. If the \fB\-\-release\fR flag is given, then the
-\fBrelease\fR or \fBbench\fR profiles are used.
-
-.TS
-allbox tab(:);
-lt lt lt.
-T{
-Target
-T}:T{
-Default Profile
-T}:T{
-\fB\-\-release\fR Profile
-T}
-T{
-lib, bin, example
-T}:T{
-\fBdev\fR
-T}:T{
-\fBrelease\fR
-T}
-T{
-test, bench, or any target in "test" or "bench" mode
-T}:T{
-\fBtest\fR
-T}:T{
-\fBbench\fR
-T}
-.TE
-.sp
-.sp
-Dependencies use the \fBdev\fR/\fBrelease\fR profiles.
 .SH "ENVIRONMENT"
 See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/environment\-variables.html> for
 details on environment variables that Cargo reads.
index 2a9af8cf6b12fbad57dd2cecc16e869c50d31062..ad5cfbb187ed88001d084d668728265afefc9045 100644 (file)
@@ -168,9 +168,14 @@ target artifacts are placed in a separate directory. See the
 .sp
 \fB\-\-release\fR
 .RS 4
-Document optimized artifacts with the \fBrelease\fR profile. See the
-PROFILES section for details on how this affects profile
-selection.
+Document optimized artifacts with the \fBrelease\fR profile.
+See also the \fB\-\-profile\fR option for choosing a specific profile by name.
+.RE
+.sp
+\fB\-\-profile\fR \fIname\fR
+.RS 4
+Document with the given profile.
+See the \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more details on profiles.
 .RE
 .sp
 \fB\-\-ignore\-rust\-version\fR
@@ -330,43 +335,6 @@ Number of parallel jobs to run. May also be specified with the
 \fBbuild.jobs\fR \fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&. Defaults to
 the number of CPUs.
 .RE
-.SH "PROFILES"
-Profiles may be used to configure compiler options such as optimization levels
-and debug settings. See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more
-details.
-.sp
-Profile selection depends on the target and crate being built. By default the
-\fBdev\fR or \fBtest\fR profiles are used. If the \fB\-\-release\fR flag is given, then the
-\fBrelease\fR or \fBbench\fR profiles are used.
-
-.TS
-allbox tab(:);
-lt lt lt.
-T{
-Target
-T}:T{
-Default Profile
-T}:T{
-\fB\-\-release\fR Profile
-T}
-T{
-lib, bin, example
-T}:T{
-\fBdev\fR
-T}:T{
-\fBrelease\fR
-T}
-T{
-test, bench, or any target in "test" or "bench" mode
-T}:T{
-\fBtest\fR
-T}:T{
-\fBbench\fR
-T}
-.TE
-.sp
-.sp
-Dependencies use the \fBdev\fR/\fBrelease\fR profiles.
 .SH "ENVIRONMENT"
 See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/environment\-variables.html> for
 details on environment variables that Cargo reads.
index bafeb08662e1149c269e73281cf98706f09d0fdb..ee0d3cf39291c37d5dfb472b9ea30929cd3bec55 100644 (file)
@@ -268,9 +268,14 @@ target artifacts are placed in a separate directory. See the
 .sp
 \fB\-\-release\fR
 .RS 4
-Test optimized artifacts with the \fBrelease\fR profile. See the
-PROFILES section for details on how this affects profile
-selection.
+Test optimized artifacts with the \fBrelease\fR profile.
+See also the \fB\-\-profile\fR option for choosing a specific profile by name.
+.RE
+.sp
+\fB\-\-profile\fR \fIname\fR
+.RS 4
+Test with the given profile.
+See the \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more details on profiles.
 .RE
 .sp
 \fB\-\-ignore\-rust\-version\fR
@@ -448,51 +453,6 @@ Number of parallel jobs to run. May also be specified with the
 \fBbuild.jobs\fR \fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&. Defaults to
 the number of CPUs.
 .RE
-.SH "PROFILES"
-Profiles may be used to configure compiler options such as optimization levels
-and debug settings. See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more
-details.
-.sp
-Profile selection depends on the target and crate being built. By default the
-\fBdev\fR or \fBtest\fR profiles are used. If the \fB\-\-release\fR flag is given, then the
-\fBrelease\fR or \fBbench\fR profiles are used.
-
-.TS
-allbox tab(:);
-lt lt lt.
-T{
-Target
-T}:T{
-Default Profile
-T}:T{
-\fB\-\-release\fR Profile
-T}
-T{
-lib, bin, example
-T}:T{
-\fBdev\fR
-T}:T{
-\fBrelease\fR
-T}
-T{
-test, bench, or any target in "test" or "bench" mode
-T}:T{
-\fBtest\fR
-T}:T{
-\fBbench\fR
-T}
-.TE
-.sp
-.sp
-Dependencies use the \fBdev\fR/\fBrelease\fR profiles.
-.sp
-Unit tests are separate executable artifacts which use the \fBtest\fR/\fBbench\fR
-profiles. Example targets are built the same as with \fBcargo build\fR (using the
-\fBdev\fR/\fBrelease\fR profiles) unless you are building them with the test harness
-(by setting \fBtest = true\fR in the manifest or using the \fB\-\-example\fR flag) in
-which case they use the \fBtest\fR/\fBbench\fR profiles. Library targets are built
-with the \fBdev\fR/\fBrelease\fR profiles when linked to an integration test, binary,
-or doctest.
 .SH "ENVIRONMENT"
 See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/environment\-variables.html> for
 details on environment variables that Cargo reads.
index 5b431fdb2985b65f343ebd6e3d0328238e5f0c29..a7d92934d04d3185db5a6a4bacaf76de21be1027 100644 (file)
@@ -351,6 +351,15 @@ fn test_all_and_bench() {
         .run();
 }
 
+/// Basic setup:
+///
+/// foo v0.0.0
+/// â”œâ”€â”€ bar v0.0.0
+/// â”‚   â”œâ”€â”€ registry v0.0.1
+/// â”‚   â””── registry-shared v0.0.1
+/// â””── registry-shared v0.0.1
+///
+/// Where `bar` will have the given crate types.
 fn project_with_dep(crate_types: &str) -> Project {
     Package::new("registry", "0.0.1")
         .file("src/lib.rs", r#"pub fn foo() { println!("registry"); }"#)
@@ -419,6 +428,10 @@ fn project_with_dep(crate_types: &str) -> Project {
         .build()
 }
 
+/// Helper for checking which LTO behavior is used for a specific crate.
+///
+/// `krate_info` is extra compiler flags used to distinguish this if the same
+/// crate name is being built multiple times.
 fn verify_lto(output: &Output, krate: &str, krate_info: &str, expected_lto: Lto) {
     let stderr = std::str::from_utf8(&output.stderr).unwrap();
     let mut matches = stderr.lines().filter(|line| {
@@ -467,18 +480,22 @@ fn verify_lto(output: &Output, krate: &str, krate_info: &str, expected_lto: Lto)
 fn cdylib_and_rlib() {
     let p = project_with_dep("'cdylib', 'rlib'");
     let output = p.cargo("build --release -v").exec_with_output().unwrap();
+    // `registry` is ObjectAndBitcode because because it needs Object for the
+    // rlib, and Bitcode for the cdylib (which doesn't support LTO).
     verify_lto(
         &output,
         "registry",
         "--crate-type lib",
         Lto::ObjectAndBitcode,
     );
+    // Same as `registry`
     verify_lto(
         &output,
         "registry_shared",
         "--crate-type lib",
         Lto::ObjectAndBitcode,
     );
+    // Same as `registry`
     verify_lto(
         &output,
         "bar",
@@ -493,8 +510,8 @@ fn cdylib_and_rlib() {
 [FRESH] registry-shared v0.0.1
 [FRESH] bar v0.0.0 [..]
 [COMPILING] foo [..]
-[RUNNING] `rustc --crate-name foo [..]-C embed-bitcode=no [..]--test[..]
-[RUNNING] `rustc --crate-name a [..]-C embed-bitcode=no [..]--test[..]
+[RUNNING] `rustc --crate-name foo [..]-C lto [..]--test[..]
+[RUNNING] `rustc --crate-name a [..]-C lto [..]--test[..]
 [FINISHED] [..]
 [RUNNING] [..]
 [RUNNING] [..]
@@ -514,19 +531,16 @@ fn cdylib_and_rlib() {
     p.cargo("test --release -v --manifest-path bar/Cargo.toml")
         .with_stderr_unordered(
             "\
-[COMPILING] registry v0.0.1
-[COMPILING] registry-shared v0.0.1
-[RUNNING] `rustc --crate-name registry [..]-C embed-bitcode=no[..]
-[RUNNING] `rustc --crate-name registry_shared [..]-C embed-bitcode=no[..]
+[FRESH] registry-shared v0.0.1
+[FRESH] registry v0.0.1
 [COMPILING] bar [..]
-[RUNNING] `rustc --crate-name bar [..]--crate-type cdylib --crate-type rlib [..]-C embed-bitcode=no[..]
-[RUNNING] `rustc --crate-name bar [..]-C embed-bitcode=no [..]--test[..]
-[RUNNING] `rustc --crate-name b [..]-C embed-bitcode=no [..]--test[..]
+[RUNNING] `rustc --crate-name bar [..]-C lto[..]--test[..]
+[RUNNING] `rustc --crate-name b [..]-C lto[..]--test[..]
 [FINISHED] [..]
 [RUNNING] [..]target/release/deps/bar-[..]
 [RUNNING] [..]target/release/deps/b-[..]
 [DOCTEST] bar
-[RUNNING] `rustdoc --crate-type cdylib --crate-type rlib --crate-name bar --test [..]-C embed-bitcode=no[..]
+[RUNNING] `rustdoc --crate-type cdylib --crate-type rlib --crate-name bar --test [..]-C lto[..]
 ",
         )
         .run();
@@ -536,15 +550,23 @@ fn cdylib_and_rlib() {
 fn dylib() {
     let p = project_with_dep("'dylib'");
     let output = p.cargo("build --release -v").exec_with_output().unwrap();
+    // `registry` is OnlyObject because rustc doesn't support LTO with dylibs.
     verify_lto(&output, "registry", "--crate-type lib", Lto::OnlyObject);
+    // `registry_shared` is both because it is needed by both bar (Object) and
+    // foo (Bitcode for LTO).
     verify_lto(
         &output,
         "registry_shared",
         "--crate-type lib",
         Lto::ObjectAndBitcode,
     );
+    // `bar` is OnlyObject because rustc doesn't support LTO with dylibs.
     verify_lto(&output, "bar", "--crate-type dylib", Lto::OnlyObject);
+    // `foo` is LTO because it is a binary, and the profile specifies `lto=true`.
     verify_lto(&output, "foo", "--crate-type bin", Lto::Run(None));
+    // `cargo test` should not rebuild dependencies. It builds the test
+    // executables with `lto=true` because the tests are built with the
+    // `--release` flag.
     p.cargo("test --release -v")
         .with_stderr_unordered(
             "\
@@ -552,14 +574,19 @@ fn dylib() {
 [FRESH] registry-shared v0.0.1
 [FRESH] bar v0.0.0 [..]
 [COMPILING] foo [..]
-[RUNNING] `rustc --crate-name foo [..]-C embed-bitcode=no [..]--test[..]
-[RUNNING] `rustc --crate-name a [..]-C embed-bitcode=no [..]--test[..]
+[RUNNING] `rustc --crate-name foo [..]-C lto [..]--test[..]
+[RUNNING] `rustc --crate-name a [..]-C lto [..]--test[..]
 [FINISHED] [..]
 [RUNNING] [..]
 [RUNNING] [..]
 ",
         )
         .run();
+    // Building just `bar` causes `registry-shared` to get rebuilt because it
+    // switches to OnlyObject because it is now only being used with a dylib
+    // which does not support LTO.
+    //
+    // `bar` gets rebuilt because `registry_shared` got rebuilt.
     p.cargo("build --release -v --manifest-path bar/Cargo.toml")
         .with_stderr_unordered(
             "\
@@ -572,14 +599,21 @@ fn dylib() {
 ",
         )
         .run();
+    // Testing just `bar` causes `registry` to get rebuilt because it switches
+    // to needing both Object (for the `bar` dylib) and Bitcode (for the test
+    // built with LTO).
+    //
+    // `bar` the dylib gets rebuilt because `registry` got rebuilt.
     p.cargo("test --release -v --manifest-path bar/Cargo.toml")
         .with_stderr_unordered(
             "\
 [FRESH] registry-shared v0.0.1
-[FRESH] registry v0.0.1
+[COMPILING] registry v0.0.1
+[RUNNING] `rustc --crate-name registry [..]
 [COMPILING] bar [..]
-[RUNNING] `rustc --crate-name bar [..]-C embed-bitcode=no [..]--test[..]
-[RUNNING] `rustc --crate-name b [..]-C embed-bitcode=no [..]--test[..]
+[RUNNING] `rustc --crate-name bar [..]--crate-type dylib [..]-C embed-bitcode=no[..]
+[RUNNING] `rustc --crate-name bar [..]-C lto [..]--test[..]
+[RUNNING] `rustc --crate-name b [..]-C lto [..]--test[..]
 [FINISHED] [..]
 [RUNNING] [..]
 [RUNNING] [..]
@@ -640,59 +674,6 @@ fn test_profile() {
         .run();
 }
 
-#[cargo_test]
-fn dev_profile() {
-    // Mixing dev=LTO with test=not-LTO
-    Package::new("bar", "0.0.1")
-        .file("src/lib.rs", "pub fn foo() -> i32 { 123 } ")
-        .publish();
-
-    let p = project()
-        .file(
-            "Cargo.toml",
-            r#"
-                [package]
-                name = "foo"
-                version = "0.1.0"
-                edition = "2018"
-
-                [profile.dev]
-                lto = 'thin'
-
-                [dependencies]
-                bar = "*"
-            "#,
-        )
-        .file(
-            "src/lib.rs",
-            r#"
-                #[test]
-                fn t1() {
-                    assert_eq!(123, bar::foo());
-                }
-            "#,
-        )
-        .build();
-
-    p.cargo("test -v")
-        // unordered because the two `foo` builds start in parallel
-        .with_stderr_unordered("\
-[UPDATING] [..]
-[DOWNLOADING] [..]
-[DOWNLOADED] [..]
-[COMPILING] bar v0.0.1
-[RUNNING] `rustc --crate-name bar [..]crate-type lib[..]
-[COMPILING] foo [..]
-[RUNNING] `rustc --crate-name foo [..]--crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no [..]
-[RUNNING] `rustc --crate-name foo [..]--emit=dep-info,link -C embed-bitcode=no [..]--test[..]
-[FINISHED] [..]
-[RUNNING] [..]
-[DOCTEST] foo
-[RUNNING] `rustdoc [..]
-")
-        .run();
-}
-
 #[cargo_test]
 fn doctest() {
     let p = project()
@@ -732,18 +713,24 @@ fn doctest() {
         .build();
 
     p.cargo("test --doc --release -v")
-        .with_stderr_contains("[..]`rustc --crate-name bar[..]-C embed-bitcode=no[..]")
-        .with_stderr_contains("[..]`rustc --crate-name foo[..]-C embed-bitcode=no[..]")
+        .with_stderr_contains("[..]`rustc --crate-name bar[..]-C linker-plugin-lto[..]")
+        .with_stderr_contains("[..]`rustc --crate-name foo[..]-C linker-plugin-lto[..]")
         // embed-bitcode should be harmless here
-        .with_stderr_contains("[..]`rustdoc [..]-C embed-bitcode=no[..]")
+        .with_stderr_contains("[..]`rustdoc [..]-C lto[..]")
         .run();
 
     // Try with bench profile.
     p.cargo("test --doc --release -v")
         .env("CARGO_PROFILE_BENCH_LTO", "true")
-        .with_stderr_contains("[..]`rustc --crate-name bar[..]-C linker-plugin-lto[..]")
-        .with_stderr_contains("[..]`rustc --crate-name foo[..]-C linker-plugin-lto[..]")
-        .with_stderr_contains("[..]`rustdoc [..]-C lto[..]")
+        .with_stderr_unordered(
+            "\
+[FRESH] bar v0.1.0 [..]
+[FRESH] foo v0.1.0 [..]
+[FINISHED] release [..]
+[DOCTEST] foo
+[RUNNING] `rustdoc [..]-C lto[..]
+",
+        )
         .run();
 }
 
@@ -821,15 +808,13 @@ fn fresh_swapping_commands() {
     p.cargo("test --release -v")
         .with_stderr_unordered(
             "\
-[COMPILING] bar v1.0.0
-[RUNNING] `rustc --crate-name bar [..]-C embed-bitcode=no[..]
+[FRESH] bar v1.0.0
 [COMPILING] foo v0.1.0 [..]
-[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib[..]-C embed-bitcode=no[..]
-[RUNNING] `rustc --crate-name foo src/lib.rs [..]-C embed-bitcode=no[..]--test[..]
+[RUNNING] `rustc --crate-name foo src/lib.rs [..]-C lto[..]--test[..]
 [FINISHED] [..]
 [RUNNING] `[..]/foo[..]`
 [DOCTEST] foo
-[RUNNING] `rustdoc [..]-C embed-bitcode=no[..]
+[RUNNING] `rustdoc [..]-C lto[..]
 ",
         )
         .run();
index f7e98add1f74ad8d3a3e2b720e85cd011cedae31..1678a57917afb2fc41551ebfd6a510078ee5eeed 100644 (file)
@@ -4,41 +4,6 @@ use cargo_test_support::paths::CargoPathExt;
 use cargo_test_support::registry::Package;
 use cargo_test_support::{basic_lib_manifest, paths, project};
 
-#[cargo_test]
-fn named_profile_gated() {
-    // Named profile in config requires enabling in Cargo.toml.
-    let p = project()
-        .file("src/lib.rs", "")
-        .file(
-            ".cargo/config",
-            r#"
-            [profile.foo]
-            inherits = 'dev'
-            opt-level = 1
-            "#,
-        )
-        .build();
-    p.cargo("build --profile foo -Zunstable-options")
-        .masquerade_as_nightly_cargo()
-        .with_stderr(
-            "\
-[ERROR] config profile `foo` is not valid (defined in `[..]/foo/.cargo/config`)
-
-Caused by:
-  feature `named-profiles` is required
-
-  The package requires the Cargo feature called `named-profiles`, \
-  but that feature is not stabilized in this version of Cargo (1.[..]).
-  Consider adding `cargo-features = [\"named-profiles\"]` to the top of Cargo.toml \
-  (above the [package] table) to tell Cargo you are opting in to use this unstable feature.
-  See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#custom-named-profiles \
-  for more information about the status of this feature.
-",
-        )
-        .with_status(101)
-        .run();
-}
-
 #[cargo_test]
 fn profile_config_validate_warnings() {
     let p = project()
@@ -378,8 +343,6 @@ fn named_config_profile() {
     fs::write(
         paths::root().join("Cargo.toml"),
         r#"
-            cargo-features = ['named-profiles']
-
             [workspace]
 
             [profile.middle]
@@ -397,7 +360,7 @@ fn named_config_profile() {
         "#,
     )
     .unwrap();
-    let config = ConfigBuilder::new().nightly_features_allowed(true).build();
+    let config = ConfigBuilder::new().build();
     let profile_name = InternedString::new("foo");
     let ws = Workspace::new(&paths::root().join("Cargo.toml"), &config).unwrap();
     let profiles = Profiles::new(&ws, profile_name).unwrap();
@@ -443,7 +406,6 @@ fn named_env_profile() {
         .file(
             "Cargo.toml",
             r#"
-            cargo-features = ["named-profiles"]
             [package]
             name = "foo"
             version = "0.1.0"
@@ -452,8 +414,7 @@ fn named_env_profile() {
         .file("src/lib.rs", "")
         .build();
 
-    p.cargo("build -v -Zunstable-options --profile=other")
-        .masquerade_as_nightly_cargo()
+    p.cargo("build -v --profile=other")
         .env("CARGO_PROFILE_OTHER_CODEGEN_UNITS", "1")
         .env("CARGO_PROFILE_OTHER_INHERITS", "dev")
         .with_stderr_contains("[..]-C codegen-units=1 [..]")
@@ -462,7 +423,8 @@ fn named_env_profile() {
 
 #[cargo_test]
 fn test_with_dev_profile() {
-    // `cargo test` uses "dev" profile for dependencies.
+    // The `test` profile inherits from `dev` for both local crates and
+    // dependencies.
     Package::new("somedep", "1.0.0").publish();
     let p = project()
         .file(
@@ -488,7 +450,7 @@ fn test_with_dev_profile() {
 [COMPILING] somedep v1.0.0
 [RUNNING] `rustc --crate-name somedep [..]-C debuginfo=0[..]
 [COMPILING] foo v0.1.0 [..]
-[RUNNING] `rustc --crate-name foo [..]-C debuginfo=2[..]
+[RUNNING] `rustc --crate-name foo [..]-C debuginfo=0[..]
 [FINISHED] [..]
 ",
         )
index 1307b4e071b309fa799e650fa27eccdaf6e232dd..e7961f373c6982a8d41d4be575d246ce681c2554 100644 (file)
@@ -3,31 +3,12 @@
 use cargo_test_support::paths::CargoPathExt;
 use cargo_test_support::{basic_lib_manifest, project};
 
-#[cargo_test]
-fn gated() {
-    let p = project().file("src/lib.rs", "").build();
-    // `rustc`, `fix`, and `check` have had `--profile` before custom named profiles.
-    // Without unstable, these shouldn't be allowed to access non-legacy names.
-    for command in [
-        "rustc", "fix", "check", "bench", "clean", "install", "test", "build", "doc", "run",
-        "rustdoc",
-    ] {
-        p.cargo(command)
-            .arg("--profile=release")
-            .with_status(101)
-            .with_stderr("error: usage of `--profile` requires `-Z unstable-options`")
-            .run();
-    }
-}
-
 #[cargo_test]
 fn inherits_on_release() {
     let p = project()
         .file(
             "Cargo.toml",
             r#"
-                cargo-features = ["named-profiles"]
-
                 [package]
                 name = "foo"
                 version = "0.0.1"
@@ -41,7 +22,6 @@ fn inherits_on_release() {
         .build();
 
     p.cargo("build")
-        .masquerade_as_nightly_cargo()
         .with_status(101)
         .with_stderr(
             "\
@@ -57,8 +37,6 @@ fn missing_inherits() {
         .file(
             "Cargo.toml",
             r#"
-                cargo-features = ["named-profiles"]
-
                 [package]
                 name = "foo"
                 version = "0.0.1"
@@ -72,7 +50,6 @@ fn missing_inherits() {
         .build();
 
     p.cargo("build")
-        .masquerade_as_nightly_cargo()
         .with_status(101)
         .with_stderr(
             "\
@@ -89,8 +66,6 @@ fn invalid_profile_name() {
         .file(
             "Cargo.toml",
             r#"
-                cargo-features = ["named-profiles"]
-
                 [package]
                 name = "foo"
                 version = "0.0.1"
@@ -105,7 +80,6 @@ fn invalid_profile_name() {
         .build();
 
     p.cargo("build")
-        .masquerade_as_nightly_cargo()
         .with_status(101)
         .with_stderr(
             "\
@@ -126,8 +100,6 @@ fn invalid_dir_name() {
         .file(
             "Cargo.toml",
             r#"
-                cargo-features = ["named-profiles"]
-
                 [package]
                 name = "foo"
                 version = "0.0.1"
@@ -143,7 +115,6 @@ fn invalid_dir_name() {
         .build();
 
     p.cargo("build")
-        .masquerade_as_nightly_cargo()
         .with_status(101)
         .with_stderr(
             "\
@@ -161,8 +132,6 @@ fn dir_name_disabled() {
         .file(
             "Cargo.toml",
             r#"
-                cargo-features = ["named-profiles"]
-
                 [package]
                 name = "foo"
                 version = "0.1.0"
@@ -177,7 +146,6 @@ fn dir_name_disabled() {
         .build();
 
     p.cargo("build")
-        .masquerade_as_nightly_cargo()
         .with_status(101)
         .with_stderr(
             "\
@@ -197,8 +165,6 @@ fn invalid_inherits() {
         .file(
             "Cargo.toml",
             r#"
-                cargo-features = ["named-profiles"]
-
                 [package]
                 name = "foo"
                 version = "0.0.1"
@@ -213,7 +179,6 @@ fn invalid_inherits() {
         .build();
 
     p.cargo("build")
-        .masquerade_as_nightly_cargo()
         .with_status(101)
         .with_stderr(
             "error: profile `release-lto` inherits from `.release`, \
@@ -228,8 +193,6 @@ fn non_existent_inherits() {
         .file(
             "Cargo.toml",
             r#"
-                cargo-features = ["named-profiles"]
-
                 [package]
                 name = "foo"
                 version = "0.0.1"
@@ -244,7 +207,6 @@ fn non_existent_inherits() {
         .build();
 
     p.cargo("build")
-        .masquerade_as_nightly_cargo()
         .with_status(101)
         .with_stderr(
             "\
@@ -260,8 +222,6 @@ fn self_inherits() {
         .file(
             "Cargo.toml",
             r#"
-                cargo-features = ["named-profiles"]
-
                 [package]
                 name = "foo"
                 version = "0.0.1"
@@ -276,7 +236,6 @@ fn self_inherits() {
         .build();
 
     p.cargo("build")
-        .masquerade_as_nightly_cargo()
         .with_status(101)
         .with_stderr(
             "\
@@ -292,8 +251,6 @@ fn inherits_loop() {
         .file(
             "Cargo.toml",
             r#"
-                cargo-features = ["named-profiles"]
-
                 [package]
                 name = "foo"
                 version = "0.0.1"
@@ -312,7 +269,6 @@ fn inherits_loop() {
         .build();
 
     p.cargo("build")
-        .masquerade_as_nightly_cargo()
         .with_status(101)
         .with_stderr(
             "\
@@ -328,8 +284,6 @@ fn overrides_with_custom() {
         .file(
             "Cargo.toml",
             r#"
-                cargo-features = ["named-profiles"]
-
                 [package]
                 name = "foo"
                 version = "0.0.1"
@@ -365,7 +319,6 @@ fn overrides_with_custom() {
     // profile overrides are inherited between profiles using inherits and have a
     // higher priority than profile options provided by custom profiles
     p.cargo("build -v")
-        .masquerade_as_nightly_cargo()
         .with_stderr_unordered(
             "\
 [COMPILING] xxx [..]
@@ -380,8 +333,7 @@ fn overrides_with_custom() {
         .run();
 
     // This also verifies that the custom profile names appears in the finished line.
-    p.cargo("build --profile=other -Z unstable-options -v")
-        .masquerade_as_nightly_cargo()
+    p.cargo("build --profile=other -v")
         .with_stderr_unordered(
             "\
 [COMPILING] xxx [..]
@@ -411,8 +363,7 @@ fn conflicting_usage() {
         .file("src/lib.rs", "")
         .build();
 
-    p.cargo("build -Z unstable-options --profile=dev --release")
-        .masquerade_as_nightly_cargo()
+    p.cargo("build --profile=dev --release")
         .with_status(101)
         .with_stderr(
             "\
@@ -423,8 +374,7 @@ Remove one flag or the other to continue.
         )
         .run();
 
-    p.cargo("install -Z unstable-options --profile=release --debug")
-        .masquerade_as_nightly_cargo()
+    p.cargo("install --profile=release --debug")
         .with_status(101)
         .with_stderr(
             "\
@@ -442,8 +392,6 @@ fn clean_custom_dirname() {
         .file(
             "Cargo.toml",
             r#"
-                cargo-features = ["named-profiles"]
-
                 [package]
                 name = "foo"
                 version = "0.0.1"
@@ -457,7 +405,6 @@ fn clean_custom_dirname() {
         .build();
 
     p.cargo("build --release")
-        .masquerade_as_nightly_cargo()
         .with_stdout("")
         .with_stderr(
             "\
@@ -470,7 +417,6 @@ fn clean_custom_dirname() {
     p.cargo("clean -p foo").masquerade_as_nightly_cargo().run();
 
     p.cargo("build --release")
-        .masquerade_as_nightly_cargo()
         .with_stdout("")
         .with_stderr(
             "\
@@ -479,12 +425,9 @@ fn clean_custom_dirname() {
         )
         .run();
 
-    p.cargo("clean -p foo --release")
-        .masquerade_as_nightly_cargo()
-        .run();
+    p.cargo("clean -p foo --release").run();
 
     p.cargo("build --release")
-        .masquerade_as_nightly_cargo()
         .with_stderr(
             "\
 [COMPILING] foo v0.0.1 ([..])
@@ -494,7 +437,6 @@ fn clean_custom_dirname() {
         .run();
 
     p.cargo("build")
-        .masquerade_as_nightly_cargo()
         .with_stdout("")
         .with_stderr(
             "\
@@ -504,8 +446,7 @@ fn clean_custom_dirname() {
         )
         .run();
 
-    p.cargo("build -Z unstable-options --profile=other")
-        .masquerade_as_nightly_cargo()
+    p.cargo("build --profile=other")
         .with_stderr(
             "\
 [COMPILING] foo v0.0.1 ([..])
@@ -514,10 +455,7 @@ fn clean_custom_dirname() {
         )
         .run();
 
-    p.cargo("clean")
-        .arg("--release")
-        .masquerade_as_nightly_cargo()
-        .run();
+    p.cargo("clean").arg("--release").run();
 
     // Make sure that 'other' was not cleaned
     assert!(p.build_dir().is_dir());
@@ -526,10 +464,7 @@ fn clean_custom_dirname() {
     assert!(!p.build_dir().join("release").is_dir());
 
     // This should clean 'other'
-    p.cargo("clean -Z unstable-options --profile=other")
-        .masquerade_as_nightly_cargo()
-        .with_stderr("")
-        .run();
+    p.cargo("clean --profile=other").with_stderr("").run();
     assert!(p.build_dir().join("debug").is_dir());
     assert!(!p.build_dir().join("other").is_dir());
 }
@@ -540,8 +475,6 @@ fn unknown_profile() {
         .file(
             "Cargo.toml",
             r#"
-            cargo-features = ["named-profiles"]
-
             [package]
             name = "foo"
             version = "0.0.1"
@@ -550,14 +483,12 @@ fn unknown_profile() {
         .file("src/lib.rs", "")
         .build();
 
-    p.cargo("build --profile alpha -Zunstable-options")
-        .masquerade_as_nightly_cargo()
+    p.cargo("build --profile alpha")
         .with_stderr("[ERROR] profile `alpha` is not defined")
         .with_status(101)
         .run();
     // Clean has a separate code path, need to check it too.
-    p.cargo("clean --profile alpha -Zunstable-options")
-        .masquerade_as_nightly_cargo()
+    p.cargo("clean --profile alpha")
         .with_stderr("[ERROR] profile `alpha` is not defined")
         .with_status(101)
         .run();
@@ -580,15 +511,13 @@ fn reserved_profile_names() {
         .file("src/lib.rs", "")
         .build();
 
-    p.cargo("build --profile=doc -Zunstable-options")
-        .masquerade_as_nightly_cargo()
+    p.cargo("build --profile=doc")
         .with_status(101)
         .with_stderr("error: profile `doc` is reserved and not allowed to be explicitly specified")
         .run();
     // Not an exhaustive list, just a sample.
     for name in ["build", "cargo", "check", "rustc", "CaRgO_startswith"] {
-        p.cargo(&format!("build --profile={} -Zunstable-options", name))
-            .masquerade_as_nightly_cargo()
+        p.cargo(&format!("build --profile={}", name))
             .with_status(101)
             .with_stderr(&format!(
                 "\
@@ -605,8 +534,6 @@ See https://doc.rust-lang.org/cargo/reference/profiles.html for more on configur
             "Cargo.toml",
             &format!(
                 r#"
-                    cargo-features = ["named-profiles"]
-
                     [package]
                     name = "foo"
                     version = "0.1.0"
@@ -619,7 +546,6 @@ See https://doc.rust-lang.org/cargo/reference/profiles.html for more on configur
         );
 
         p.cargo("build")
-            .masquerade_as_nightly_cargo()
             .with_status(101)
             .with_stderr(&format!(
                 "\
@@ -638,8 +564,6 @@ Caused by:
     p.change_file(
         "Cargo.toml",
         r#"
-               cargo-features = ["named-profiles"]
-
                [package]
                name = "foo"
                version = "0.1.0"
@@ -652,7 +576,6 @@ Caused by:
     );
 
     p.cargo("build")
-        .masquerade_as_nightly_cargo()
         .with_status(101)
         .with_stderr(
             "\
@@ -674,8 +597,6 @@ fn legacy_commands_support_custom() {
         .file(
             "Cargo.toml",
             r#"
-               cargo-features = ["named-profiles"]
-
                [package]
                name = "foo"
                version = "0.1.0"
@@ -694,9 +615,7 @@ fn legacy_commands_support_custom() {
             pb.arg("--allow-no-vcs");
         }
         pb.arg("--profile=super-dev")
-            .arg("-Zunstable-options")
             .arg("-v")
-            .masquerade_as_nightly_cargo()
             .with_stderr_contains("[RUNNING] [..]codegen-units=3[..]")
             .run();
         p.build_dir().rm_rf();
index 045f2a3e06576b663d96e20c883a6a7b2746eac5..74d54385ff149febe0df3277ef049203345ddb0a 100644 (file)
@@ -2,7 +2,7 @@
 //! example, the `test` profile applying to test targets, but not other
 //! targets, etc.
 
-use cargo_test_support::{basic_manifest, is_nightly, project, Project};
+use cargo_test_support::{basic_manifest, project, Project};
 
 fn all_target_project() -> Project {
     // This abuses the `codegen-units` setting so that we can verify exactly
@@ -10,41 +10,32 @@ fn all_target_project() -> Project {
     project()
         .file(
             "Cargo.toml",
-            &format!(
-                r#"
-                    cargo-features = [{named_profiles}]
-
-                    [package]
-                    name = "foo"
-                    version = "0.0.1"
+            r#"
+                [package]
+                name = "foo"
+                version = "0.0.1"
 
-                    [dependencies]
-                    bar = {{ path = "bar" }}
+                [dependencies]
+                bar = { path = "bar" }
 
-                    [build-dependencies]
-                    bdep = {{ path = "bdep" }}
+                [build-dependencies]
+                bdep = { path = "bdep" }
 
-                    [profile.dev]
-                    codegen-units = 1
-                    panic = "abort"
-                    [profile.release]
-                    codegen-units = 2
-                    panic = "abort"
-                    [profile.test]
-                    codegen-units = 3
-                    [profile.bench]
-                    codegen-units = 4
-                    [profile.dev.build-override]
-                    codegen-units = 5
-                    [profile.release.build-override]
-                    codegen-units = 6
-                "#,
-                named_profiles = if is_nightly() {
-                    "\"named-profiles\", "
-                } else {
-                    ""
-                }
-            ),
+                [profile.dev]
+                codegen-units = 1
+                panic = "abort"
+                [profile.release]
+                codegen-units = 2
+                panic = "abort"
+                [profile.test]
+                codegen-units = 3
+                [profile.bench]
+                codegen-units = 4
+                [profile.dev.build-override]
+                codegen-units = 5
+                [profile.release.build-override]
+                codegen-units = 6
+            "#,
         )
         .file("src/lib.rs", "extern crate bar;")
         .file("src/main.rs", "extern crate foo; fn main() {}")
@@ -91,7 +82,7 @@ fn profile_selection_build() {
     // NOTES:
     // - bdep `panic` is not set because it thinks `build.rs` is a plugin.
     // - build_script_build is built without panic because it thinks `build.rs` is a plugin.
-    p.cargo("build -vv").masquerade_as_nightly_cargo().with_stderr_unordered("\
+    p.cargo("build -vv").with_stderr_unordered("\
 [COMPILING] bar [..]
 [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
 [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..]
@@ -106,7 +97,6 @@ fn profile_selection_build() {
 [FINISHED] dev [unoptimized + debuginfo] [..]
 ").run();
     p.cargo("build -vv")
-        .masquerade_as_nightly_cargo()
         .with_stderr_unordered(
             "\
 [FRESH] bar [..]
@@ -123,7 +113,7 @@ fn profile_selection_build_release() {
     let p = all_target_project();
 
     // `build --release`
-    p.cargo("build --release -vv").masquerade_as_nightly_cargo().with_stderr_unordered("\
+    p.cargo("build --release -vv").with_stderr_unordered("\
 [COMPILING] bar [..]
 [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]
 [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..]
@@ -138,7 +128,6 @@ fn profile_selection_build_release() {
 [FINISHED] release [optimized] [..]
 ").run();
     p.cargo("build --release -vv")
-        .masquerade_as_nightly_cargo()
         .with_stderr_unordered(
             "\
 [FRESH] bar [..]
@@ -153,7 +142,6 @@ fn profile_selection_build_release() {
 #[cargo_test]
 fn profile_selection_build_all_targets() {
     let p = all_target_project();
-    let affected = if is_nightly() { 1 } else { 3 };
     // `build`
     // NOTES:
     // - bdep `panic` is not set because it thinks `build.rs` is a plugin.
@@ -181,7 +169,7 @@ fn profile_selection_build_all_targets() {
     //   bin      dev        dev
     //   bin      dev        build
     //   example  dev        build
-    p.cargo("build --all-targets -vv").masquerade_as_nightly_cargo().with_stderr_unordered(format!("\
+    p.cargo("build --all-targets -vv").with_stderr_unordered("\
 [COMPILING] bar [..]
 [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 [..]
 [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
@@ -193,17 +181,16 @@ fn profile_selection_build_all_targets() {
 [RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build`
 [foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
 [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]`
-[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link[..]-C codegen-units={affected} -C debuginfo=2 --test [..]`
+[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 --test [..]`
 [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 [..]`
-[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link[..]-C codegen-units={affected} -C debuginfo=2 --test [..]`
-[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link[..]-C codegen-units={affected} -C debuginfo=2 --test [..]`
-[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]link[..]-C codegen-units={affected} -C debuginfo=2 --test [..]`
+[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 --test [..]`
+[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 --test [..]`
+[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 --test [..]`
 [RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]`
 [RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]`
 [FINISHED] dev [unoptimized + debuginfo] [..]
-", affected=affected)).run();
+").run();
     p.cargo("build -vv")
-        .masquerade_as_nightly_cargo()
         .with_stderr_unordered(
             "\
 [FRESH] bar [..]
@@ -218,7 +205,6 @@ fn profile_selection_build_all_targets() {
 #[cargo_test]
 fn profile_selection_build_all_targets_release() {
     let p = all_target_project();
-    let affected = if is_nightly() { 2 } else { 4 };
     // `build --all-targets --release`
     // NOTES:
     // - bdep `panic` is not set because it thinks `build.rs` is a plugin.
@@ -249,7 +235,7 @@ fn profile_selection_build_all_targets_release() {
     //   bin      release        test   (bench/test de-duped)
     //   bin      release        build
     //   example  release        build
-    p.cargo("build --all-targets --release -vv").masquerade_as_nightly_cargo().with_stderr_unordered(format!("\
+    p.cargo("build --all-targets --release -vv").with_stderr_unordered("\
 [COMPILING] bar [..]
 [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3[..]-C codegen-units=2 [..]
 [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]
@@ -261,17 +247,16 @@ fn profile_selection_build_all_targets_release() {
 [RUNNING] `[..]/target/release/build/foo-[..]/build-script-build`
 [foo 0.0.1] foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
 [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]`
-[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units={affected} --test [..]`
+[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..]`
 [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3[..]-C codegen-units=2 [..]`
-[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units={affected} --test [..]`
-[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units={affected} --test [..]`
-[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units={affected} --test [..]`
+[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..]`
+[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..]`
+[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..]`
 [RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]`
 [RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]`
 [FINISHED] release [optimized] [..]
-", affected=affected)).run();
+").run();
     p.cargo("build --all-targets --release -vv")
-        .masquerade_as_nightly_cargo()
         .with_stderr_unordered(
             "\
 [FRESH] bar [..]
@@ -286,7 +271,6 @@ fn profile_selection_build_all_targets_release() {
 #[cargo_test]
 fn profile_selection_test() {
     let p = all_target_project();
-    let affected = if is_nightly() { 3 } else { 1 };
     // `test`
     // NOTES:
     // - Dependency profiles:
@@ -308,33 +292,32 @@ fn profile_selection_test() {
     //   bin      test           test
     //   bin      test           build
     //
-    p.cargo("test -vv").masquerade_as_nightly_cargo().with_stderr_unordered(format!("\
+    p.cargo("test -vv").with_stderr_unordered("\
 [COMPILING] bar [..]
-[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units={affected} -C debuginfo=2 [..]
+[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 [..]
 [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..]
-[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units={affected} -C debuginfo=2 [..]
+[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=3 -C debuginfo=2 [..]
 [COMPILING] bdep [..]
 [RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..]
 [COMPILING] foo [..]
 [RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..]
 [RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build`
 [foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
-[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units={affected} -C debuginfo=2 [..]
-[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units={affected} -C debuginfo=2 [..]
+[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=3 -C debuginfo=2 [..]
+[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 [..]
 [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 --test [..]
 [RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 --test [..]
-[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units={affected} -C debuginfo=2 [..]
+[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 [..]
 [RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 --test [..]
-[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C panic=abort[..]-C codegen-units={affected} -C debuginfo=2 [..]
+[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C panic=abort[..]-C codegen-units=3 -C debuginfo=2 [..]
 [FINISHED] test [unoptimized + debuginfo] [..]
 [RUNNING] `[..]/deps/foo-[..]`
 [RUNNING] `[..]/deps/foo-[..]`
 [RUNNING] `[..]/deps/test1-[..]`
 [DOCTEST] foo
 [RUNNING] `rustdoc [..]--test [..]
-", affected=affected)).run();
+").run();
     p.cargo("test -vv")
-        .masquerade_as_nightly_cargo()
         .with_stderr_unordered(
             "\
 [FRESH] bar [..]
@@ -354,7 +337,6 @@ fn profile_selection_test() {
 #[cargo_test]
 fn profile_selection_test_release() {
     let p = all_target_project();
-    let affected = if is_nightly() { 2 } else { 4 };
 
     // `test --release`
     // NOTES:
@@ -377,7 +359,7 @@ fn profile_selection_test_release() {
     //   bin      release        test
     //   bin      release        build
     //
-    p.cargo("test --release -vv").masquerade_as_nightly_cargo().with_stderr_unordered(format!("\
+    p.cargo("test --release -vv").with_stderr_unordered("\
 [COMPILING] bar [..]
 [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..]
 [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]
@@ -390,9 +372,9 @@ fn profile_selection_test_release() {
 [foo 0.0.1] foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
 [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]
 [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3[..]-C codegen-units=2 [..]
-[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units={affected} --test [..]
-[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units={affected} --test [..]
-[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units={affected} --test [..]
+[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..]
+[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..]
+[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..]
 [RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link -C opt-level=3[..]-C codegen-units=2 [..]
 [RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]
 [FINISHED] release [optimized] [..]
@@ -401,9 +383,8 @@ fn profile_selection_test_release() {
 [RUNNING] `[..]/deps/test1-[..]`
 [DOCTEST] foo
 [RUNNING] `rustdoc [..]--test [..]`
-", affected=affected)).run();
+").run();
     p.cargo("test --release -vv")
-        .masquerade_as_nightly_cargo()
         .with_stderr_unordered(
             "\
 [FRESH] bar [..]
@@ -423,7 +404,6 @@ fn profile_selection_test_release() {
 #[cargo_test]
 fn profile_selection_bench() {
     let p = all_target_project();
-    let affected = if is_nightly() { 4 } else { 2 };
 
     // `bench`
     // NOTES:
@@ -445,10 +425,10 @@ fn profile_selection_bench() {
     //   bin      bench          test(bench)
     //   bin      bench          build
     //
-    p.cargo("bench -vv").masquerade_as_nightly_cargo().with_stderr_unordered(format!("\
+    p.cargo("bench -vv").with_stderr_unordered("\
 [COMPILING] bar [..]
-[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3[..]-C codegen-units={affected} [..]
-[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units={affected} [..]
+[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3[..]-C codegen-units=4 [..]
+[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=4 [..]
 [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..]
 [COMPILING] bdep [..]
 [RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..]
@@ -456,19 +436,18 @@ fn profile_selection_bench() {
 [RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=6 [..]
 [RUNNING] `[..]target/release/build/foo-[..]/build-script-build`
 [foo 0.0.1] foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
-[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units={affected} [..]
-[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3[..]-C codegen-units={affected} [..]
+[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=4 [..]
+[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3[..]-C codegen-units=4 [..]
 [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=4 --test [..]
 [RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=4 --test [..]
 [RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=4 --test [..]
-[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units={affected} [..]
+[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=4 [..]
 [FINISHED] bench [optimized] [..]
 [RUNNING] `[..]/deps/foo-[..] --bench`
 [RUNNING] `[..]/deps/foo-[..] --bench`
 [RUNNING] `[..]/deps/bench1-[..] --bench`
-", affected=affected)).run();
+").run();
     p.cargo("bench -vv")
-        .masquerade_as_nightly_cargo()
         .with_stderr_unordered(
             "\
 [FRESH] bar [..]
@@ -511,7 +490,7 @@ fn profile_selection_check_all_targets() {
     //   bin      dev            check
     //   bin      dev-panic      check-test (checking bin as a unittest)
     //
-    p.cargo("check --all-targets -vv").masquerade_as_nightly_cargo().with_stderr_unordered("\
+    p.cargo("check --all-targets -vv").with_stderr_unordered("\
 [COMPILING] bar [..]
 [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..]
 [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata[..]-C codegen-units=1 -C debuginfo=2 [..]
@@ -537,7 +516,6 @@ fn profile_selection_check_all_targets() {
     // rechecked.
     // See PR rust-lang/rust#49289 and issue rust-lang/cargo#3624.
     p.cargo("check --all-targets -vv")
-        .masquerade_as_nightly_cargo()
         .with_stderr_unordered(
             "\
 [FRESH] bar [..]
@@ -557,7 +535,7 @@ fn profile_selection_check_all_targets_release() {
     // This is a pretty straightforward variant of
     // `profile_selection_check_all_targets` that uses `release` instead of
     // `dev` for all targets.
-    p.cargo("check --all-targets --release -vv").masquerade_as_nightly_cargo().with_stderr_unordered("\
+    p.cargo("check --all-targets --release -vv").with_stderr_unordered("\
 [COMPILING] bar [..]
 [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..]
 [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata -C opt-level=3[..]-C codegen-units=2 [..]
@@ -580,7 +558,6 @@ fn profile_selection_check_all_targets_release() {
 ").run();
 
     p.cargo("check --all-targets --release -vv")
-        .masquerade_as_nightly_cargo()
         .with_stderr_unordered(
             "\
 [FRESH] bar [..]
@@ -595,7 +572,6 @@ fn profile_selection_check_all_targets_release() {
 #[cargo_test]
 fn profile_selection_check_all_targets_test() {
     let p = all_target_project();
-    let affected = if is_nightly() { 3 } else { 1 };
 
     // `check --profile=test`
     // - Dependency profiles:
@@ -618,27 +594,26 @@ fn profile_selection_check_all_targets_test() {
     //   bench    test-panic  check-test
     //   bin      test-panic  check-test
     //
-    p.cargo("check --all-targets --profile=test -vv").masquerade_as_nightly_cargo().with_stderr_unordered(format!("\
+    p.cargo("check --all-targets --profile=test -vv").with_stderr_unordered("\
 [COMPILING] bar [..]
 [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..]
-[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata[..]-C codegen-units={affected} -C debuginfo=2 [..]
+[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 [..]
 [COMPILING] bdep[..]
 [RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..]
 [COMPILING] foo [..]
 [RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..]
 [RUNNING] `[..]target/debug/build/foo-[..]/build-script-build`
 [foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
-[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]metadata[..]-C codegen-units={affected} -C debuginfo=2 [..]
-[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]metadata[..]-C codegen-units={affected} -C debuginfo=2 --test [..]
-[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]metadata[..]-C codegen-units={affected} -C debuginfo=2 --test [..]
-[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]metadata[..]-C codegen-units={affected} -C debuginfo=2 --test [..]
-[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]metadata[..]-C codegen-units={affected} -C debuginfo=2 --test [..]
-[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--emit=[..]metadata[..]-C codegen-units={affected} -C debuginfo=2 --test [..]
+[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 [..]
+[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 --test [..]
+[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 --test [..]
+[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 --test [..]
+[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 --test [..]
+[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 --test [..]
 [FINISHED] test [unoptimized + debuginfo] [..]
-", affected=affected)).run();
+").run();
 
     p.cargo("check --all-targets --profile=test -vv")
-        .masquerade_as_nightly_cargo()
         .with_stderr_unordered(
             "\
 [FRESH] bar [..]
@@ -664,7 +639,7 @@ fn profile_selection_doc() {
     //   foo  custom  dev*       link     For build.rs
     //
     //   `*` = wants panic, but it is cleared when args are built.
-    p.cargo("doc -vv").masquerade_as_nightly_cargo().with_stderr_unordered("\
+    p.cargo("doc -vv").with_stderr_unordered("\
 [COMPILING] bar [..]
 [DOCUMENTING] bar [..]
 [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..]