Add clippy suggestions (#6203)
* add clippy suggestions * revert &/ref change * Update cranelift/isle/isle/src/parser.rs Co-authored-by: Jamey Sharp <jamey@minilop.net> --------- Co-authored-by: Jamey Sharp <jamey@minilop.net>
This commit is contained in:
@@ -228,8 +228,8 @@ impl InstructionBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn build(self) -> Instruction {
|
fn build(self) -> Instruction {
|
||||||
let operands_in = self.operands_in.unwrap_or_else(Vec::new);
|
let operands_in = self.operands_in.unwrap_or_default();
|
||||||
let operands_out = self.operands_out.unwrap_or_else(Vec::new);
|
let operands_out = self.operands_out.unwrap_or_default();
|
||||||
|
|
||||||
let mut value_opnums = Vec::new();
|
let mut value_opnums = Vec::new();
|
||||||
let mut imm_opnums = Vec::new();
|
let mut imm_opnums = Vec::new();
|
||||||
@@ -375,7 +375,7 @@ fn verify_polymorphic(
|
|||||||
if (free_typevar.is_some() && tv == &free_typevar.unwrap())
|
if (free_typevar.is_some() && tv == &free_typevar.unwrap())
|
||||||
|| tv.singleton_type().is_some()
|
|| tv.singleton_type().is_some()
|
||||||
{
|
{
|
||||||
match is_ctrl_typevar_candidate(tv, &operands_in, &operands_out) {
|
match is_ctrl_typevar_candidate(tv, operands_in, operands_out) {
|
||||||
Ok(_other_typevars) => {
|
Ok(_other_typevars) => {
|
||||||
return Some(PolymorphicInfo {
|
return Some(PolymorphicInfo {
|
||||||
use_typevar_operand: true,
|
use_typevar_operand: true,
|
||||||
@@ -410,7 +410,7 @@ fn verify_polymorphic(
|
|||||||
|
|
||||||
// At this point, if the next unwrap() fails, it means the output type couldn't be used as a
|
// At this point, if the next unwrap() fails, it means the output type couldn't be used as a
|
||||||
// controlling type variable either; panicking is the right behavior.
|
// controlling type variable either; panicking is the right behavior.
|
||||||
is_ctrl_typevar_candidate(tv, &operands_in, &operands_out).unwrap();
|
is_ctrl_typevar_candidate(tv, operands_in, operands_out).unwrap();
|
||||||
|
|
||||||
Some(PolymorphicInfo {
|
Some(PolymorphicInfo {
|
||||||
use_typevar_operand: false,
|
use_typevar_operand: false,
|
||||||
|
|||||||
@@ -50,10 +50,7 @@ impl Operand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_value(&self) -> bool {
|
pub fn is_value(&self) -> bool {
|
||||||
match self.kind.fields {
|
matches!(self.kind.fields, OperandKindFields::TypeVar(_))
|
||||||
OperandKindFields::TypeVar(_) => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn type_var(&self) -> Option<&TypeVar> {
|
pub fn type_var(&self) -> Option<&TypeVar> {
|
||||||
@@ -64,28 +61,25 @@ impl Operand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_varargs(&self) -> bool {
|
pub fn is_varargs(&self) -> bool {
|
||||||
match self.kind.fields {
|
matches!(self.kind.fields, OperandKindFields::VariableArgs)
|
||||||
OperandKindFields::VariableArgs => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if the operand has an immediate kind or is an EntityRef.
|
/// Returns true if the operand has an immediate kind or is an EntityRef.
|
||||||
pub fn is_immediate_or_entityref(&self) -> bool {
|
pub fn is_immediate_or_entityref(&self) -> bool {
|
||||||
match self.kind.fields {
|
matches!(
|
||||||
|
self.kind.fields,
|
||||||
OperandKindFields::ImmEnum(_)
|
OperandKindFields::ImmEnum(_)
|
||||||
| OperandKindFields::ImmValue
|
| OperandKindFields::ImmValue
|
||||||
| OperandKindFields::EntityRef => true,
|
| OperandKindFields::EntityRef
|
||||||
_ => false,
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if the operand has an immediate kind.
|
/// Returns true if the operand has an immediate kind.
|
||||||
pub fn is_immediate(&self) -> bool {
|
pub fn is_immediate(&self) -> bool {
|
||||||
match self.kind.fields {
|
matches!(
|
||||||
OperandKindFields::ImmEnum(_) | OperandKindFields::ImmValue => true,
|
self.kind.fields,
|
||||||
_ => false,
|
OperandKindFields::ImmEnum(_) | OperandKindFields::ImmValue
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,18 +152,18 @@ impl OperandKind {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<OperandKind> for &TypeVar {
|
impl From<&TypeVar> for OperandKind {
|
||||||
fn into(self) -> OperandKind {
|
fn from(type_var: &TypeVar) -> Self {
|
||||||
OperandKind {
|
OperandKind {
|
||||||
rust_field_name: "value",
|
rust_field_name: "value",
|
||||||
rust_type: "ir::Value",
|
rust_type: "ir::Value",
|
||||||
fields: OperandKindFields::TypeVar(self.into()),
|
fields: OperandKindFields::TypeVar(type_var.into()),
|
||||||
doc: None,
|
doc: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Into<OperandKind> for &OperandKind {
|
impl From<&OperandKind> for OperandKind {
|
||||||
fn into(self) -> OperandKind {
|
fn from(kind: &OperandKind) -> Self {
|
||||||
self.clone()
|
kind.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,14 +75,14 @@ pub(crate) enum PresetType {
|
|||||||
OtherPreset(PresetIndex),
|
OtherPreset(PresetIndex),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<PresetType> for BoolSettingIndex {
|
impl From<BoolSettingIndex> for PresetType {
|
||||||
fn into(self) -> PresetType {
|
fn from(bool_setting_index: BoolSettingIndex) -> Self {
|
||||||
PresetType::BoolSetting(self)
|
PresetType::BoolSetting(bool_setting_index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Into<PresetType> for PresetIndex {
|
impl From<PresetIndex> for PresetType {
|
||||||
fn into(self) -> PresetType {
|
fn from(value: PresetIndex) -> Self {
|
||||||
PresetType::OtherPreset(self)
|
PresetType::OtherPreset(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,13 +134,7 @@ impl SettingGroup {
|
|||||||
fn num_bool_settings(&self) -> u8 {
|
fn num_bool_settings(&self) -> u8 {
|
||||||
self.settings
|
self.settings
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|s| {
|
.filter(|s| matches!(s.specific, SpecificSetting::Bool(_)))
|
||||||
if let SpecificSetting::Bool(_) = s.specific {
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.count() as u8
|
.count() as u8
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,14 +178,15 @@ pub(crate) enum PredicateNode {
|
|||||||
And(Box<PredicateNode>, Box<PredicateNode>),
|
And(Box<PredicateNode>, Box<PredicateNode>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<PredicateNode> for BoolSettingIndex {
|
impl From<BoolSettingIndex> for PredicateNode {
|
||||||
fn into(self) -> PredicateNode {
|
fn from(bool_setting_index: BoolSettingIndex) -> Self {
|
||||||
PredicateNode::OwnedBool(self)
|
PredicateNode::OwnedBool(bool_setting_index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'a> Into<PredicateNode> for (BoolSettingIndex, &'a SettingGroup) {
|
|
||||||
fn into(self) -> PredicateNode {
|
impl<'a> From<(BoolSettingIndex, &'a SettingGroup)> for PredicateNode {
|
||||||
let (index, group) = (self.0, self.1);
|
fn from(val: (BoolSettingIndex, &'a SettingGroup)) -> Self {
|
||||||
|
let (index, group) = (val.0, val.1);
|
||||||
let setting = &group.settings[index.0];
|
let setting = &group.settings[index.0];
|
||||||
PredicateNode::SharedBool(group.name, setting.name)
|
PredicateNode::SharedBool(group.name, setting.name)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -491,10 +491,6 @@ impl ReferenceTypeIterator {
|
|||||||
impl Iterator for ReferenceTypeIterator {
|
impl Iterator for ReferenceTypeIterator {
|
||||||
type Item = ReferenceType;
|
type Item = ReferenceType;
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
if let Some(r) = self.reference_iter.next() {
|
self.reference_iter.next().map(ReferenceType::from)
|
||||||
Some(ReferenceType::from(r))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -279,14 +279,14 @@ impl TypeVar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<TypeVar> for &TypeVar {
|
impl From<&TypeVar> for TypeVar {
|
||||||
fn into(self) -> TypeVar {
|
fn from(type_var: &TypeVar) -> Self {
|
||||||
self.clone()
|
type_var.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Into<TypeVar> for ValueType {
|
impl From<ValueType> for TypeVar {
|
||||||
fn into(self) -> TypeVar {
|
fn from(value_type: ValueType) -> Self {
|
||||||
TypeVar::new_singleton(self)
|
TypeVar::new_singleton(value_type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,7 +507,7 @@ impl TypeSet {
|
|||||||
self.dynamic_lanes
|
self.dynamic_lanes
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|&&x| x < MAX_LANES)
|
.filter(|&&x| x < MAX_LANES)
|
||||||
.map(|&x| x),
|
.copied(),
|
||||||
);
|
);
|
||||||
copy.dynamic_lanes = NumSet::new();
|
copy.dynamic_lanes = NumSet::new();
|
||||||
copy
|
copy
|
||||||
@@ -660,13 +660,7 @@ pub(crate) enum Interval {
|
|||||||
impl Interval {
|
impl Interval {
|
||||||
fn to_range(&self, full_range: Range, default: Option<RangeBound>) -> Option<Range> {
|
fn to_range(&self, full_range: Range, default: Option<RangeBound>) -> Option<Range> {
|
||||||
match self {
|
match self {
|
||||||
Interval::None => {
|
Interval::None => default.map(|default_val| default_val..default_val),
|
||||||
if let Some(default_val) = default {
|
|
||||||
Some(default_val..default_val)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Interval::All => Some(full_range),
|
Interval::All => Some(full_range),
|
||||||
|
|
||||||
@@ -683,9 +677,9 @@ impl Interval {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<Interval> for Range {
|
impl From<Range> for Interval {
|
||||||
fn into(self) -> Interval {
|
fn from(range: Range) -> Self {
|
||||||
Interval::Range(self)
|
Interval::Range(range)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ pub fn generate_table<'cont, T, I: iter::Iterator<Item = &'cont T>, H: Fn(&T) ->
|
|||||||
let mut table = vec![None; size];
|
let mut table = vec![None; size];
|
||||||
|
|
||||||
for i in items {
|
for i in items {
|
||||||
let mut h = hash_function(&i) % size;
|
let mut h = hash_function(i) % size;
|
||||||
let mut s = 0;
|
let mut s = 0;
|
||||||
while table[h].is_some() {
|
while table[h].is_some() {
|
||||||
s += 1;
|
s += 1;
|
||||||
|
|||||||
@@ -700,7 +700,7 @@ fn get_constraint<'entries, 'table>(
|
|||||||
if let Some(free_typevar) = type_var.free_typevar() {
|
if let Some(free_typevar) = type_var.free_typevar() {
|
||||||
if ctrl_typevar.is_some() && free_typevar != *ctrl_typevar.unwrap() {
|
if ctrl_typevar.is_some() && free_typevar != *ctrl_typevar.unwrap() {
|
||||||
assert!(type_var.base.is_none());
|
assert!(type_var.base.is_none());
|
||||||
return format!("Free({})", type_sets.add(&type_var.get_raw_typeset()));
|
return format!("Free({})", type_sets.add(type_var.get_raw_typeset()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -809,7 +809,7 @@ fn gen_type_constraints(all_inst: &AllInstructions, fmt: &mut Formatter) {
|
|||||||
fmt.indent(|fmt| {
|
fmt.indent(|fmt| {
|
||||||
for inst in all_inst.iter() {
|
for inst in all_inst.iter() {
|
||||||
let (ctrl_typevar, ctrl_typeset) = if let Some(poly) = &inst.polymorphic_info {
|
let (ctrl_typevar, ctrl_typeset) = if let Some(poly) = &inst.polymorphic_info {
|
||||||
let index = type_sets.add(&*poly.ctrl_typevar.get_raw_typeset());
|
let index = type_sets.add(poly.ctrl_typevar.get_raw_typeset());
|
||||||
(Some(&poly.ctrl_typevar), index)
|
(Some(&poly.ctrl_typevar), index)
|
||||||
} else {
|
} else {
|
||||||
(None, TYPESET_LIMIT)
|
(None, TYPESET_LIMIT)
|
||||||
@@ -857,7 +857,7 @@ fn gen_type_constraints(all_inst: &AllInstructions, fmt: &mut Formatter) {
|
|||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(", ")));
|
.join(", ")));
|
||||||
if let Some(poly) = &inst.polymorphic_info {
|
if let Some(poly) = &inst.polymorphic_info {
|
||||||
fmt.comment(format!("Polymorphic over {}", typeset_to_string(&poly.ctrl_typevar.get_raw_typeset())));
|
fmt.comment(format!("Polymorphic over {}", typeset_to_string(poly.ctrl_typevar.get_raw_typeset())));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the bit field encoding, c.f. instructions.rs.
|
// Compute the bit field encoding, c.f. instructions.rs.
|
||||||
@@ -1730,7 +1730,7 @@ fn gen_builder(
|
|||||||
fmt.line("pub trait InstBuilder<'f>: InstBuilderBase<'f> {");
|
fmt.line("pub trait InstBuilder<'f>: InstBuilderBase<'f> {");
|
||||||
fmt.indent(|fmt| {
|
fmt.indent(|fmt| {
|
||||||
for inst in instructions.iter() {
|
for inst in instructions.iter() {
|
||||||
gen_inst_builder(inst, &*inst.format, fmt);
|
gen_inst_builder(inst, &inst.format, fmt);
|
||||||
fmt.empty_line();
|
fmt.empty_line();
|
||||||
}
|
}
|
||||||
for (i, format) in formats.iter().enumerate() {
|
for (i, format) in formats.iter().enumerate() {
|
||||||
|
|||||||
@@ -267,10 +267,10 @@ fn gen_getters(group: &SettingGroup, fmt: &mut Formatter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for setting in &group.settings {
|
for setting in &group.settings {
|
||||||
gen_getter(&setting, fmt);
|
gen_getter(setting, fmt);
|
||||||
}
|
}
|
||||||
for predicate in &group.predicates {
|
for predicate in &group.predicates {
|
||||||
gen_pred_getter(&predicate, &group, fmt);
|
gen_pred_getter(predicate, group, fmt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
fmtln!(fmt, "}");
|
fmtln!(fmt, "}");
|
||||||
@@ -364,8 +364,8 @@ fn gen_descriptors(group: &SettingGroup, fmt: &mut Formatter) {
|
|||||||
|
|
||||||
// Generate hash table.
|
// Generate hash table.
|
||||||
let mut hash_entries: Vec<SettingOrPreset> = Vec::new();
|
let mut hash_entries: Vec<SettingOrPreset> = Vec::new();
|
||||||
hash_entries.extend(group.settings.iter().map(|x| SettingOrPreset::Setting(x)));
|
hash_entries.extend(group.settings.iter().map(SettingOrPreset::Setting));
|
||||||
hash_entries.extend(group.presets.iter().map(|x| SettingOrPreset::Preset(x)));
|
hash_entries.extend(group.presets.iter().map(SettingOrPreset::Preset));
|
||||||
|
|
||||||
let hash_table = generate_table(hash_entries.iter(), hash_entries.len(), |entry| {
|
let hash_table = generate_table(hash_entries.iter(), hash_entries.len(), |entry| {
|
||||||
simple_hash(entry.name())
|
simple_hash(entry.name())
|
||||||
@@ -399,9 +399,9 @@ fn gen_descriptors(group: &SettingGroup, fmt: &mut Formatter) {
|
|||||||
fmt.comment(format!(
|
fmt.comment(format!(
|
||||||
"{}: {}",
|
"{}: {}",
|
||||||
preset.name,
|
preset.name,
|
||||||
preset.setting_names(&group).collect::<Vec<_>>().join(", ")
|
preset.setting_names(group).collect::<Vec<_>>().join(", ")
|
||||||
));
|
));
|
||||||
for (mask, value) in preset.layout(&group) {
|
for (mask, value) in preset.layout(group) {
|
||||||
fmtln!(fmt, "(0b{:08b}, 0b{:08b}),", mask, value);
|
fmtln!(fmt, "(0b{:08b}, 0b{:08b}),", mask, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -502,7 +502,7 @@ pub(crate) fn generate(
|
|||||||
out_dir: &str,
|
out_dir: &str,
|
||||||
) -> Result<(), error::Error> {
|
) -> Result<(), error::Error> {
|
||||||
let mut fmt = Formatter::new();
|
let mut fmt = Formatter::new();
|
||||||
gen_group(&settings, parent_group, &mut fmt);
|
gen_group(settings, parent_group, &mut fmt);
|
||||||
fmt.update_file(filename, out_dir)?;
|
fmt.update_file(filename, out_dir)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ pub fn generate(isas: &[isa::Isa], out_dir: &str, isle_dir: &str) -> Result<(),
|
|||||||
&shared_defs.settings,
|
&shared_defs.settings,
|
||||||
gen_settings::ParentGroup::None,
|
gen_settings::ParentGroup::None,
|
||||||
"settings.rs",
|
"settings.rs",
|
||||||
&out_dir,
|
out_dir,
|
||||||
)?;
|
)?;
|
||||||
gen_types::generate("types.rs", &out_dir)?;
|
gen_types::generate("types.rs", out_dir)?;
|
||||||
|
|
||||||
// - per ISA definitions.
|
// - per ISA definitions.
|
||||||
let target_isas = isa::define(isas, &mut shared_defs);
|
let target_isas = isa::define(isas, &mut shared_defs);
|
||||||
@@ -49,7 +49,7 @@ pub fn generate(isas: &[isa::Isa], out_dir: &str, isle_dir: &str) -> Result<(),
|
|||||||
"inst_builder.rs",
|
"inst_builder.rs",
|
||||||
"clif_opt.isle",
|
"clif_opt.isle",
|
||||||
"clif_lower.isle",
|
"clif_lower.isle",
|
||||||
&out_dir,
|
out_dir,
|
||||||
isle_dir,
|
isle_dir,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ pub fn generate(isas: &[isa::Isa], out_dir: &str, isle_dir: &str) -> Result<(),
|
|||||||
&isa.settings,
|
&isa.settings,
|
||||||
gen_settings::ParentGroup::Shared,
|
gen_settings::ParentGroup::Shared,
|
||||||
&format!("settings-{}.rs", isa.name),
|
&format!("settings-{}.rs", isa.name),
|
||||||
&out_dir,
|
out_dir,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ impl Definitions {
|
|||||||
// Check name.
|
// Check name.
|
||||||
if let Some(existing_format) = format_names.get(&inst.format.name) {
|
if let Some(existing_format) = format_names.get(&inst.format.name) {
|
||||||
assert!(
|
assert!(
|
||||||
Rc::ptr_eq(&existing_format, &inst.format),
|
Rc::ptr_eq(existing_format, &inst.format),
|
||||||
"formats must uniquely named; there's a\
|
"formats must uniquely named; there's a\
|
||||||
conflict on the name '{}', please make sure it is used only once.",
|
conflict on the name '{}', please make sure it is used only once.",
|
||||||
existing_format.name
|
existing_format.name
|
||||||
@@ -80,7 +80,7 @@ impl Definitions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut result = Vec::from_iter(format_structures.into_iter().map(|(_, v)| v));
|
let mut result = Vec::from_iter(format_structures.into_values());
|
||||||
result.sort_by_key(|format| format.name);
|
result.sort_by_key(|format| format.name);
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ fn _indent(s: &str) -> Option<usize> {
|
|||||||
fn parse_multiline(s: &str) -> Vec<String> {
|
fn parse_multiline(s: &str) -> Vec<String> {
|
||||||
// Convert tabs into spaces.
|
// Convert tabs into spaces.
|
||||||
let expanded_tab = format!("{:-1$}", " ", SHIFTWIDTH);
|
let expanded_tab = format!("{:-1$}", " ", SHIFTWIDTH);
|
||||||
let lines: Vec<String> = s.lines().map(|l| l.replace("\t", &expanded_tab)).collect();
|
let lines: Vec<String> = s.lines().map(|l| l.replace('\t', &expanded_tab)).collect();
|
||||||
|
|
||||||
// Determine minimum indentation, ignoring the first line and empty lines.
|
// Determine minimum indentation, ignoring the first line and empty lines.
|
||||||
let indent = lines
|
let indent = lines
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ pub struct ControlPlane {
|
|||||||
/// disabled. It doesn't consume any bytes and always returns a default
|
/// disabled. It doesn't consume any bytes and always returns a default
|
||||||
/// control plane.
|
/// control plane.
|
||||||
impl arbitrary::Arbitrary<'_> for ControlPlane {
|
impl arbitrary::Arbitrary<'_> for ControlPlane {
|
||||||
fn arbitrary<'a>(_u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
|
fn arbitrary(_u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
|
||||||
Ok(Self::default())
|
Ok(Self::default())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ impl<'a> Codegen<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn generate_ctx_trait(&self, code: &mut String) {
|
fn generate_ctx_trait(&self, code: &mut String) {
|
||||||
writeln!(code, "").unwrap();
|
writeln!(code).unwrap();
|
||||||
writeln!(
|
writeln!(
|
||||||
code,
|
code,
|
||||||
"/// Context during lowering: an implementation of this trait"
|
"/// Context during lowering: an implementation of this trait"
|
||||||
@@ -287,7 +287,7 @@ impl<'a> Codegen<'a> {
|
|||||||
for field in &variant.fields {
|
for field in &variant.fields {
|
||||||
let name = &self.typeenv.syms[field.name.index()];
|
let name = &self.typeenv.syms[field.name.index()];
|
||||||
let ty_name =
|
let ty_name =
|
||||||
self.typeenv.types[field.ty.index()].name(&self.typeenv);
|
self.typeenv.types[field.ty.index()].name(self.typeenv);
|
||||||
writeln!(code, " {}: {},", name, ty_name).unwrap();
|
writeln!(code, " {}: {},", name, ty_name).unwrap();
|
||||||
}
|
}
|
||||||
writeln!(code, " }},").unwrap();
|
writeln!(code, " }},").unwrap();
|
||||||
@@ -301,9 +301,9 @@ impl<'a> Codegen<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn type_name(&self, typeid: TypeId, by_ref: bool) -> String {
|
fn type_name(&self, typeid: TypeId, by_ref: bool) -> String {
|
||||||
match &self.typeenv.types[typeid.index()] {
|
match self.typeenv.types[typeid.index()] {
|
||||||
&Type::Primitive(_, sym, _) => self.typeenv.syms[sym.index()].clone(),
|
Type::Primitive(_, sym, _) => self.typeenv.syms[sym.index()].clone(),
|
||||||
&Type::Enum { name, .. } => {
|
Type::Enum { name, .. } => {
|
||||||
let r = if by_ref { "&" } else { "" };
|
let r = if by_ref { "&" } else { "" };
|
||||||
format!("{}{}", r, self.typeenv.syms[name.index()])
|
format!("{}{}", r, self.typeenv.syms[name.index()])
|
||||||
}
|
}
|
||||||
@@ -620,7 +620,7 @@ impl<'a> Codegen<'a> {
|
|||||||
&self.typeenv.syms[field.name.index()],
|
&self.typeenv.syms[field.name.index()],
|
||||||
)?;
|
)?;
|
||||||
self.emit_expr(ctx, *value)?;
|
self.emit_expr(ctx, *value)?;
|
||||||
if ctx.is_ref.contains(&value) {
|
if ctx.is_ref.contains(value) {
|
||||||
write!(ctx.out, ".clone()")?;
|
write!(ctx.out, ".clone()")?;
|
||||||
}
|
}
|
||||||
writeln!(ctx.out, ",")?;
|
writeln!(ctx.out, ",")?;
|
||||||
|
|||||||
@@ -19,13 +19,13 @@ impl std::fmt::Debug for Errors {
|
|||||||
}
|
}
|
||||||
let diagnostics = Vec::from_iter(self.errors.iter().map(|e| {
|
let diagnostics = Vec::from_iter(self.errors.iter().map(|e| {
|
||||||
let message = match e {
|
let message = match e {
|
||||||
Error::IoError { context, .. } => format!("{}", context),
|
Error::IoError { context, .. } => context.clone(),
|
||||||
Error::ParseError { msg, .. } => format!("parse error: {}", msg),
|
Error::ParseError { msg, .. } => format!("parse error: {}", msg),
|
||||||
Error::TypeError { msg, .. } => format!("type error: {}", msg),
|
Error::TypeError { msg, .. } => format!("type error: {}", msg),
|
||||||
Error::UnreachableError { msg, .. } => format!("unreachable rule: {}", msg),
|
Error::UnreachableError { msg, .. } => format!("unreachable rule: {}", msg),
|
||||||
Error::OverlapError { msg, .. } => format!("overlap error: {}", msg),
|
Error::OverlapError { msg, .. } => format!("overlap error: {}", msg),
|
||||||
Error::ShadowedError { .. } => {
|
Error::ShadowedError { .. } => {
|
||||||
format!("more general higher-priority rule shadows other rules")
|
"more general higher-priority rule shadows other rules".to_string()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ impl<'a> Lexer<'a> {
|
|||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
for text in &file_texts {
|
for text in &file_texts {
|
||||||
file_starts.push(buf.len());
|
file_starts.push(buf.len());
|
||||||
buf += &text;
|
buf += text;
|
||||||
buf += "\n";
|
buf += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,18 +316,12 @@ impl<'a> Lexer<'a> {
|
|||||||
impl Token {
|
impl Token {
|
||||||
/// Is this an `Int` token?
|
/// Is this an `Int` token?
|
||||||
pub fn is_int(&self) -> bool {
|
pub fn is_int(&self) -> bool {
|
||||||
match self {
|
matches!(self, Token::Int(_))
|
||||||
Token::Int(_) => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is this a `Sym` token?
|
/// Is this a `Sym` token?
|
||||||
pub fn is_sym(&self) -> bool {
|
pub fn is_sym(&self) -> bool {
|
||||||
match self {
|
matches!(self, Token::Symbol(_))
|
||||||
Token::Symbol(_) => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is<F: Fn(&Token) -> bool>(&self, f: F) -> bool {
|
fn is<F: Fn(&Token) -> bool>(&self, f: F) -> bool {
|
||||||
if let Some(&(_, ref peek)) = self.lexer.peek() {
|
if let Some((_, peek)) = self.lexer.peek() {
|
||||||
f(peek)
|
f(peek)
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
@@ -99,7 +99,7 @@ impl<'a> Parser<'a> {
|
|||||||
|
|
||||||
fn is_const(&self) -> bool {
|
fn is_const(&self) -> bool {
|
||||||
self.is(|tok| match tok {
|
self.is(|tok| match tok {
|
||||||
&Token::Symbol(ref tok_s) if tok_s.starts_with("$") => true,
|
Token::Symbol(tok_s) if tok_s.starts_with('$') => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ impl<'a> Parser<'a> {
|
|||||||
|
|
||||||
fn eat_sym_str(&mut self, s: &str) -> Result<bool> {
|
fn eat_sym_str(&mut self, s: &str) -> Result<bool> {
|
||||||
self.eat(|tok| match tok {
|
self.eat(|tok| match tok {
|
||||||
&Token::Symbol(ref tok_s) if tok_s == s => true,
|
Token::Symbol(ref tok_s) if tok_s == s => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
})
|
})
|
||||||
.map(|token| token.is_some())
|
.map(|token| token.is_some())
|
||||||
@@ -202,8 +202,7 @@ impl<'a> Parser<'a> {
|
|||||||
fn parse_const(&mut self) -> Result<Ident> {
|
fn parse_const(&mut self) -> Result<Ident> {
|
||||||
let pos = self.pos();
|
let pos = self.pos();
|
||||||
let ident = self.parse_ident()?;
|
let ident = self.parse_ident()?;
|
||||||
if ident.0.starts_with("$") {
|
if let Some(s) = ident.0.strip_prefix('$') {
|
||||||
let s = &ident.0[1..];
|
|
||||||
Ok(Ident(s.to_string(), ident.1))
|
Ok(Ident(s.to_string(), ident.1))
|
||||||
} else {
|
} else {
|
||||||
Err(self.error(
|
Err(self.error(
|
||||||
@@ -216,9 +215,8 @@ impl<'a> Parser<'a> {
|
|||||||
fn parse_pragma(&mut self) -> Result<Pragma> {
|
fn parse_pragma(&mut self) -> Result<Pragma> {
|
||||||
let ident = self.parse_ident()?;
|
let ident = self.parse_ident()?;
|
||||||
// currently, no pragmas are defined, but the infrastructure is useful to keep around
|
// currently, no pragmas are defined, but the infrastructure is useful to keep around
|
||||||
match ident.0.as_str() {
|
let pragma = ident.0.as_str();
|
||||||
pragma => Err(self.error(ident.1, format!("Unknown pragma '{}'", pragma))),
|
Err(self.error(ident.1, format!("Unknown pragma '{}'", pragma)))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_type(&mut self) -> Result<Type> {
|
fn parse_type(&mut self) -> Result<Type> {
|
||||||
@@ -472,7 +470,7 @@ impl<'a> Parser<'a> {
|
|||||||
self.expect_rparen()?;
|
self.expect_rparen()?;
|
||||||
Ok(ret)
|
Ok(ret)
|
||||||
} else {
|
} else {
|
||||||
self.parse_expr().map(|expr| IfLetOrExpr::Expr(expr))
|
self.parse_expr().map(IfLetOrExpr::Expr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -595,14 +595,14 @@ pub trait PatternVisitor {
|
|||||||
impl Pattern {
|
impl Pattern {
|
||||||
/// Get this pattern's type.
|
/// Get this pattern's type.
|
||||||
pub fn ty(&self) -> TypeId {
|
pub fn ty(&self) -> TypeId {
|
||||||
match self {
|
match *self {
|
||||||
&Self::BindPattern(t, ..) => t,
|
Self::BindPattern(t, ..) => t,
|
||||||
&Self::Var(t, ..) => t,
|
Self::Var(t, ..) => t,
|
||||||
&Self::ConstInt(t, ..) => t,
|
Self::ConstInt(t, ..) => t,
|
||||||
&Self::ConstPrim(t, ..) => t,
|
Self::ConstPrim(t, ..) => t,
|
||||||
&Self::Term(t, ..) => t,
|
Self::Term(t, ..) => t,
|
||||||
&Self::Wildcard(t, ..) => t,
|
Self::Wildcard(t, ..) => t,
|
||||||
&Self::And(t, ..) => t,
|
Self::And(t, ..) => t,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -614,14 +614,14 @@ impl Pattern {
|
|||||||
termenv: &TermEnv,
|
termenv: &TermEnv,
|
||||||
vars: &mut HashMap<VarId, V::PatternId>,
|
vars: &mut HashMap<VarId, V::PatternId>,
|
||||||
) {
|
) {
|
||||||
match self {
|
match *self {
|
||||||
&Pattern::BindPattern(_ty, var, ref subpat) => {
|
Pattern::BindPattern(_ty, var, ref subpat) => {
|
||||||
// Bind the appropriate variable and recurse.
|
// Bind the appropriate variable and recurse.
|
||||||
assert!(!vars.contains_key(&var));
|
assert!(!vars.contains_key(&var));
|
||||||
vars.insert(var, input);
|
vars.insert(var, input);
|
||||||
subpat.visit(visitor, input, termenv, vars);
|
subpat.visit(visitor, input, termenv, vars);
|
||||||
}
|
}
|
||||||
&Pattern::Var(ty, var) => {
|
Pattern::Var(ty, var) => {
|
||||||
// Assert that the value matches the existing bound var.
|
// Assert that the value matches the existing bound var.
|
||||||
let var_val = vars
|
let var_val = vars
|
||||||
.get(&var)
|
.get(&var)
|
||||||
@@ -629,9 +629,9 @@ impl Pattern {
|
|||||||
.expect("Variable should already be bound");
|
.expect("Variable should already be bound");
|
||||||
visitor.add_match_equal(input, var_val, ty);
|
visitor.add_match_equal(input, var_val, ty);
|
||||||
}
|
}
|
||||||
&Pattern::ConstInt(ty, value) => visitor.add_match_int(input, ty, value),
|
Pattern::ConstInt(ty, value) => visitor.add_match_int(input, ty, value),
|
||||||
&Pattern::ConstPrim(ty, value) => visitor.add_match_prim(input, ty, value),
|
Pattern::ConstPrim(ty, value) => visitor.add_match_prim(input, ty, value),
|
||||||
&Pattern::Term(ty, term, ref args) => {
|
Pattern::Term(ty, term, ref args) => {
|
||||||
// Determine whether the term has an external extractor or not.
|
// Determine whether the term has an external extractor or not.
|
||||||
let termdata = &termenv.terms[term.index()];
|
let termdata = &termenv.terms[term.index()];
|
||||||
let arg_values = match &termdata.kind {
|
let arg_values = match &termdata.kind {
|
||||||
@@ -673,12 +673,12 @@ impl Pattern {
|
|||||||
pat.visit(visitor, val, termenv, vars);
|
pat.visit(visitor, val, termenv, vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&Pattern::And(_ty, ref children) => {
|
Pattern::And(_ty, ref children) => {
|
||||||
for child in children {
|
for child in children {
|
||||||
child.visit(visitor, input, termenv, vars);
|
child.visit(visitor, input, termenv, vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&Pattern::Wildcard(_ty) => {
|
Pattern::Wildcard(_ty) => {
|
||||||
// Nothing!
|
// Nothing!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -719,12 +719,12 @@ pub trait ExprVisitor {
|
|||||||
impl Expr {
|
impl Expr {
|
||||||
/// Get this expression's type.
|
/// Get this expression's type.
|
||||||
pub fn ty(&self) -> TypeId {
|
pub fn ty(&self) -> TypeId {
|
||||||
match self {
|
match *self {
|
||||||
&Self::Term(t, ..) => t,
|
Self::Term(t, ..) => t,
|
||||||
&Self::Var(t, ..) => t,
|
Self::Var(t, ..) => t,
|
||||||
&Self::ConstInt(t, ..) => t,
|
Self::ConstInt(t, ..) => t,
|
||||||
&Self::ConstPrim(t, ..) => t,
|
Self::ConstPrim(t, ..) => t,
|
||||||
&Self::Let { ty: t, .. } => t,
|
Self::Let { ty: t, .. } => t,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -736,10 +736,10 @@ impl Expr {
|
|||||||
vars: &HashMap<VarId, V::ExprId>,
|
vars: &HashMap<VarId, V::ExprId>,
|
||||||
) -> V::ExprId {
|
) -> V::ExprId {
|
||||||
log!("Expr::visit: expr {:?}", self);
|
log!("Expr::visit: expr {:?}", self);
|
||||||
match self {
|
match *self {
|
||||||
&Expr::ConstInt(ty, val) => visitor.add_const_int(ty, val),
|
Expr::ConstInt(ty, val) => visitor.add_const_int(ty, val),
|
||||||
&Expr::ConstPrim(ty, val) => visitor.add_const_prim(ty, val),
|
Expr::ConstPrim(ty, val) => visitor.add_const_prim(ty, val),
|
||||||
&Expr::Let {
|
Expr::Let {
|
||||||
ty: _ty,
|
ty: _ty,
|
||||||
ref bindings,
|
ref bindings,
|
||||||
ref body,
|
ref body,
|
||||||
@@ -751,8 +751,8 @@ impl Expr {
|
|||||||
}
|
}
|
||||||
body.visit(visitor, termenv, &vars)
|
body.visit(visitor, termenv, &vars)
|
||||||
}
|
}
|
||||||
&Expr::Var(_ty, var_id) => *vars.get(&var_id).unwrap(),
|
Expr::Var(_ty, var_id) => *vars.get(&var_id).unwrap(),
|
||||||
&Expr::Term(ty, term, ref arg_exprs) => {
|
Expr::Term(ty, term, ref arg_exprs) => {
|
||||||
let termdata = &termenv.terms[term.index()];
|
let termdata = &termenv.terms[term.index()];
|
||||||
let arg_values_tys = arg_exprs
|
let arg_values_tys = arg_exprs
|
||||||
.iter()
|
.iter()
|
||||||
@@ -957,23 +957,21 @@ impl TypeEnv {
|
|||||||
|
|
||||||
// Now collect types for extern constants.
|
// Now collect types for extern constants.
|
||||||
for def in &defs.defs {
|
for def in &defs.defs {
|
||||||
match def {
|
if let &ast::Def::Extern(ast::Extern::Const {
|
||||||
&ast::Def::Extern(ast::Extern::Const {
|
ref name,
|
||||||
ref name,
|
ref ty,
|
||||||
ref ty,
|
pos,
|
||||||
pos,
|
}) = def
|
||||||
}) => {
|
{
|
||||||
let ty = match tyenv.get_type_by_name(ty) {
|
let ty = match tyenv.get_type_by_name(ty) {
|
||||||
Some(ty) => ty,
|
Some(ty) => ty,
|
||||||
None => {
|
None => {
|
||||||
tyenv.report_error(pos, "Unknown type for constant");
|
tyenv.report_error(pos, "Unknown type for constant");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let name = tyenv.intern_mut(name);
|
let name = tyenv.intern_mut(name);
|
||||||
tyenv.const_types.insert(name, ty);
|
tyenv.const_types.insert(name, ty);
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1221,7 +1219,6 @@ impl TermEnv {
|
|||||||
.map(|id| {
|
.map(|id| {
|
||||||
tyenv.get_type_by_name(id).ok_or_else(|| {
|
tyenv.get_type_by_name(id).ok_or_else(|| {
|
||||||
tyenv.report_error(id.1, format!("Unknown arg type: '{}'", id.0));
|
tyenv.report_error(id.1, format!("Unknown arg type: '{}'", id.0));
|
||||||
()
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.collect::<Result<Vec<_>, _>>();
|
.collect::<Result<Vec<_>, _>>();
|
||||||
|
|||||||
2
crates/cache/build.rs
vendored
2
crates/cache/build.rs
vendored
@@ -2,7 +2,7 @@ use std::process::Command;
|
|||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let git_rev = match Command::new("git").args(&["rev-parse", "HEAD"]).output() {
|
let git_rev = match Command::new("git").args(["rev-parse", "HEAD"]).output() {
|
||||||
Ok(output) => str::from_utf8(&output.stdout).unwrap().trim().to_string(),
|
Ok(output) => str::from_utf8(&output.stdout).unwrap().trim().to_string(),
|
||||||
Err(_) => env!("CARGO_PKG_VERSION").to_string(),
|
Err(_) => env!("CARGO_PKG_VERSION").to_string(),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ fn parse_source(source: &Option<Source>) -> anyhow::Result<(Resolve, PackageId,
|
|||||||
let root = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
|
let root = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
|
||||||
let mut parse = |path: &Path| -> anyhow::Result<_> {
|
let mut parse = |path: &Path| -> anyhow::Result<_> {
|
||||||
if path.is_dir() {
|
if path.is_dir() {
|
||||||
let (pkg, sources) = resolve.push_dir(&path)?;
|
let (pkg, sources) = resolve.push_dir(path)?;
|
||||||
files = sources;
|
files = sources;
|
||||||
Ok(pkg)
|
Ok(pkg)
|
||||||
} else {
|
} else {
|
||||||
@@ -128,10 +128,10 @@ fn parse_source(source: &Option<Source>) -> anyhow::Result<(Resolve, PackageId,
|
|||||||
};
|
};
|
||||||
let pkg = match source {
|
let pkg = match source {
|
||||||
Some(Source::Inline(s)) => resolve.push(
|
Some(Source::Inline(s)) => resolve.push(
|
||||||
UnresolvedPackage::parse("macro-input".as_ref(), &s)?,
|
UnresolvedPackage::parse("macro-input".as_ref(), s)?,
|
||||||
&Default::default(),
|
&Default::default(),
|
||||||
)?,
|
)?,
|
||||||
Some(Source::Path(s)) => parse(&root.join(&s))?,
|
Some(Source::Path(s)) => parse(&root.join(s))?,
|
||||||
None => parse(&root.join("wit"))?,
|
None => parse(&root.join("wit"))?,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -151,9 +151,9 @@ impl Wasmtime {
|
|||||||
let mut gen = InterfaceGenerator::new(self, resolve);
|
let mut gen = InterfaceGenerator::new(self, resolve);
|
||||||
let import = match item {
|
let import = match item {
|
||||||
WorldItem::Function(func) => {
|
WorldItem::Function(func) => {
|
||||||
gen.generate_function_trait_sig(TypeOwner::None, &func);
|
gen.generate_function_trait_sig(TypeOwner::None, func);
|
||||||
let sig = mem::take(&mut gen.src).into();
|
let sig = mem::take(&mut gen.src).into();
|
||||||
gen.generate_add_function_to_linker(TypeOwner::None, &func, "linker");
|
gen.generate_add_function_to_linker(TypeOwner::None, func, "linker");
|
||||||
let add_to_linker = gen.src.into();
|
let add_to_linker = gen.src.into();
|
||||||
Import::Function { sig, add_to_linker }
|
Import::Function { sig, add_to_linker }
|
||||||
}
|
}
|
||||||
@@ -203,7 +203,7 @@ impl Wasmtime {
|
|||||||
let (_name, getter) = gen.extract_typed_function(func);
|
let (_name, getter) = gen.extract_typed_function(func);
|
||||||
assert!(gen.src.is_empty());
|
assert!(gen.src.is_empty());
|
||||||
self.exports.funcs.push(body);
|
self.exports.funcs.push(body);
|
||||||
(format!("wasmtime::component::Func"), getter)
|
("wasmtime::component::Func".to_string(), getter)
|
||||||
}
|
}
|
||||||
WorldItem::Type(_) => unreachable!(),
|
WorldItem::Type(_) => unreachable!(),
|
||||||
WorldItem::Interface(id) => {
|
WorldItem::Interface(id) => {
|
||||||
@@ -1051,9 +1051,9 @@ impl<'a> InterfaceGenerator<'a> {
|
|||||||
uwriteln!(self.src, "}}");
|
uwriteln!(self.src, "}}");
|
||||||
|
|
||||||
let where_clause = if self.gen.opts.async_ {
|
let where_clause = if self.gen.opts.async_ {
|
||||||
format!("T: Send, U: Host + Send")
|
"T: Send, U: Host + Send".to_string()
|
||||||
} else {
|
} else {
|
||||||
format!("U: Host")
|
"U: Host".to_string()
|
||||||
};
|
};
|
||||||
uwriteln!(
|
uwriteln!(
|
||||||
self.src,
|
self.src,
|
||||||
@@ -1259,7 +1259,7 @@ impl<'a> InterfaceGenerator<'a> {
|
|||||||
|
|
||||||
let ret = (snake, mem::take(&mut self.src).to_string());
|
let ret = (snake, mem::take(&mut self.src).to_string());
|
||||||
self.src = prev;
|
self.src = prev;
|
||||||
return ret;
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
fn define_rust_guest_export(&mut self, ns: Option<&str>, func: &Function) {
|
fn define_rust_guest_export(&mut self, ns: Option<&str>, func: &Function) {
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ pub trait RustGenerator<'a> {
|
|||||||
if self.uses_two_names(&info) {
|
if self.uses_two_names(&info) {
|
||||||
result.push((self.param_name(ty), TypeMode::AllBorrowed("'a")));
|
result.push((self.param_name(ty), TypeMode::AllBorrowed("'a")));
|
||||||
}
|
}
|
||||||
return result;
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Writes the camel-cased 'name' of the passed type to `out`, as used to name union variants.
|
/// Writes the camel-cased 'name' of the passed type to `out`, as used to name union variants.
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ impl Types {
|
|||||||
_ => continue,
|
_ => continue,
|
||||||
};
|
};
|
||||||
if let Some(Type::Id(id)) = err {
|
if let Some(Type::Id(id)) = err {
|
||||||
self.type_info.get_mut(&id).unwrap().error = true;
|
self.type_info.get_mut(id).unwrap().error = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user