diff --git a/src/ast.rs b/src/ast.rs index ebf38250..4a31d1f9 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -83,6 +83,10 @@ impl FnAccess { /// This type is volatile and may change. #[derive(Debug, Clone)] pub struct ScriptFnDef { + /// Function body. + pub body: Stmt, + /// Encapsulated running environment, if any. + pub lib: Option>, /// Function name. pub name: ImmutableString, /// Function access mode. @@ -92,12 +96,6 @@ pub struct ScriptFnDef { /// Access to external variables. #[cfg(not(feature = "no_closure"))] pub externals: HashSet, - /// Function body. - pub body: Stmt, - /// Position of the function definition. - pub pos: Position, - /// Encapsulated running environment, if any. - pub lib: Option>, } impl fmt::Display for ScriptFnDef { @@ -1240,3 +1238,19 @@ impl Expr { } } } + +#[cfg(test)] +mod tests { + use super::*; + + /// This test is to make sure no code changes increase the sizes of critical data structures. + #[test] + fn check_struct_sizes() { + use std::mem::size_of; + + assert_eq!(size_of::(), 16); + assert_eq!(size_of::>(), 16); + assert_eq!(size_of::(), 16); + assert_eq!(size_of::(), 32); + } +} diff --git a/src/optimize.rs b/src/optimize.rs index 3778a7b1..e549fc8b 100644 --- a/src/optimize.rs +++ b/src/optimize.rs @@ -866,7 +866,6 @@ pub fn optimize_into_ast( params: fn_def.params.clone(), #[cfg(not(feature = "no_closure"))] externals: fn_def.externals.clone(), - pos: fn_def.pos, lib: None, } .into() diff --git a/src/parser.rs b/src/parser.rs index d808522e..448df46f 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -2485,7 +2485,6 @@ fn parse_fn( #[cfg(not(feature = "no_closure"))] externals, body, - pos: settings.pos, lib: None, }) } @@ -2655,7 +2654,6 @@ fn parse_anon_fn( #[cfg(not(feature = "no_closure"))] externals: Default::default(), body, - pos: settings.pos, lib: None, };