diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2022-03-03 18:44:02 +0100 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2022-03-13 14:34:49 +0100 |
| commit | dca8ff5b252ce2430fa61e6a5bd230b1edc9ea50 (patch) | |
| tree | 2a6d8c72d926481f3f30aee23288a5de692ba09d | |
| parent | a0b4d2136d639590fa2be32f8b092c5766bc92af (diff) | |
| download | rust-dca8ff5b252ce2430fa61e6a5bd230b1edc9ea50.tar.gz rust-dca8ff5b252ce2430fa61e6a5bd230b1edc9ea50.zip | |
Prevent duplicate monomorphization of deserialization impls
This reduces binary size from 9.7MiB (5.8MiB for just rustbuild code) to 9.3MiB (5.3MiB for just rustbuild code). This doesn't reduce compile time in a statistically significant way.
| -rw-r--r-- | src/bootstrap/config.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 762f18fb32f..6e8471b1de7 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -731,7 +731,11 @@ impl Config { let contents = t!(fs::read_to_string(file), format!("config file {} not found", file.display())); - match toml::from_str(&contents) { + // Deserialize to Value and then TomlConfig to prevent the Deserialize impl of + // TomlConfig and sub types to be monomorphized 5x by toml. + match toml::from_str(&contents) + .and_then(|table: toml::Value| TomlConfig::deserialize(table)) + { Ok(table) => table, Err(err) => { println!("failed to parse TOML configuration '{}': {}", file.display(), err); |
