1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//! Source locations, their portable text form, and localized labels.
//! 源码位置、其可移植文本形式,以及本地化标签。
use *;
/// File and line captured at the declaration site.
/// 在声明点捕获的文件和行号。
/// Render a source path with `/` separators on every platform.
/// 在任何平台上都以 `/` 分隔符渲染源码路径。
///
/// `file!()` records the platform separator, and a declaration cannot rewrite
/// it at compile time without allocating, so the portable form is produced when
/// a path is displayed or compared instead. Identity is unaffected: hashing
/// folds both separators to the same byte.
/// `file!()` 记录平台分隔符,而声明在编译期无法在不分配的前提下改写它,因此改为
/// 在显示或比较时产出可移植形式。身份不受影响:哈希会把两种分隔符折叠为同一字节。
/// Whether a recorded source path matches a lowercase search needle.
/// 记录的源码路径是否匹配一个小写的搜索关键词。
///
/// The search surfaces match a `file!()`-recorded path against what a user
/// typed, and on Windows that path is spelled with backslashes while the path
/// the same surface *displays* is [`portable_path`]'s `/` form. Comparing the
/// raw value therefore misses the query a user can see and retype — the search
/// for `control/widget.rs` finds nothing where the screen says
/// `control/widget.rs`. The fold has to happen here, at the comparison, for the
/// same reason it happens at the display.
/// 搜索面把 `file!()` 记录的路径与用户输入做匹配,而在 Windows 上该路径以反斜杠拼写,
/// 同一个面**显示**的却是 [`portable_path`] 的 `/` 形式。因此比较原始值时,用户
/// 照着屏幕重敲的查询会落空——搜 `control/widget.rs` 什么都找不到,而屏幕上写的就是
/// `control/widget.rs`。与显示时同理,折叠必须发生在比较处。
///
/// `needle` must already be lowercase: every caller lowercases its query once and
/// reuses it across all the fields it searches, and folding case here would
/// allocate a second time on every candidate.
/// `needle` 必须已经是小写:每个调用方把查询小写一次并在它搜索的所有字段间复用,在这里
/// 折叠大小写会让每个候选再多分配一次。
/// Match a recorded file path by its lowercase spelling.
/// 按小写拼法匹配记录的源码文件路径。
///
/// `file` is lowercased here; `needle` is **not**. A caller that passes a mixed-case
/// needle silently matches nothing, which is why every call site passes an
/// already-lowercase needle (audit `KRN-K-19`).
/// 这里会把 `file` 小写,**不会**处理 `needle`。传入大小写混合的 `needle` 会静默匹配不到任何东西,
/// 因此每个调用点传的都是已小写的 `needle`(审计 `KRN-K-19`)。
/// Bilingual text kept on the registration face.
/// 注册面上的双语文本。