Skip to content

Commit 07d0d7c

Browse files
committed
Auto merge of #123364 - klensy:bs-mixed-types, r=albertlarsan68
bootstrap: actually allow set debuginfo-level to "line-tables-only" I've tried to set in config.toml `rust.debuginfo-level = "line-tables-only"`, but ended with: ``` failed to parse TOML configuration 'config.toml': data did not match any variant of untagged enum StringOrInt for key `rust.debuginfo-level` ``` Also this PR allows to set `line-directives-only` for debuginfo in config.toml too. 1. Fixes this. Alternative is remove that Deserialize and use default one: https://github.com/rust-lang/rust/blob/0e682e9875458ebf811206a48b688e07d762d9bb/src/bootstrap/src/core/config/config.rs#L725-L728 2. Should `line-directives-only` be added too? 3. I've tried to add test to rust/src/bootstrap/src/core/config/tests.rs: ```rust #[test] fn rust_debuginfo() { assert!(matches!( parse("rust.debuginfo-level-rustc = 1").rust_debuginfo_level_rustc, DebuginfoLevel::Limited )); assert!(matches!( parse("rust.debuginfo-level-rustc = \"line-tables-only\"").rust_debuginfo_level_rustc, DebuginfoLevel::LineTablesOnly )); } ``` But test passes before that PR too; looks like config parse tests checks something wrong? I mean, that tests check something which isn't actual bootstrap behavior.
2 parents 43a0686 + 1d929cf commit 07d0d7c

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

config.example.toml

+2-5
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,8 @@
517517
#overflow-checks-std = rust.overflow-checks (boolean)
518518

519519
# Debuginfo level for most of Rust code, corresponds to the `-C debuginfo=N` option of `rustc`.
520-
# `0` - no debug info
521-
# `1` - line tables only - sufficient to generate backtraces that include line
522-
# information and inlined functions, set breakpoints at source code
523-
# locations, and step through execution in a debugger.
524-
# `2` - full debug info with variable and type information
520+
# See https://doc.rust-lang.org/rustc/codegen-options/index.html#debuginfo for available options.
521+
#
525522
# Can be overridden for specific subsets of Rust code (rustc, std or tools).
526523
# Debuginfo for tests run with compiletest is not controlled by this option
527524
# and needs to be enabled separately with `debuginfo-level-tests`.

src/bootstrap/src/core/config/config.rs

+15-7
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pub enum DryRun {
5555
pub enum DebuginfoLevel {
5656
#[default]
5757
None,
58+
LineDirectivesOnly,
5859
LineTablesOnly,
5960
Limited,
6061
Full,
@@ -70,16 +71,22 @@ impl<'de> Deserialize<'de> for DebuginfoLevel {
7071
use serde::de::Error;
7172

7273
Ok(match Deserialize::deserialize(deserializer)? {
73-
StringOrInt::String("none") | StringOrInt::Int(0) => DebuginfoLevel::None,
74-
StringOrInt::String("line-tables-only") => DebuginfoLevel::LineTablesOnly,
75-
StringOrInt::String("limited") | StringOrInt::Int(1) => DebuginfoLevel::Limited,
76-
StringOrInt::String("full") | StringOrInt::Int(2) => DebuginfoLevel::Full,
74+
StringOrInt::String(s) if s == "none" => DebuginfoLevel::None,
75+
StringOrInt::Int(0) => DebuginfoLevel::None,
76+
StringOrInt::String(s) if s == "line-directives-only" => {
77+
DebuginfoLevel::LineDirectivesOnly
78+
}
79+
StringOrInt::String(s) if s == "line-tables-only" => DebuginfoLevel::LineTablesOnly,
80+
StringOrInt::String(s) if s == "limited" => DebuginfoLevel::Limited,
81+
StringOrInt::Int(1) => DebuginfoLevel::Limited,
82+
StringOrInt::String(s) if s == "full" => DebuginfoLevel::Full,
83+
StringOrInt::Int(2) => DebuginfoLevel::Full,
7784
StringOrInt::Int(n) => {
7885
let other = serde::de::Unexpected::Signed(n);
7986
return Err(D::Error::invalid_value(other, &"expected 0, 1, or 2"));
8087
}
8188
StringOrInt::String(s) => {
82-
let other = serde::de::Unexpected::Str(s);
89+
let other = serde::de::Unexpected::Str(&s);
8390
return Err(D::Error::invalid_value(
8491
other,
8592
&"expected none, line-tables-only, limited, or full",
@@ -95,6 +102,7 @@ impl Display for DebuginfoLevel {
95102
use DebuginfoLevel::*;
96103
f.write_str(match self {
97104
None => "0",
105+
LineDirectivesOnly => "line-directives-only",
98106
LineTablesOnly => "line-tables-only",
99107
Limited => "1",
100108
Full => "2",
@@ -1021,8 +1029,8 @@ impl RustOptimize {
10211029

10221030
#[derive(Deserialize)]
10231031
#[serde(untagged)]
1024-
enum StringOrInt<'a> {
1025-
String(&'a str),
1032+
enum StringOrInt {
1033+
String(String),
10261034
Int(i64),
10271035
}
10281036

0 commit comments

Comments
 (0)