I am manually writing out some mono ir in rust. I am trying to call the List.sublist
builtin. To do that, I first have to create a symbol that stores the parameters. To bind the symbol I have to specify the layout.
example code:
let sublist_params_sym = env.unique_symbol();
let sublist_params_expr = Expr::Struct(env.arena.alloc([start_sym, rest_len_sym]));
let sublist_params_layout = ???;
stmt = Stmt::Let(
sublist_params_sym,
sublist_params_expr,
sublist_params_layout,
env.arena.alloc(stmt),
);
I tried to build the layout manually, but the fields are private, so this must be the wrong way to generate it:
let sublist_params_layout = layout_cache.interner.insert(Layout {
repr: LayoutWrapper::Direct(LayoutRepr::Struct(env.arena.alloc([
usize_layout,
usize_layout,
]))),
semantic: SemanticRepr::record(env.arena.alloc(["start", "len"])),
}));
Any help?
Are you working in mono?
There's Layout::new
What are you trying to do though? Generally constructing a layout directly is not preferred
Trying to fix binding rest in a list pattern match.
Also, turns out the that low level doesn't use the struct, so I didn't need the layout.
#6030 for context
Last updated: Jul 06 2025 at 12:14 UTC