From 378a3c0363b572f670701f84eb806a1b6636fd0c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 7 Apr 2020 10:09:25 +0200 Subject: [PATCH] fix example --- personal/_posts/2020-04-04-layout-debugging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/personal/_posts/2020-04-04-layout-debugging.md b/personal/_posts/2020-04-04-layout-debugging.md index 7b8caa6..66000e0 100644 --- a/personal/_posts/2020-04-04-layout-debugging.md +++ b/personal/_posts/2020-04-04-layout-debugging.md @@ -83,7 +83,7 @@ the fields are at offsets 0 and 2, the type has alignment 2 (but preferred align We can also see that it uses the `ScalarPair` abi which is relevant for Miri and when passing data as arguments to another function. To learn more about what all this information means, see [the `Layout` type docs](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/abi/struct.Layout.html). -**Update:** After a suggestions by @jschievink, this can now also be used to print the [underlying type and layout](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=4aab680db88d1e3922bfb7e26103a125) of named opaque types, which is particularly useful [for generators](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=de99ab78a4d77bceee6760021b19de7d). **/Update** +**Update:** After a suggestions by @jschievink, this can now also be used to print the [underlying type and layout](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=1de2bed0c0d0f9171bfb41969f5028fb) of named opaque types, which is particularly useful [for generators](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=de99ab78a4d77bceee6760021b19de7d). **/Update** So the next time you work with `Layout` and wonder how exactly the niche gets represented, or whether an `enum` can have `ScalarPair` abi (hint: yes it can), you can easily look at a few examples to see how rustc thinks about this type internally. This is basically the type-level equivalent of `--emit mir`. -- 2.30.2