Repository: lambda-fairy/maud (rust)

Issue:
Incorrect expression hygiene results in cryptic errors
Consider the following invocation:

```rust
html! {
  (1 + 1)
}
```

This expands to

```rust
{
    extern crate alloc;
    extern crate maud;
    let mut __maud_output = alloc::string::String::with_capacity(7usize);
    {
        use ::maud::macro_private::*;
        match ChooseRenderOrDisplay(&1 + 1) { // <- the problem
            x => (&&x)
                .implements_render_or_display()
                .render_to(x.0, &mut __maud_output),
        }
    };
    maud::PreEscaped(__maud_output)
}
```

Clearly `&1 + 1` should have been `&(1 + 1)`.

(Also, the String size hint is wrong.)

Pull request description:
Fix #382
A pretty straightforward fix

Fixes #382

Patch:
diff --git a/maud_macros/src/generate.rs b/maud_macros/src/generate.rs
index c9ba9fb..ee27a55 100644
--- a/maud_macros/src/generate.rs
+++ b/maud_macros/src/generate.rs
@@ -103,7 +103,7 @@ impl Generator {
 
     fn splice(&self, expr: TokenStream, build: &mut Builder) {
         let output_ident = self.output_ident.clone();
-        build.push_tokens(quote!(maud::macro_private::render_to!(&#expr, &mut #output_ident);));
+        build.push_tokens(quote!(maud::macro_private::render_to!(&(#expr), &mut #output_ident);));
     }
 
     fn element(&self, name: TokenStream, attrs: Vec<Attr>, body: ElementBody, build: &mut Builder) {


Test patch:
diff --git a/maud/tests/splices.rs b/maud/tests/splices.rs
index d3fd511..8665e84 100644
--- a/maud/tests/splices.rs
+++ b/maud/tests/splices.rs
@@ -124,3 +124,9 @@ fn nested_macro_invocation() {
     let result = html! { (format!("{best_pony} is best pony")) };
     assert_eq!(result.into_string(), "Pinkie Pie is best pony");
 }
+
+#[test]
+fn expression_grouping() {
+    let result = html! { (1 + 1) };
+    assert_eq!(result.into_string(), "2");
+}