Stream: t-compiler/const-eval

Topic: Which kind of operands functions are?


Christian Poveda (Mar 15 2019 at 00:59, on Zulip):

I'm trying to follow the execution of a function from a call terminator on MIR (https://github.com/rust-lang/rust/blob/f058741a679062202697144daebd05e1b0d6d747/src/librustc_mir/interpret/terminator.rs#L77) and I wanted to know which kind of operands (https://github.com/rust-lang/rust/blob/f058741a679062202697144daebd05e1b0d6d747/src/librustc/mir/mod.rs#L2113) functions are

Christian Poveda (Mar 15 2019 at 01:22, on Zulip):

I assume functions declared with fn () {...} are just constants?

Matthew Jasper (Mar 15 2019 at 07:29, on Zulip):

Yes

Christian Poveda (Mar 15 2019 at 14:38, on Zulip):

On which stage rustc stores functions to be called later?

Wesley Wiser (Mar 15 2019 at 14:39, on Zulip):

What do you mean by "stores functions"?

Christian Poveda (Mar 15 2019 at 14:47, on Zulip):

Well right now I understand that in order to evaluate a function, const-eval adds a new frame to the stack with a reference to the MIR of the function. Where are the representations of functions stored to be retrieved?

Wesley Wiser (Mar 15 2019 at 15:07, on Zulip):

The MIR for the function is stored in a side table in the TyCtxt which is accessed by DefId. The query you're probably most interested in is tcx.mir_const() https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.TyCtxt.html#method.mir_const

oli (Mar 15 2019 at 15:32, on Zulip):

Const eval actually uses the optimized_mir query. mir_const is only for const qualification

Wesley Wiser (Mar 15 2019 at 15:42, on Zulip):

Oops. Thanks @oli

Christian Poveda (Mar 16 2019 at 18:11, on Zulip):

Ok now I've got weekend reading material, thank you :D

Last update: Nov 15 2019 at 20:10UTC