From 85214f340c563305bb8c01312e707d0693a13cf9 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Wed, 29 May 2024 11:40:50 -0700 Subject: [PATCH 1/2] Move example code block to paragraph referencing it Noticed by Mario Carneiro. --- src/mir/index.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mir/index.md b/src/mir/index.md index 94d062c57..ff073bf38 100644 --- a/src/mir/index.md +++ b/src/mir/index.md @@ -62,12 +62,6 @@ show you the MIR for your program. Try putting this program into play button on the top: [sample-play]: https://play.rust-lang.org/?gist=30074856e62e74e91f06abd19bd72ece&version=stable -MIR shown by above link is optimized. -Some statements like `StorageLive` are removed in optimization. -This happens because the compiler notices the value is never accessed in the code. -We can use `rustc [filename].rs -Z mir-opt-level=0 --emit mir` to view unoptimized MIR. -This requires the nightly toolchain. - ```rust fn main() { @@ -88,6 +82,12 @@ fn main() -> () { ``` This is the MIR format for the `main` function. +MIR shown by above link is optimized. +Some statements like `StorageLive` are removed in optimization. +This happens because the compiler notices the value is never accessed in the code. +We can use `rustc [filename].rs -Z mir-opt-level=0 --emit mir` to view unoptimized MIR. +This requires the nightly toolchain. + **Variable declarations.** If we drill in a bit, we'll see it begins with a bunch of variable declarations. They look like this: From 506c3858696549b7fc9f2bfdd2828ebfe1eb6da4 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Wed, 29 May 2024 11:44:57 -0700 Subject: [PATCH 2/2] Use 2021 edition for example code playground link The playground defaults to 2015. Might as well use the latest edition. --- src/mir/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mir/index.md b/src/mir/index.md index ff073bf38..d540cc85f 100644 --- a/src/mir/index.md +++ b/src/mir/index.md @@ -61,7 +61,7 @@ show you the MIR for your program. Try putting this program into play (or [clicking on this link][sample-play]), and then clicking the "MIR" button on the top: -[sample-play]: https://play.rust-lang.org/?gist=30074856e62e74e91f06abd19bd72ece&version=stable +[sample-play]: https://play.rust-lang.org/?gist=30074856e62e74e91f06abd19bd72ece&version=stable&edition=2021 ```rust fn main() {