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.
This commit is contained in:
parent
a0b4d2136d
commit
dca8ff5b25
1 changed files with 5 additions and 1 deletions
|
@ -731,7 +731,11 @@ impl Config {
|
||||||
|
|
||||||
let contents =
|
let contents =
|
||||||
t!(fs::read_to_string(file), format!("config file {} not found", file.display()));
|
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,
|
Ok(table) => table,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
println!("failed to parse TOML configuration '{}': {}", file.display(), err);
|
println!("failed to parse TOML configuration '{}': {}", file.display(), err);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue