Refactor type errors back into macro annotations

Far less verbose than defining classes by hand, plus, it allows to have everything about a single error be co-located. And finally, it allows to use 'related', 'label' and so on more easily.
This commit is contained in:
KtorZ
2023-01-20 20:08:40 +01:00
parent 4459fdb360
commit d321b85df2
3 changed files with 716 additions and 1102 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -27,12 +27,14 @@ impl FieldMap {
if self.is_function {
Err(Error::DuplicateArgument {
label,
locations: vec![*location, location_other],
location: *location,
duplicate_location: location_other,
})
} else {
Err(Error::DuplicateField {
label,
locations: vec![*location, location_other],
location: *location,
duplicate_location: location_other,
})
}
}
@@ -102,7 +104,7 @@ impl FieldMap {
}
};
let (position, other_location) = match self.fields.get(label) {
let (position, duplicate_location) = match self.fields.get(label) {
None => {
unknown_labels.push((label.clone(), location));
@@ -122,7 +124,8 @@ impl FieldMap {
} else {
if seen_labels.contains(label) {
return Err(Error::DuplicateArgument {
locations: vec![location, other_location],
location,
duplicate_location,
label: label.to_string(),
});
}