Skip to content

Commit

Permalink
Prevent duplicate monomorphization of deserialization impls
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bjorn3 committed Mar 13, 2022
1 parent a0b4d21 commit dca8ff5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/bootstrap/config.rs
Expand Up @@ -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);
Expand Down

0 comments on commit dca8ff5

Please sign in to comment.