From de13d68cddef5bb321469bcffb868f27ddd5390e Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 12 Mar 2023 15:12:10 +0900 Subject: style: add .highlight class to pre tag --- .../rust-where-are-primitive-types-from/index.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'public/posts/2021-10-02/rust-where-are-primitive-types-from') 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 において、プリミティブ型の名前は予約語でない。したがって、次のコードは合法である。

-
+            
               #![allow(non_camel_case_types)]
 #![allow(dead_code)]
 
@@ -111,7 +111,7 @@ struct str;
               rustcはセルフホストされている (=rustc自身が Rust で書かれている) ので、boolcharなどで適当に検索をかけてもノイズが多すぎて話にならない。 しかし、お誂え向きなことにi128/u128というコンパイラ自身が使うことがなさそうな型が存在するのでこれを使ってgit grepしてみる。
             

-
+            
               $ git grep "\bi128\b" | wc      # i128
 165    1069   15790
 
@@ -126,7 +126,7 @@ $ git grep "\bbool\b" | wc      # cf. bool の結果
               165 程度であれば探すことができそうだ。今回は、クレート名を見ておおよその当たりをつけた。
             

-
+            
               $ git grep "\bi128\b"
 ...
 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));
               rustc_resolveというのはいかにも名前解決を担いそうなクレート名である。該当箇所を見てみる。
             

-
+            
               /// 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 の使用箇所を追う。追うと言っても使われている箇所は次の一箇所しかない。なお説明に不要な箇所は大きく削っている。
             

-
+            
                   /// 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
               動作がわかったところで、例として次のコードを考える。
             

-
+            
               #![allow(non_camel_case_types)]
 
 struct bool;
-- 
cgit v1.2.3-70-g09d2