Fix syn regression.

This commit is contained in:
Stephen Chung 2021-03-29 12:46:46 +08:00
parent 60f8a7f91c
commit c0b2eee9f2
3 changed files with 9 additions and 5 deletions

View File

@ -21,5 +21,5 @@ trybuild = "1"
[dependencies] [dependencies]
proc-macro2 = "1" proc-macro2 = "1"
syn = { version = "1", features = ["full", "parsing", "printing", "proc-macro", "extra-traits"] } syn = { version = "1.0", features = ["full", "parsing", "printing", "proc-macro", "extra-traits"] }
quote = "1" quote = "1"

View File

@ -52,7 +52,8 @@ pub fn generate_body(
.collect(); .collect();
add_mod_blocks.push( add_mod_blocks.push(
syn::parse2::<syn::ExprBlock>(quote! { syn::parse2::<syn::ExprBlock>(quote! {
#(#cfg_attrs)* { {
#(#cfg_attrs)*
m.set_sub_module(#exported_name, self::#module_name::rhai_module_generate()); m.set_sub_module(#exported_name, self::#module_name::rhai_module_generate());
} }
}) })
@ -60,7 +61,8 @@ pub fn generate_body(
); );
set_flattened_mod_blocks.push( set_flattened_mod_blocks.push(
syn::parse2::<syn::ExprBlock>(quote! { syn::parse2::<syn::ExprBlock>(quote! {
#(#cfg_attrs)* { {
#(#cfg_attrs)*
self::#module_name::rhai_generate_into_module(m, flatten); self::#module_name::rhai_generate_into_module(m, flatten);
} }
}) })

View File

@ -1276,11 +1276,13 @@ mod generate_tests {
#[allow(unused_mut)] #[allow(unused_mut)]
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) { pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
if flatten { if flatten {
#[cfg(not(feature = "no_float"))] { {
#[cfg(not(feature = "no_float"))]
self::it_is::rhai_generate_into_module(m, flatten); self::it_is::rhai_generate_into_module(m, flatten);
} }
} else { } else {
#[cfg(not(feature = "no_float"))] { {
#[cfg(not(feature = "no_float"))]
m.set_sub_module("it_is", self::it_is::rhai_module_generate()); m.set_sub_module("it_is", self::it_is::rhai_module_generate());
} }
} }