Stream: t-compiler/help

Topic: valid constants


Christian Poveda (Feb 27 2019 at 18:13, on Zulip):

Hi everyone, I'd like to know what mechanism the compiler uses to decide which expressions are valid constants or valid inside a constant function

oli (Feb 28 2019 at 07:56, on Zulip):

There's currently two things, librustc_mir/transform/const_qualif.rs for constants and unstable const fn. Then there's librustc_mir/transform/qualif_min_const_fn.rs

oli (Feb 28 2019 at 07:57, on Zulip):

The latter is for stable const fn

Christian Poveda (Feb 28 2019 at 15:12, on Zulip):

thank you, I'm not familiarized with the structures shown in qualify_consts.rs, i can understand parts of it but not the whole picture. I suppose that at the end something qualify as a constant if is a part of a constant, is the result of a const fn or is the result of operating constants (excluding raw pointer operations), am I missing something?

oli (Feb 28 2019 at 15:59, on Zulip):

Well, there are some details like the differences between statics and constants wrt what is permitted and how promotion has special rules. Also we don't allow box keywords, but yes, most things boil down to safe primitives or const fn calls

Christian Poveda (Feb 28 2019 at 16:09, on Zulip):

ok then, thank you Oliver!

oli (Feb 28 2019 at 16:33, on Zulip):

Well, there are some details like the differences between statics and constants wrt what is permitted and how promotion has special rules. Also we don't allow box keywords, but yes, most things boil down to safe primitives or const fn calls

Last update: Nov 11 2019 at 23:00UTC