Skip to content

Commit c916d36

Browse files
committed
feat(profile): Add built-in profile debug
Key points: - It inherits from `dev` - Conceptually, debugging is part of the development process - The hope is this will smooth out the transition for people - `cargo install --debug` now uses `debug` instead of `dev` - `debug` changes nothing from `dev` right now. `dev` will evolve in the future (with `debug` overriding those values to leave it effectively unchanged) but that is deferred out to offer a transition period where `debug` can be used without but isn't required for debugging as people deal with multiple Rust versions. This also shrinks the change and decouples what the conversation around what the settings should be.
1 parent 0cc4686 commit c916d36

21 files changed

Lines changed: 66 additions & 58 deletions

File tree

crates/cargo-util-schemas/src/restricted_names.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,6 @@ pub(crate) fn validate_profile_name(name: &str) -> Result<()> {
137137
}
138138

139139
let lower_name = name.to_lowercase();
140-
if lower_name == "debug" {
141-
return Err(ErrorKind::ProfileNameReservedKeyword {
142-
name: name.into(),
143-
help: "To configure the default development profile, \
144-
use the name `dev` as in [profile.dev]",
145-
}
146-
.into());
147-
}
148140
if lower_name == "build-override" {
149141
return Err(ErrorKind::ProfileNameReservedKeyword {
150142
name: name.into(),

doc/book/src/commands/cargo-bench.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ function to handle running benchmarks.
4646
4747
By default, `cargo bench` uses the [`bench` profile], which enables
4848
optimizations and disables debugging information. If you need to debug a
49-
benchmark, you can use the `--profile=dev` command-line option to switch to
50-
the dev profile. You can then run the debug-enabled benchmark within a
49+
benchmark, you can use the `--profile=debug` command-line option to switch to
50+
the debug profile. You can then run the debug-enabled benchmark within a
5151
debugger.
5252

5353
[`bench` profile]: ../reference/profiles.html#bench

doc/book/src/commands/cargo-install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ is specified.</p>
260260

261261

262262
<dt class="option-term" id="option-cargo-install---debug"><a class="option-anchor" href="#option-cargo-install---debug"><code>--debug</code></a></dt>
263-
<dd class="option-desc"><p>Build with the <code>dev</code> profile instead of the <code>release</code> profile.
263+
<dd class="option-desc"><p>Build with the <code>debug</code> profile instead of the <code>release</code> profile.
264264
See also the <code>--profile</code> option for choosing a specific profile by name.</p>
265265
</dd>
266266

doc/book/src/commands/cargo-test.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ manifest settings, in which case your code will need to provide its own `main`
3838
function to handle running tests.
3939

4040
By default, `cargo test` uses the [`test` profile], which enables
41-
debugging.
41+
some optimizations and disables debugging information for fast feedback. If you need to debug a
42+
test, you can use the `--profile=debug` command-line option to switch to
43+
the debug profile. You can then run the debug-enabled test within a
44+
debugger.
4245

4346
[`test` profile]: ../reference/profiles.html#test
4447

doc/book/src/reference/profiles.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ whether or not [`rpath`] is enabled.
262262

263263
### dev
264264

265-
The `dev` profile is used for normal development and debugging. It is the
266-
default for build commands like [`cargo build`], and is used for `cargo install --debug`.
265+
The `dev` profile is used for normal development. It is the
266+
default for build commands like [`cargo build`], and is used for `cargo install --profile dev`.
267267

268268
The default settings for the `dev` profile are:
269269

@@ -282,6 +282,17 @@ codegen-units = 256
282282
rpath = false
283283
```
284284

285+
### debug
286+
287+
The `debug` profile is used for creating binaries to run with a debugger. It is used with `cargo build --profile debug` and `cargo install --debug`.
288+
289+
The default settings for the `debug` profile are:
290+
291+
```toml
292+
[profile.debug]
293+
inherits = "dev"
294+
```
295+
285296
### release
286297

287298
The `release` profile is intended for optimized artifacts used for releases

doc/man/cargo-bench.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ function to handle running benchmarks.
5151
5252
By default, `cargo bench` uses the [`bench` profile], which enables
5353
optimizations and disables debugging information. If you need to debug a
54-
benchmark, you can use the `--profile=dev` command-line option to switch to
55-
the dev profile. You can then run the debug-enabled benchmark within a
54+
benchmark, you can use the `--profile=debug` command-line option to switch to
55+
the debug profile. You can then run the debug-enabled benchmark within a
5656
debugger.
5757

5858
[`bench` profile]: ../reference/profiles.html#bench

doc/man/cargo-install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ Directory to install packages into.
178178
{{> options-target-dir }}
179179

180180
{{#option "`--debug`" }}
181-
Build with the `dev` profile instead of the `release` profile.
181+
Build with the `debug` profile instead of the `release` profile.
182182
See also the `--profile` option for choosing a specific profile by name.
183183
{{/option}}
184184

doc/man/cargo-test.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ manifest settings, in which case your code will need to provide its own `main`
4343
function to handle running tests.
4444

4545
By default, `cargo test` uses the [`test` profile], which enables
46-
debugging.
46+
some optimizations and disables debugging information for fast feedback. If you need to debug a
47+
test, you can use the `--profile=debug` command-line option to switch to
48+
the debug profile. You can then run the debug-enabled test within a
49+
debugger.
4750

4851
[`test` profile]: ../reference/profiles.html#test
4952

doc/man/generated_txt/cargo-bench.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ DESCRIPTION
4646
By default, cargo bench uses the bench profile
4747
<https://doc.rust-lang.org/cargo/reference/profiles.html#bench>, which
4848
enables optimizations and disables debugging information. If you need to
49-
debug a benchmark, you can use the --profile=dev command-line option to
50-
switch to the dev profile. You can then run the debug-enabled benchmark
51-
within a debugger.
49+
debug a benchmark, you can use the --profile=debug command-line option
50+
to switch to the debug profile. You can then run the debug-enabled
51+
benchmark within a debugger.
5252

5353
Working directory of benchmarks
5454
The working directory of every benchmark is set to the root directory of

doc/man/generated_txt/cargo-install.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ OPTIONS
226226
workspace of the local crate unless --target-dir is specified.
227227

228228
--debug
229-
Build with the dev profile instead of the release profile. See also
230-
the --profile option for choosing a specific profile by name.
229+
Build with the debug profile instead of the release profile. See
230+
also the --profile option for choosing a specific profile by name.
231231

232232
--profile name
233233
Install with the given profile. See the reference

0 commit comments

Comments
 (0)