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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
use ;
use TextRange;
use crateFileId;
use crateLookupMap;
// ─── Symbol index ───────────────────────────────────────────────────
/// The unified symbol table produced by merging per-file manifests and
/// resolving references.
///
/// `symbols`/`by_name` are keyed lookup tables (`LookupMap` — a `HashMap`
/// under an issue #801 audited alias, see `crate::determinism`'s doc): every
/// consumer that needs a deterministic order over these builds it explicitly
/// at the point of consumption (e.g. `lir::lower::mod`'s `private_defs`
/// sorts by raw id; `brink-analyzer::modules`'s file-attribution fold is
/// order-independent by construction — see its doc comment).
/// Explicit visibility override on a declaration, from a `#@private` /
/// `#@public` directive (M-2, docs/modules-spec.md §4).
///
/// `None` on a declaration means "no override — take the module's default".
/// The *effective* [`Visibility`] is computed downstream by the analyzer,
/// which knows each file's declared-ness (including INCLUDE inheritance) and
/// so can apply declaration-flips-default (§4).
/// Effective visibility of a definition (M-2, docs/modules-spec.md §4) —
/// who may *reference the name*.
///
/// `Public` names cross module boundaries via `IMPORT`; `Private` names are
/// module-internal (and the host is outside every module). Computed by
/// declaration-flips-default: a *declared* module defaults `Private`, an
/// *undeclared* stem-module defaults `Public`, and a per-definition
/// [`VisibilityMark`] overrides that default.
/// Metadata for a resolved symbol.
/// Parameter metadata for hover/signature help.
/// The kind of a declared symbol.
// ─── Resolution types ───────────────────────────────────────────────
/// A resolved reference: a use-site that has been matched to a definition.
///
/// ## The `range` contract for a call-path reference (issue #1561)
///
/// For a call (`brink_ir::hir::Expr::Call(path, _)`), `range` **must equal
/// `path.range` exactly** — the callee `Path` node's own whole span, from
/// its first segment through its last. This holds for both an ordinary
/// single-segment callee (`f()`) and a UFCS-shaped multi-segment one
/// (`recv.verb(args)`, where the whole-path range still resolves to the
/// **receiver**, per `brink-analyzer::resolve::resolve_function`'s B3a
/// branch — never to a receiver-only or method-only sub-segment).
///
/// This is produced once, structurally, by
/// `brink_ir::symbols::project::Projector::walk_expr`'s `Expr::Call` arm
/// (`path.range` is what it hands to `push_ref`, becoming
/// `UnresolvedRef::range`), and every push site in
/// `brink-analyzer::resolve::resolve_function` carries it through
/// unchanged as `ResolvedRef::range` — see that function's own doc for the
/// full push-site list.
///
/// It is then an **exact lookup key** at least six separate consumers
/// key their own `(FileId, range)` maps on, independently:
///
/// - `brink_ir::lir::lower::expr::lower_call`'s `ctx.resolve_path(path.range)`;
/// - `brink_ir::lir::lower::expr::ufcs_receiver_path`, which deliberately
/// keeps `path.range` (not a receiver-only sub-range) on the desugared
/// receiver sub-path it builds, precisely so the *same* `resolve_path`
/// lookup above still hits when lowering that receiver as its own
/// expression;
/// - `brink_analyzer::strict::check_void_root`'s
/// `resolution_by_range.get(&range_key(path.range))` (the `E067`
/// void-assignment check);
/// - `brink_analyzer::coalesce::classify_coalesce_operand`'s equivalent
/// `resolution_by_range` lookup on a coalescing operand's call;
/// - `brink_analyzer::ufcs::value_receiver_def`'s
/// `resolution_by_range.get(&key)` lookup on the callee path — the mirror
/// of `resolve::resolve_function`'s own UFCS-shaped fallback, which must
/// agree with it or a call is diagnosed twice or not at all; and
/// - `brink_analyzer::infer::body::infer_call`'s `self.resolve(path.range)`
/// (backed by the same `resolution_by_range` map), whose B3a branch
/// explicitly handles a multi-segment (dotted UFCS) callee path.
///
/// Narrowing this range anywhere upstream — even in service of a real bug
/// fix elsewhere, e.g. a rename edit that must span only one segment — is a
/// silent miscompile here: every consumer above misses its lookup and
/// either falls back to a wrong resolution or refuses the compile with no
/// clue this field is the cause. That happened once already (#1550/#1554)
/// and was caught only by review, not by a test — hence this doc and the
/// cross-layer regression test in
/// `brink-test-harness/tests/resolved_ref_range_contract.rs`. A narrowing
/// fix for a *different* consumer (e.g. an IDE rename edit) belongs at that
/// consumer's own layer, never here — `brink-ide::ufcs_hover`'s
/// segment-narrowing helpers are the established pattern.
/// Maps reference use-sites to their resolved definitions, with file provenance.
pub type ResolutionMap = ;
/// Resolution context — identifies the current knot/stitch for relative
/// path lookup.