pedant_core/resolution/rust/resolve/error.rs
1//! Typed failures returned while resolving a snapshot into a report.
2
3use pedant_types::ResolutionReportError;
4
5use crate::resolution::rust::warning::RustResolutionWarning;
6
7/// Failure encountered while turning a resolution snapshot into a validated,
8/// snapshot-bound report.
9#[derive(Debug, thiserror::Error)]
10pub enum RustResolutionError {
11 /// The report's units do not describe this snapshot's units.
12 #[error("report unit {unit} does not describe this snapshot: {reason}")]
13 UnitMapping {
14 /// The report-local unit identifier that could not be bound.
15 unit: u32,
16 /// Why the unit does not describe a snapshot unit.
17 reason: Box<str>,
18 },
19 /// A site names a file this snapshot does not hold.
20 #[error("{file} is not a source of this snapshot")]
21 UnknownFile {
22 /// The repository-relative path the site named.
23 file: Box<str>,
24 },
25 /// A site's coordinate does not exist in the exact snapshotted source.
26 #[error("{file}:{line}:{column} is not a coordinate of the snapshotted source")]
27 InvalidCoordinate {
28 /// The source the coordinate claimed to sit in.
29 file: Box<str>,
30 /// The zero-based line.
31 line: u32,
32 /// The zero-based UTF-8 byte column.
33 column: u32,
34 },
35 /// One reference carries more candidates than the configured ceiling.
36 ///
37 /// Candidate fan-out is never truncated: an overflowing reference refuses
38 /// the whole resolution rather than reporting a misleading complete answer.
39 #[error("a reference carries more than {limit} candidates")]
40 LimitExceeded {
41 /// The configured candidate ceiling.
42 limit: u32,
43 },
44 /// The names `use` items bind did not settle within the bounded rounds.
45 ///
46 /// Each round strictly adds, so a re-export chain shallower than the bound
47 /// always settles. A chain deeper than it refuses the whole resolution
48 /// rather than reporting the tail's unfilled bindings as names that do not
49 /// exist.
50 #[error("the names imports bind did not settle within {rounds} rounds")]
51 ImportsNotConverged {
52 /// The number of rounds the fixed point was given.
53 rounds: u32,
54 },
55 /// The semantic database does not hold what the snapshot claims.
56 ///
57 /// Tier 2 never falls back: a database that holds other units, other
58 /// sources, or other bytes answers for another repository state, so no
59 /// candidate is promoted against it.
60 #[error("the semantic database does not describe this snapshot: {reason}")]
61 SemanticContextMismatch {
62 /// Which identity disagrees, and how.
63 reason: Box<str>,
64 },
65 /// One physical source belongs to multiple resolution units that the
66 /// semantic database cannot distinguish.
67 #[error("semantic resolution cannot represent this snapshot: {warning}")]
68 SemanticSharedSourceMismatch {
69 /// The project-level warning with the path, unit identities, and
70 /// remediation.
71 warning: RustResolutionWarning,
72 },
73 /// The report contract refused the stated facts.
74 #[error(transparent)]
75 Report(#[from] ResolutionReportError),
76}