Review comments
This commit is contained in:
@@ -39,12 +39,12 @@ impl Operand {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn doc(&self) -> Option<&str> {
|
pub fn doc(&self) -> &str {
|
||||||
if let Some(doc) = &self.doc {
|
if let Some(doc) = &self.doc {
|
||||||
return Some(doc);
|
return doc;
|
||||||
}
|
}
|
||||||
match &self.kind.fields {
|
match &self.kind.fields {
|
||||||
OperandKindFields::TypeVar(tvar) => Some(&tvar.doc),
|
OperandKindFields::TypeVar(tvar) => &tvar.doc,
|
||||||
_ => self.kind.doc(),
|
_ => self.kind.doc(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,12 +139,14 @@ impl OperandKind {
|
|||||||
doc: Some(doc),
|
doc: Some(doc),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn doc(&self) -> Option<&str> {
|
fn doc(&self) -> &str {
|
||||||
if let Some(doc) = &self.doc {
|
if let Some(doc) = &self.doc {
|
||||||
return Some(doc);
|
return doc;
|
||||||
}
|
}
|
||||||
match &self.fields {
|
match &self.fields {
|
||||||
OperandKindFields::TypeVar(type_var) => Some(&type_var.doc),
|
OperandKindFields::TypeVar(type_var) => &type_var.doc,
|
||||||
|
// The only method to create an OperandKind with `doc` set to None is using a TypeVar,
|
||||||
|
// so all other options are unreachable here.
|
||||||
OperandKindFields::ImmEnum(_)
|
OperandKindFields::ImmEnum(_)
|
||||||
| OperandKindFields::ImmValue
|
| OperandKindFields::ImmValue
|
||||||
| OperandKindFields::EntityRef
|
| OperandKindFields::EntityRef
|
||||||
|
|||||||
@@ -946,21 +946,11 @@ fn gen_inst_builder(inst: &Instruction, format: &InstructionFormat, fmt: &mut Fo
|
|||||||
op.kind.rust_type.to_string()
|
op.kind.rust_type.to_string()
|
||||||
};
|
};
|
||||||
args.push(format!("{}: {}", op.name, t));
|
args.push(format!("{}: {}", op.name, t));
|
||||||
args_doc.push(format!(
|
args_doc.push(format!("- {}: {}", op.name, op.doc()));
|
||||||
"- {}: {}",
|
|
||||||
op.name,
|
|
||||||
op.doc()
|
|
||||||
.expect("every instruction's input operand must be documented")
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for op in &inst.operands_out {
|
for op in &inst.operands_out {
|
||||||
rets_doc.push(format!(
|
rets_doc.push(format!("- {}: {}", op.name, op.doc()));
|
||||||
"- {}: {}",
|
|
||||||
op.name,
|
|
||||||
op.doc()
|
|
||||||
.expect("every instruction's output operand must be documented")
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let rtype = match inst.value_results.len() {
|
let rtype = match inst.value_results.len() {
|
||||||
|
|||||||
Reference in New Issue
Block a user