#[non_exhaustive]pub enum Violation {
Show 31 variants
MissingBase {
name: Token,
},
CyclicInheritance {
chain: String,
},
MultipleBases {
count: usize,
},
AppliedApiNotRooted {
base: Token,
},
NonAppliedApiNotRooted {
base: Token,
},
InheritsWithinFamily {
base: Token,
},
UnknownApiSchemaType {
spelling: String,
},
KindMismatch {
key: &'static str,
kind: &'static str,
},
ConcreteNotTyped,
ApiSchemaTypeOnTyped,
DisallowedIdentifier {
identifier: Token,
},
TypeNameMismatch {
authored: Token,
},
ApiSchemasNotPrepended,
DuplicateSchematicsName {
name: Token,
first: Token,
second: Token,
},
UnknownPropertyType {
property: Token,
type_name: Token,
},
MultipleApplyPrefix,
DisallowedField {
field: String,
},
OverridesADeclaration {
property: Token,
class: Token,
},
IncompatibleRedeclaration {
property: Token,
class: Token,
theirs: Box<Shape>,
ours: Box<Shape>,
},
TokenValueCollision {
id: String,
first: String,
second: String,
},
RustNameCollision {
name: String,
first: String,
second: String,
},
MethodCollision {
method: String,
first: Token,
second: Token,
},
NotAnIdentifier {
name: String,
},
Ungenerated {
class: Token,
},
UnknownReflectedSchema {
schema: Token,
},
ReflectedNotApplied {
schema: Token,
},
UnknownLibrary {
library: String,
class: Token,
},
UnreadableLibraryPath {
library: String,
path: String,
},
UnknownApiGetImplementation {
spelling: String,
},
CustomGetWithoutAccessor {
property: Token,
},
UnnameableType {
property: Token,
type_name: Token,
},
}Expand description
A rule a schema broke.
One variant per rule enforced, not one per upstream check: two upstream checks that mean one thing here share a variant, and a check not kept has none. Tests match variants rather than message text.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
MissingBase
A base no layer in the stack declares.
CyclicInheritance
An inheritance chain that returns to where it started, which has no order to generate in.
MultipleBases
More than one base. A schema is a single chain, and the registry
resolves is_a along one.
AppliedApiNotRooted
An applied API schema that does not inherit directly from
APISchemaBase.
Applying a schema brings its own properties and the API schemas it lists, not its bases’ — an API schema’s inheritance is not walked the way a typed schema’s is — so a chain here would promise properties that applying never delivers.
NonAppliedApiNotRooted
A non-applied API schema on a base that is neither APISchemaBase nor
another non-applied API schema, whose properties it would appear to
offer and could never carry.
InheritsWithinFamily
A schema inheriting inside its own family, which the registry reads as one schema at two versions rather than two schemas.
UnknownApiSchemaType
An apiSchemaType that is none of the three kinds.
KindMismatch
Metadata that contradicts the kind of schema it sits on.
Fields
ConcreteNotTyped
A concrete schema that is not typed, so a stage could never instantiate it.
ApiSchemaTypeOnTyped
A schema that is typed, or carries a type name, and also declares itself an API schema.
The two cannot both hold: apiSchemaType is what makes a schema an API
schema, and an API schema is never a prim type. Left alone the API
reading wins and the type name never reaches the schematics, so a stage
could no longer instantiate the prim type the schema meant to declare.
DisallowedIdentifier
An identifier the registry would refuse to register, and so could never look up.
TypeNameMismatch
A typeName that is not the class’s own identifier. It reaches the
schematics, so a stage would compose the wrong type.
Fields
The authored type name.
ApiSchemasNotPrepended
An apiSchemas opinion that is not a prepend. Only a prepend composes
as the class’s built-in applied API schemas.
Which kinds may declare built-ins at all is deliberately not a rule
here: the upstream corpus’s own PublicMultipleApplyAPI declares them
on a multiple-apply schema, so the shape is legal however it reads.
DuplicateSchematicsName
Two properties that reach one name in the schematics, where one spec cannot hold both.
The check is on the resolved name: a multiple-apply schema’s property picks up its namespace prefix and the instance-name template on the way there, so two names distinct at the source can arrive as one.
Fields
UnknownPropertyType
An attribute whose type no registered value type names, leaving its accessor nothing to read.
MultipleApplyPrefix
A multiple-apply schema with properties but no namespace prefix, or a prefix and no properties. The prefix is what keeps one instance’s properties apart from another’s.
DisallowedField
A field the registry would refuse to carry, so it would be silently dropped rather than mean anything.
OverridesADeclaration
A property this class records as an API schema override that an ancestor declares outright.
An override reaches a prim definition only where a built-in API schema supplies the property, so this would delete the ancestor’s property from the class wherever none does. The other direction is allowed: a class may make an inherited override a declaration of its own.
IncompatibleRedeclaration
A redeclaration that changes what a property is, rather than what it falls back to.
An accessor is generated where a property is introduced and every class
below reaches that one, so its creator authors the type, variability and
custom composed there. A redeclaration changing any of them would have
that creator author a property the redeclaring class’s own definition
contradicts. A fallback is not on the list: changing one is what a
redeclaration is for.
Fields
TokenValueCollision
Two token sources reaching one identifier with different values, where one constant would have to hold both strings.
Fields
RustNameCollision
Two classes of one library reaching one Rust name, where one module cannot hold both.
The scope is the module: two libraries may each declare a Sphere, and
nothing stops them.
Fields
MethodCollision
Two properties reaching one method name, where two methods of one name — or two traits offering one — make every call ambiguous.
Fields
NotAnIdentifier
A name a schema chose — through className or apiName — that is not a
Rust identifier, so nothing could be called it.
Ungenerated
A class this run does not generate and that belongs to no other library, so no view of it exists for a descendant to derive from or for a class to reflect.
UnknownReflectedSchema
A reflected API schema no layer in the stack declares.
ReflectedNotApplied
A reflected API schema the class does not apply.
Reflecting says every prim of this type carries the schema’s properties, which only applying the schema makes true; a reflected accessor would otherwise reach a property the prim’s definition does not have. A multiple-apply class records its applied schemas as instance-name templates, which no reflected name matches, so it cannot reflect.
UnknownLibrary
A class in a library this run does not generate and was not told where to find, so its views cannot be named: a base to derive from, or a schema to reflect.
Fields
UnreadableLibraryPath
A library was told where its views live, but not in a spelling Rust can read, so nothing can be named through it.
UnknownApiGetImplementation
An apiGetImplementation that is neither spelling.
CustomGetWithoutAccessor
A custom read accessor asked for on a property that has no accessor, which cannot both be true.
UnnameableType
An attribute whose type the core reads but gives no constant to declare it with, so nothing could author the property.
Trait Implementations§
Source§impl Error for Violation
impl Error for Violation
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()