aboutsummaryrefslogtreecommitdiffhomepage
path: root/public/posts/2021-10-02/rust-where-are-primitive-types-from
diff options
context:
space:
mode:
Diffstat (limited to 'public/posts/2021-10-02/rust-where-are-primitive-types-from')
-rw-r--r--public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html12
1 files changed, 6 insertions, 6 deletions
diff --git a/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html b/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html
index 8879a79..8bcb923 100644
--- a/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html
+++ b/public/posts/2021-10-02/rust-where-are-primitive-types-from/index.html
@@ -55,7 +55,7 @@
Rust において、プリミティブ型の名前は予約語でない。したがって、次のコードは合法である。
</p>
- <pre language="rust" linenumbering="unnumbered">
+ <pre class="highlight" language="rust" linenumbering="unnumbered">
<code>#![allow(non_camel_case_types)]
#![allow(dead_code)]
@@ -111,7 +111,7 @@ struct str;</code>
<code>rustc</code>はセルフホストされている (=<code>rustc</code>自身が Rust で書かれている) ので、<code>bool</code>や<code>char</code>などで適当に検索をかけてもノイズが多すぎて話にならない。 しかし、お誂え向きなことに<code>i128</code>/<code>u128</code>というコンパイラ自身が使うことがなさそうな型が存在するのでこれを使って<code>git grep</code>してみる。
</p>
- <pre class="monospaced">
+ <pre class="monospaced highlight">
<code>$ git grep &quot;\bi128\b&quot; | wc # i128
165 1069 15790
@@ -126,7 +126,7 @@ $ git grep &quot;\bbool\b&quot; | wc # cf. bool の結果
165 程度であれば探すことができそうだ。今回は、クレート名を見ておおよその当たりをつけた。
</p>
- <pre class="monospaced">
+ <pre class="monospaced highlight">
<code>$ git grep &quot;\bi128\b&quot;
...
rustc_resolve/src/lib.rs: table.insert(sym::i128, Int(IntTy::I128));
@@ -137,7 +137,7 @@ rustc_resolve/src/lib.rs: table.insert(sym::i128, Int(IntTy::I128));
<code>rustc_resolve</code>というのはいかにも名前解決を担いそうなクレート名である。該当箇所を見てみる。
</p>
- <pre language="rust" linenumbering="unnumbered">
+ <pre class="highlight" language="rust" linenumbering="unnumbered">
<code>/// Interns the names of the primitive types.
///
/// All other types are defined somewhere and possibly imported, but the primitive ones need
@@ -186,7 +186,7 @@ Self { primitive_types: table }
とある。次はこの struct の使用箇所を追う。追うと言っても使われている箇所は次の一箇所しかない。なお説明に不要な箇所は大きく削っている。
</p>
- <pre language="rust" linenumbering="unnumbered">
+ <pre class="highlight" language="rust" linenumbering="unnumbered">
<code> /// This resolves the identifier `ident` in the namespace `ns` in the current lexical scope.
/// (略)
fn resolve_ident_in_lexical_scope(
@@ -226,7 +226,7 @@ None
動作がわかったところで、例として次のコードを考える。
</p>
- <pre language="rust" linenumbering="unnumbered">
+ <pre class="highlight" language="rust" linenumbering="unnumbered">
<code>#![allow(non_camel_case_types)]
struct bool;