# HG changeset patch # User Arseniy Alekseyev # Date 1677522269 0 # Node ID af9d050f2bb8bd2c4048a11998c6038a05a8fb90 # Parent 3f3fca243dcaf3f0089372eec12d3195fcb20e7c rust: box ConfigValueParseError to avoid large result types clippy emits a warning that all the Result types are way too large because of HgError includes ConfigValueParseError as one of the variants, so its size is 136 bytes. By boxing ConfigValueParseError we're hopefully making everything faster "for free". diff -r 3f3fca243dca -r af9d050f2bb8 rust/hg-core/src/config/mod.rs --- a/rust/hg-core/src/config/mod.rs Wed Feb 22 02:08:11 2023 +0100 +++ b/rust/hg-core/src/config/mod.rs Mon Feb 27 18:24:29 2023 +0000 @@ -64,7 +64,7 @@ } #[derive(Debug)] -pub struct ConfigValueParseError { +pub struct ConfigValueParseErrorDetails { pub origin: ConfigOrigin, pub line: Option, pub section: Vec, @@ -73,6 +73,9 @@ pub expected_type: &'static str, } +// boxed to avoid very large Result types +pub type ConfigValueParseError = Box; + impl fmt::Display for ConfigValueParseError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // TODO: add origin and line number information, here and in @@ -354,14 +357,14 @@ match self.get_inner(section, item) { Some((layer, v)) => match parse(&v.bytes) { Some(b) => Ok(Some(b)), - None => Err(ConfigValueParseError { + None => Err(Box::new(ConfigValueParseErrorDetails { origin: layer.origin.to_owned(), line: v.line, value: v.bytes.to_owned(), section: section.to_owned(), item: item.to_owned(), expected_type, - }), + })), }, None => Ok(None), }