Enforce all OperandKind have documentation

This commit is contained in:
bjorn3
2021-10-31 19:27:12 +01:00
parent e8f3c0c6a9
commit f84e1c16c7
3 changed files with 98 additions and 40 deletions

View File

@@ -130,19 +130,15 @@ impl OperandKind {
rust_field_name: &'static str,
rust_type: &'static str,
fields: OperandKindFields,
doc: &'static str,
) -> Self {
Self {
rust_field_name,
rust_type,
fields,
doc: None,
doc: Some(doc),
}
}
pub fn with_doc(mut self, doc: &'static str) -> Self {
assert!(self.doc.is_none());
self.doc = Some(doc);
self
}
fn doc(&self) -> Option<&str> {
if let Some(doc) = &self.doc {
return Some(doc);
@@ -152,18 +148,19 @@ impl OperandKind {
OperandKindFields::ImmEnum(_)
| OperandKindFields::ImmValue
| OperandKindFields::EntityRef
| OperandKindFields::VariableArgs => None,
| OperandKindFields::VariableArgs => unreachable!(),
}
}
}
impl Into<OperandKind> for &TypeVar {
fn into(self) -> OperandKind {
OperandKind::new(
"value",
"ir::Value",
OperandKindFields::TypeVar(self.into()),
)
OperandKind {
rust_field_name: "value",
rust_type: "ir::Value",
fields: OperandKindFields::TypeVar(self.into()),
doc: None,
}
}
}
impl Into<OperandKind> for &OperandKind {