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
//! What one site names, decided before the span it was written at is read.
//!
//! Every classification reaches one of three shapes: definitions a lookup
//! found, nothing with the gap that stopped it, or a run-time choice among the
//! definitions a dispatch could reach. Naming them here keeps a classifier from
//! assembling a certainty of its own.
use pedant_types::{ReferenceKind, ResolutionGap};
/// What one site denotes, before it is written into a report record.
pub(super) struct Answer {
pub(super) kind: ReferenceKind,
pub(super) candidates: Box<[usize]>,
pub(super) gap: Option<ResolutionGap>,
pub(super) possible_only: bool,
}
impl Answer {
/// One answer naming the definitions a lookup found.
pub(super) fn found(
kind: ReferenceKind,
candidates: Box<[usize]>,
gap: Option<ResolutionGap>,
) -> Self {
Self {
kind,
candidates,
gap,
possible_only: false,
}
}
/// One site that names nothing, and the gap that says why.
pub(super) fn refused(kind: ReferenceKind, gap: ResolutionGap) -> Self {
Self::found(kind, Box::from([]), Some(gap))
}
/// One answer whose target is chosen at run time.
pub(super) fn dispatched(kind: ReferenceKind, candidates: Box<[usize]>) -> Self {
Self {
kind,
candidates,
gap: Some(ResolutionGap::DynamicDispatch),
possible_only: true,
}
}
/// One answer whose selector reaches its member by several embedding paths.
///
/// Go rejects such a selector rather than choosing between the paths, so
/// the definitions it reaches stay possible however few they are: a single
/// candidate here is one definition an illegal selector names, not a target
/// the corpus proved.
pub(super) fn multiple(kind: ReferenceKind, candidates: Box<[usize]>) -> Self {
Self {
kind,
candidates,
gap: Some(ResolutionGap::Ambiguous),
possible_only: true,
}
}
}