Skip to content

Commit dca8ff5

Browse files
committed
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.
1 parent a0b4d21 commit dca8ff5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/bootstrap/config.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,11 @@ impl Config {
731731

732732
let contents =
733733
t!(fs::read_to_string(file), format!("config file {} not found", file.display()));
734-
match toml::from_str(&contents) {
734+
// Deserialize to Value and then TomlConfig to prevent the Deserialize impl of
735+
// TomlConfig and sub types to be monomorphized 5x by toml.
736+
match toml::from_str(&contents)
737+
.and_then(|table: toml::Value| TomlConfig::deserialize(table))
738+
{
735739
Ok(table) => table,
736740
Err(err) => {
737741
println!("failed to parse TOML configuration '{}': {}", file.display(), err);

0 commit comments

Comments
 (0)