Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
公式サンプルが コンパイルできない 〜tracing::info! のエラーから Rust の...
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Retasusan
September 27, 2026
Technology
90
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
公式サンプルが コンパイルできない 〜tracing::info! のエラーから Rust のマクロを読む〜
Retasusan
September 27, 2026
More Decks by Retasusan
See All by Retasusan
JavaScriptのnullとundefinedの違い
retasusan
0
200
Other Decks in Technology
See All in Technology
1つのリクエストを追って理解する - llm-dのP/D分離
akhino
1
170
データエンジニアの次の戦場は "プロセスエンジニアリング"
sansantech
PRO
1
110
LambdaWebFunctionsを試してみた / exploring-lambda-web-functions
koukihosaka
1
360
古い指輪から広がった JAVA コミュニティ とのつながり
yamad
0
130
実践!Cloud Run ハンズオン!! / Cloud Run handson
y0hgi
2
300
Kiro Crewで「みのるん式」仕事術やってみた
minorun365
PRO
3
740
フロントエンドカンファレンス関西2026 - 速すぎるUIに、待ち時間を
teamlab
PRO
0
190
AI コーディングと人間の認知スループット / CTO Night & Day 2026 Morning Session / AI Coding and Human Cognitive Throughput
prog893
5
1.3k
価値について
gree_tech
PRO
0
110
DBについての基礎説明(MySQL編) - コロプラ 2026年度 新卒研修
colopl
0
130
Claude の新機能を、 出た日に触って社内に届けるまで
rfdnxbro
1
190
SAENM ~Jupyterで残すPoCの試行錯誤、未来の自分と仲間を助ける記録!~
terapyon
0
120
Featured
See All Featured
BBQ
matthewcrist
90
10k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Documentation Writing (for coders)
carmenintech
77
5.6k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
450
Design in an AI World
tapps
1
350
It's Worth the Effort
3n
188
29k
GitHub's CSS Performance
jonrohan
1033
470k
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
1k
Transcript
公式サンプルが コンパイルできない tracing::info! のエラーから Rust のマクロを読む @Retasusan / Kyoto.rs #2
⾃⼰紹介 @Retasusan 普段 普段は⼤学3回⽣やってます 最近研究室に配属されました 後最近、⻭が⽋けました 最近の散財 Xで⾒つけたプロンプトで⽣成した右の⼦を 気に⼊ってしまって、この⼦の前掛けを 作ってしまった
散財紹介 シャツも作っちゃった…
直前までLTのネタが決まらない とりあえず何かのコードを読もう 最近、気になっていたOpenTelemetryのRust実装を読むことにする 調査の出発点
読み⽅がわからない‧読んでも分からない 読めない理由の仮説 • ユースケースが良くわかっていない状態で読もうとしているか ら • Rustにあまり詳しくないから 調査の出発点
読み⽅がわからない‧読んでも分からない 読めない理由の仮説 • ユースケースが良くわかっていない状態で読もうとしているか ら ←まだ攻めやすそう • Rustにあまり詳しくないから ←時間的に厳しい 調査の出発点
まず隗より始めよ • 物事を⾏うときはまず⾝近なところから始めよという意味 まず、 Getting Started を動かし呼び出しから逆に実装を追う 調査の出発点
Getting Started で全体をつかむ サイコロを振る HTTP サンプル 結構⻑いので、⼀度実⾏してから読むことにする ミクロではなく、 まずはマクロの視点で全体を把握しようという試み 実⾏はみんな⼤好き(?)
$ cargo run OpenTelemetry Rust Getting Started https://opentelemetry.io/docs/languages/rust/getting-started/ main.rsのコード
Getting Started実⾏結果 Rust コンパイラが出したエラー
Getting Started おや? Rust コンパイラが出したエラー
Getting Started Rust コンパイラが出したエラー
Getting Started 「全体像をつかむには、まずマクロな視点が⼤事」 Rust コンパイラが出したエラー
Getting Started 「全体像をつかむには、まずマクロな視点が⼤事」 Rust コンパイラが出したエラー
Getting Started 「全体像をつかむには、まずマクロな視点が⼤事」 マクロ発⾒ Rust コンパイラが出したエラー
このマクロを調査してみた件についてのLTです マクロ発⾒ Rust コンパイラが出したエラー
エラーの原因箇所 公式サンプルの呼び出し 公式サンプル:https://opentelemetry.io/docs/languages/rust/getting-started/
そもそもtracing traitって何者? tracing is a framework for instrumenting Rust programs
to collect structured, event-based diagnostic information. tracingは、構造化されたイベントベースの診断情報を収集するために、 Rustプログラムを計測す るためのフレームワークです。 docs.rs/tracingより docs.rs/tracing:https://docs.rs/tracing/latest/tracing/
そもそもtracing traitって何者? tracing is a framework for instrumenting Rust programs
to collect structured, event-based diagnostic information. tracingは、構造化されたイベントベースの診断情報を収集するために、 Rustプログラムを計測す るためのフレームワークです。 docs.rs/tracingより わかったような分からないような? docs.rs/tracing:https://docs.rs/tracing/latest/tracing/
tracing crate docs.rs/tracing:https://docs.rs/tracing/latest/tracing/
マクロは⼊⼒からコードを作る 例 呼び出しと展開のイメージ show!(score) ↓ score = 80 マクロはコードを受け取る。 渡したコードを⾒て”score”という⽂字も作れる
`!` が呼び出しの⽬印。照合と展開はコンパイル中。
info! もマクロとして⼊⼒を読む 呼び出しに渡す⼊⼒ マクロがすること ⼊⼒を左から読み、 ルールに照合する。 合うルールが決まれば、そのルールのコードを展開する。 今回は照合中に `.` の扱いで迷い、展開まで進めなかった。
Rust Reference: Macros by Example
info! の定義 いっぱいある この中から一致するもので解釈される Rust Reference: Macros by Example:https://docs.rs/tracing/latest/tracing/macro.info.html
問題の⼊⼒は roll.value ここでの `.` `roll.value` は フィールド名。 右辺は記録する値。 error: local
ambiguity when calling macro `info` `local ambiguity`: この `.` をどの部分が読むか決められない。 OpenTelemetry Rust Getting Started
info! の定義の要点だけ抜く (name: $name:expr, $($k:ident).+ $($field:tt)*) $name:expr $($k:ident).+ $($field:tt)* Event
名の値 roll と value を ピリオドでつなぐ 残りのトークン。 ピリオドも含められる 同じピリオドを左側の区切りにも、右側の⼊⼒にもできる。 出典: docs.rs/tracing/latest/src/tracing/macros.rs.html
ピリオドで2通りに分かれる roll . value = random_number 解釈 A: k =
roll.value / field =「= random_number, ...」 解釈 B: k = roll / field =「. value = random_number, ...」 候補A: 名前を続ける 候補B: 残りを始める roll.value のピリオドを 名前の区切りとして読む roll で名前を終え、 ピリオドから残りを読む Rust は次の `value` を⾒て選び直さない → local ambiguity Rust Reference: macro_rules! は局所的な曖昧さを先読みで解消しない
修正案 元の書き⽅ 修正案 波括弧でフィールドの範囲を明⽰すると、読み⽅が確定する { ... } がフィールド。 ⽂字列が本⽂。
修正案 修正案 波括弧でフィールドの範囲を明⽰すると、読み⽅が確定する {}をつけると{}の中で、fieldset!を呼び出す $($k:ident).+ = $val:expr, $($rest:tt)*
issue を投げた 報告した内容 1. `cargo run` での再現⼿順 2. コンパイラのエラー 3.
波括弧を使う修正案 github.com/open-telemetry/opentelemetry.io/issues/11823
ご清聴いただきありがとうございました