From 8abb3c52037099cce5268714709a19d3e0c89ad2 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Thu, 15 Oct 2020 14:06:54 +0800 Subject: [PATCH] Fix ui tests. --- codegen/src/function.rs | 16 ++++++++-------- codegen/src/rhai_module.rs | 2 +- codegen/ui_tests/export_fn_raw_noreturn.stderr | 2 +- codegen/ui_tests/export_mod_raw_noreturn.stderr | 2 +- codegen/ui_tests/return_shared_ref.stderr | 2 +- codegen/ui_tests/rhai_fn_setter_return.stderr | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/codegen/src/function.rs b/codegen/src/function.rs index 0d34c266..a992e858 100644 --- a/codegen/src/function.rs +++ b/codegen/src/function.rs @@ -261,7 +261,7 @@ impl Parse for ExportedFn { ref elem, .. }) => match flatten_type_groups(elem.as_ref()) { - &syn::Type::Path(ref p) if p.path == str_type_path => false, + syn::Type::Path(ref p) if p.path == str_type_path => false, _ => { return Err(syn::Error::new( ty.span(), @@ -296,7 +296,7 @@ impl Parse for ExportedFn { ref elem, .. }) => { - matches!(flatten_type_groups(elem.as_ref()), &syn::Type::Path(ref p) if p.path == str_type_path) + matches!(flatten_type_groups(elem.as_ref()), syn::Type::Path(ref p) if p.path == str_type_path) } syn::Type::Verbatim(_) => false, _ => true, @@ -632,8 +632,8 @@ impl ExportedFn { let var = syn::Ident::new("arg0", proc_macro2::Span::call_site()); match first_arg { syn::FnArg::Typed(pattern) => { - let arg_type: &syn::Type = match flatten_type_groups(pattern.ty.as_ref()) { - &syn::Type::Reference(syn::TypeReference { ref elem, .. }) => elem.as_ref(), + let arg_type = match flatten_type_groups(pattern.ty.as_ref()) { + syn::Type::Reference(syn::TypeReference { ref elem, .. }) => elem.as_ref(), p => p, }; let downcast_span = quote_spanned!( @@ -670,14 +670,14 @@ impl ExportedFn { let is_ref; match arg { syn::FnArg::Typed(pattern) => { - let arg_type: &syn::Type = pattern.ty.as_ref(); + let arg_type = pattern.ty.as_ref(); let downcast_span = match flatten_type_groups(pattern.ty.as_ref()) { - &syn::Type::Reference(syn::TypeReference { + syn::Type::Reference(syn::TypeReference { mutability: None, ref elem, .. }) => match flatten_type_groups(elem.as_ref()) { - &syn::Type::Path(ref p) if p.path == str_type_path => { + syn::Type::Path(ref p) if p.path == str_type_path => { is_string = true; is_ref = true; quote_spanned!(arg_type.span()=> @@ -685,7 +685,7 @@ impl ExportedFn { } _ => panic!("internal error: why wasn't this found earlier!?"), }, - &syn::Type::Path(ref p) if p.path == string_type_path => { + syn::Type::Path(ref p) if p.path == string_type_path => { is_string = true; is_ref = false; quote_spanned!(arg_type.span()=> diff --git a/codegen/src/rhai_module.rs b/codegen/src/rhai_module.rs index f18e809e..fec67d1c 100644 --- a/codegen/src/rhai_module.rs +++ b/codegen/src/rhai_module.rs @@ -38,7 +38,7 @@ pub(crate) fn generate_body( if itemmod.skipped() { continue; } - let module_name: &syn::Ident = itemmod.module_name().unwrap(); + let module_name = itemmod.module_name().unwrap(); let exported_name: syn::LitStr = if let Some(name) = itemmod.exported_name() { syn::LitStr::new(&name, proc_macro2::Span::call_site()) } else { diff --git a/codegen/ui_tests/export_fn_raw_noreturn.stderr b/codegen/ui_tests/export_fn_raw_noreturn.stderr index 0687c8c6..db719f9b 100644 --- a/codegen/ui_tests/export_fn_raw_noreturn.stderr +++ b/codegen/ui_tests/export_fn_raw_noreturn.stderr @@ -1,4 +1,4 @@ -error: return_raw functions must return Result +error: return_raw functions must return Result> --> $DIR/export_fn_raw_noreturn.rs:10:5 | 10 | pub fn test_fn(input: &mut Point) { diff --git a/codegen/ui_tests/export_mod_raw_noreturn.stderr b/codegen/ui_tests/export_mod_raw_noreturn.stderr index 74fd381f..dc7bf10f 100644 --- a/codegen/ui_tests/export_mod_raw_noreturn.stderr +++ b/codegen/ui_tests/export_mod_raw_noreturn.stderr @@ -1,4 +1,4 @@ -error: return_raw functions must return Result +error: return_raw functions must return Result> --> $DIR/export_mod_raw_noreturn.rs:12:5 | 12 | pub fn test_fn(input: &mut Point) { diff --git a/codegen/ui_tests/return_shared_ref.stderr b/codegen/ui_tests/return_shared_ref.stderr index 50d223ef..9b7a91ca 100644 --- a/codegen/ui_tests/return_shared_ref.stderr +++ b/codegen/ui_tests/return_shared_ref.stderr @@ -1,4 +1,4 @@ -error: Rhai functions cannot return pointers +error: Rhai functions cannot return references --> $DIR/return_shared_ref.rs:12:33 | 12 | pub fn test_fn(input: Clonable) -> &'static str { diff --git a/codegen/ui_tests/rhai_fn_setter_return.stderr b/codegen/ui_tests/rhai_fn_setter_return.stderr index db37a80f..d55e2073 100644 --- a/codegen/ui_tests/rhai_fn_setter_return.stderr +++ b/codegen/ui_tests/rhai_fn_setter_return.stderr @@ -1,4 +1,4 @@ -error: property setter must return no value +error: property setter cannot return any value --> $DIR/rhai_fn_setter_return.rs:13:9 | 13 | pub fn test_fn(input: &mut Point, value: f32) -> bool {