TypeId constant in patterns has confusing error message
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start with the pattern-matching diagnostic path and the related pull request #166205 mentioned in the issue. Reproduce the example with the reported nightly compiler, then trace why matching the TypeId constant produces the raw-pointer unpredictability error instead of a StructuralPartialEq error. Done when the diagnostic reports the expected reason and relevant compiler tests cover the case.
索引モデルが issue の本文から書いたものです。
説明
I tried this code:
use std::any::TypeId;
const abc: TypeId = TypeId::of::<i32>();
fn main() {
match TypeId::of::<i32>() {
abc => {},
_ => {},
}
}
I expected to see this happen: It gives an error mentioning that TypeId is not StructuralPartialEq
Instead, this happened: I get an error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
Meta
rustc --version --verbose:
rustc 1.102.0-nightly (5df8c02af 2026-11-16)
binary: rustc
commit-hash: 5df8c02afdf6b882bc301442cea70f026e3d3974
commit-date: 2026-11-16
host: x86_64-unknown-linux-gnu
release: 1.102.0-nightly
LLVM version: 23.1.5
From what I can tell, it seems to think that TypeId is a function pointer, but not other structs. Not related to the provenience either as copying the data field from TypeId into a local struct doesn't reproduce. I was told that this issue may be relevant as well.
- 主要言語
- Rust
- スター
- 123k
- フォーク
- 16.6k
- 平均マージ
- 2日 17時間
- マージ済み PR(30日)
- 532
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rust-lang/rust のほかの issue
-
C-bug needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
rust-lang/rust#166722 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
A-attributes relnotes relnotes-needs-review relnotes-tracking-issue T-compiler T-lang
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
A-run-make C-bug T-bootstrap
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
Tracking issue for release notes of #161531: Remove `T: Send + Sync` bound from `Arc::downcast`オープンrelnotes relnotes-tracking-issue T-libs
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
A-str A-Unicode relnotes relnotes-tracking-issue T-libs
難易度 1/5 1時間未満 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
bug P2
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
bug core-lang
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Windows microphone listing treats words in a device name as DirectShow labels対応中かも @Sujal-chaudhary が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
clipy-recorder/clipy#447 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
nightly-cleanup
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
max-sixty/worktrunk#4939 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信