From 33436c85f06fb4b1e4ae4926fa0272adcbb67e96 Mon Sep 17 00:00:00 2001 From: Prashant-Shekhar-Rao <139104389+Prashant-Shekhar-Rao@users.noreply.github.com> Date: Thu, 7 Sep 2023 19:18:37 +0530 Subject: [PATCH 1/3] Updated index.md to add a command which can show unoptimized MIR The current playground link used in the page of MIR shows a optimized version of MIR which is missing some statements such as StorageLive . Updated to use a local command which shows unoptimized MIR that would be more useful for pedagogical purposes. --- src/mir/index.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mir/index.md b/src/mir/index.md index dc0be167b..b90c5ad83 100644 --- a/src/mir/index.md +++ b/src/mir/index.md @@ -62,6 +62,12 @@ 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 compiler notices the value is never acessed 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() { From c21ab4f0a54a1d4e0f459d3579c83154b1b125bf Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Fri, 8 Sep 2023 12:57:33 +0200 Subject: [PATCH 2/3] typo --- 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 b90c5ad83..20cbf75d2 100644 --- a/src/mir/index.md +++ b/src/mir/index.md @@ -64,7 +64,7 @@ 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 compiler notices the value is never acessed in the code. +This happens because 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. From ef1640bbf23d1407a5d4fdb2acb2fd9f0647ef69 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Fri, 8 Sep 2023 12:58:20 +0200 Subject: [PATCH 3/3] grammar --- 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 20cbf75d2..7027cd803 100644 --- a/src/mir/index.md +++ b/src/mir/index.md @@ -64,7 +64,7 @@ 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 compiler notices the value is never accessed in the code. +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.