Overview
Save Big on Coursera Plus. 7,000+ courses at $160 off. Limited Time Only!
Explore the intricacies of constant evaluation in Rust with this RustConf 2019 talk by Oliver Schneider. Delve into the new theoretically unrestricted constant evaluator in rustc, nicknamed Miri (MIR interpreter), and discover its potential for complex static initializations, microcontroller programming, and runtime code reduction. Learn about the grading of constant evaluators, necessary and unnecessary restrictions, and the challenges of heap allocations. Examine practical examples, including String implementations and unsafe operations in constants, while understanding the stricter rules applied at compile-time. Gain insights into compile-time undefined behavior, const assertions on stable Rust, and even witness a Fibonacci sequence calculated at compile-time. Perfect for Rust developers seeking to push the boundaries of constant evaluation and optimize their code.
Syllabus
Intro
Why const eval?
Grading constant evaluators
Why restrict ourselves?
What restrictions do we want?
What unnecessary restrictions do we have?
Open RFC
Details, details, details ...
Heap allocations...
Heap problems
Example with String
impl Send for &Sync
Unsafe in constants
compile time undefined behavior
Not UB
Much stricter rules at compile-time
Less stricter rules at compile-time
Summary
Don't try this at home
Const assertions on stable rust
Fibonacci at compile-time
Spot the fib
Taught by
Rust