pub struct Conflict {
pub current: String,
pub against: String,
pub kind: String,
pub detail: String,
}Expand description
Two things in the answer that do not agree, named rather than silently ordered.
The compiler could have resolved every disagreement by keeping one side, and for deduplication it does. A conflict is what is left when both sides are legitimately in the answer and they still do not agree — so the resolution belongs to the session reading it, and the compiler’s job is to make sure the disagreement is visible rather than implied by the order of two rows.
current is the side the compiler treats as current, which is a statement about
recency, not correctness: supersedes means the layer declared one to replace the other,
version means two versions of one thing are both here.
use majordomus_cli::devcontext::Conflict;
use majordomus_cli::order::canonical;
use serde_json::json;
let row = |current: &str, against: &str, kind: &str| -> Conflict {
serde_json::from_value(json!({
"current": current, "against": against, "kind": kind,
"detail": "both are in the answer and they disagree",
})).unwrap()
};
let mut conflicts = vec![
row("majordomus://rule/project.x@2", "majordomus://rule/project.x@1", "version"),
row("majordomus://adr/0052", "majordomus://adr/0031", "supersedes"),
];
canonical(&mut conflicts);
// filed under the kind of disagreement, so like reads with like
let kinds: Vec<&str> = conflicts.iter().map(|c| c.kind.as_str()).collect();
assert_eq!(kinds, ["supersedes", "version"]);
// and both sides are always named: the pair is the fact, not the winner alone
for c in &conflicts {
assert_ne!(c.current, c.against);
assert!(!c.detail.is_empty());
}Fields§
§current: StringThe entry the compiler treats as current.
against: StringThe entry it stands against.
kind: StringWhat kind of disagreement: supersedes or version.
detail: StringThe same, in words.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Conflict
impl<'de> Deserialize<'de> for Conflict
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for Conflict
impl JsonSchema for Conflict
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl Ordered for Conflict
Filed under the kind of disagreement, then the current entry, and ended by the entry it
stands against — the pair is what makes one conflict distinct from another under a kind.
impl Ordered for Conflict
Filed under the kind of disagreement, then the current entry, and ended by the entry it stands against — the pair is what makes one conflict distinct from another under a kind.