Use .. for (_).
This commit is contained in:
@@ -366,7 +366,7 @@ impl Parse for ExportedFn {
|
||||
}) => {
|
||||
matches!(flatten_type_groups(elem.as_ref()), syn::Type::Path(ref p) if p.path == str_type_path)
|
||||
}
|
||||
syn::Type::Verbatim(_) => false,
|
||||
syn::Type::Verbatim(..) => false,
|
||||
_ => true,
|
||||
};
|
||||
if !is_ok {
|
||||
@@ -381,13 +381,13 @@ impl Parse for ExportedFn {
|
||||
match fn_all.sig.output {
|
||||
syn::ReturnType::Type(.., ref ret_type) => {
|
||||
match flatten_type_groups(ret_type.as_ref()) {
|
||||
syn::Type::Ptr(_) => {
|
||||
syn::Type::Ptr(..) => {
|
||||
return Err(syn::Error::new(
|
||||
fn_all.sig.output.span(),
|
||||
"Rhai functions cannot return pointers",
|
||||
))
|
||||
}
|
||||
syn::Type::Reference(_) => {
|
||||
syn::Type::Reference(..) => {
|
||||
return Err(syn::Error::new(
|
||||
fn_all.sig.output.span(),
|
||||
"Rhai functions cannot return references",
|
||||
@@ -544,28 +544,28 @@ impl ExportedFn {
|
||||
|
||||
match params.special {
|
||||
// 2a. Property getters must take only the subject as an argument.
|
||||
FnSpecialAccess::Property(Property::Get(_)) if self.arg_count() != 1 => {
|
||||
FnSpecialAccess::Property(Property::Get(..)) if self.arg_count() != 1 => {
|
||||
return Err(syn::Error::new(
|
||||
self.signature.inputs.span(),
|
||||
"property getter requires exactly 1 parameter",
|
||||
))
|
||||
}
|
||||
// 2b. Property getters must return a value.
|
||||
FnSpecialAccess::Property(Property::Get(_)) if self.return_type().is_none() => {
|
||||
FnSpecialAccess::Property(Property::Get(..)) if self.return_type().is_none() => {
|
||||
return Err(syn::Error::new(
|
||||
self.signature.span(),
|
||||
"property getter must return a value",
|
||||
))
|
||||
}
|
||||
// 3a. Property setters must take the subject and a new value as arguments.
|
||||
FnSpecialAccess::Property(Property::Set(_)) if self.arg_count() != 2 => {
|
||||
FnSpecialAccess::Property(Property::Set(..)) if self.arg_count() != 2 => {
|
||||
return Err(syn::Error::new(
|
||||
self.signature.inputs.span(),
|
||||
"property setter requires exactly 2 parameters",
|
||||
))
|
||||
}
|
||||
// 3b. Non-raw property setters must return nothing.
|
||||
FnSpecialAccess::Property(Property::Set(_))
|
||||
FnSpecialAccess::Property(Property::Set(..))
|
||||
if params.return_raw.is_none() && self.return_type().is_some() =>
|
||||
{
|
||||
return Err(syn::Error::new(
|
||||
@@ -734,7 +734,7 @@ impl ExportedFn {
|
||||
.unwrap(),
|
||||
);
|
||||
}
|
||||
syn::FnArg::Receiver(_) => todo!("true self parameters not implemented yet"),
|
||||
syn::FnArg::Receiver(..) => todo!("true self parameters not implemented yet"),
|
||||
}
|
||||
unpack_exprs.push(syn::parse2::<syn::Expr>(quote! { #var }).unwrap());
|
||||
} else {
|
||||
@@ -811,7 +811,7 @@ impl ExportedFn {
|
||||
);
|
||||
}
|
||||
}
|
||||
syn::FnArg::Receiver(_) => panic!("internal error: how did this happen!?"),
|
||||
syn::FnArg::Receiver(..) => panic!("internal error: how did this happen!?"),
|
||||
}
|
||||
if !is_ref {
|
||||
unpack_exprs.push(syn::parse2::<syn::Expr>(quote! { #var }).unwrap());
|
||||
|
@@ -144,12 +144,14 @@ impl Parse for Module {
|
||||
attrs,
|
||||
ty,
|
||||
..
|
||||
}) if matches!(vis, syn::Visibility::Public(_)) => consts.push(ExportedConst {
|
||||
name: ident.to_string(),
|
||||
typ: ty.clone(),
|
||||
expr: expr.as_ref().clone(),
|
||||
cfg_attrs: crate::attrs::collect_cfg_attr(&attrs),
|
||||
}),
|
||||
}) if matches!(vis, syn::Visibility::Public(..)) => {
|
||||
consts.push(ExportedConst {
|
||||
name: ident.to_string(),
|
||||
typ: ty.clone(),
|
||||
expr: expr.as_ref().clone(),
|
||||
cfg_attrs: crate::attrs::collect_cfg_attr(&attrs),
|
||||
})
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -161,7 +163,7 @@ impl Parse for Module {
|
||||
let mut i = 0;
|
||||
while i < content.len() {
|
||||
match content[i] {
|
||||
syn::Item::Mod(_) => {
|
||||
syn::Item::Mod(..) => {
|
||||
let mut item_mod = match content.remove(i) {
|
||||
syn::Item::Mod(m) => m,
|
||||
_ => unreachable!(),
|
||||
@@ -212,7 +214,7 @@ impl Module {
|
||||
pub fn update_scope(&mut self, parent_scope: &ExportScope) {
|
||||
let keep = match (self.params.skip, parent_scope) {
|
||||
(true, ..) => false,
|
||||
(.., ExportScope::PubOnly) => matches!(self.mod_all.vis, syn::Visibility::Public(_)),
|
||||
(.., ExportScope::PubOnly) => matches!(self.mod_all.vis, syn::Visibility::Public(..)),
|
||||
(.., ExportScope::Prefix(s)) => self.mod_all.ident.to_string().starts_with(s),
|
||||
(.., ExportScope::All) => true,
|
||||
};
|
||||
|
@@ -99,7 +99,7 @@ pub fn generate_body(
|
||||
let fn_input_types: Vec<_> = function
|
||||
.arg_list()
|
||||
.map(|fn_arg| match fn_arg {
|
||||
syn::FnArg::Receiver(_) => panic!("internal error: receiver fn outside impl!?"),
|
||||
syn::FnArg::Receiver(..) => panic!("internal error: receiver fn outside impl!?"),
|
||||
syn::FnArg::Typed(syn::PatType { ref ty, .. }) => {
|
||||
let arg_type = match flatten_type_groups(ty.as_ref()) {
|
||||
syn::Type::Reference(syn::TypeReference {
|
||||
@@ -150,7 +150,7 @@ pub fn generate_body(
|
||||
|
||||
match function.params().special {
|
||||
FnSpecialAccess::None => (),
|
||||
FnSpecialAccess::Index(_) | FnSpecialAccess::Property(_) => {
|
||||
FnSpecialAccess::Index(..) | FnSpecialAccess::Property(..) => {
|
||||
let reg_name = fn_literal.value();
|
||||
if reg_name.starts_with(FN_GET)
|
||||
|| reg_name.starts_with(FN_SET)
|
||||
@@ -254,7 +254,7 @@ pub fn check_rename_collisions(fns: &[ExportedFn]) -> Result<(), syn::Error> {
|
||||
.arg_list()
|
||||
.fold(name.to_string(), |mut arg_str, fn_arg| {
|
||||
let type_string: String = match fn_arg {
|
||||
syn::FnArg::Receiver(_) => unimplemented!("receiver rhai_fns not implemented"),
|
||||
syn::FnArg::Receiver(..) => unimplemented!("receiver rhai_fns not implemented"),
|
||||
syn::FnArg::Typed(syn::PatType { ref ty, .. }) => print_type(ty),
|
||||
};
|
||||
arg_str.push('.');
|
||||
|
Reference in New Issue
Block a user