pub fn compact(module: &mut Module, keep_unused: KeepUnused)
Expand description
Remove most unused objects from module
, which must be valid.
Always removes the following unused objects:
- anonymous types, overrides, and constants
- abstract-typed constants
- expressions
If keep_unused
is Yes
, the following are never considered unused,
otherwise, they will also be removed if unused:
- functions
- global variables
- named types and overrides
The following are never removed:
- named constants with a concrete type
- special types
- entry points
- within an entry point or a used function:
- arguments
- local variables
- named expressions
After removing items according to the rules above, all handles in the
remaining objects are adjusted as necessary. When KeepUnused
is Yes
, the
resulting module should have all the named objects (except abstract-typed
constants) present in the original, and those objects should be functionally
identical. When KeepUnused
is No
, the resulting module should have the
entry points present in the original, and those entry points should be
functionally identical.
§Panics
If module
would not pass validation, this may panic.