From 652a54d943c0f87c57865ead166e69b76550b79b Mon Sep 17 00:00:00 2001 From: tdashelby-cmyk <253610080+tdashelby-cmyk@users.noreply.github.com> Date: Mon, 11 May 2026 14:23:36 +0200 Subject: [PATCH] Handle stable warning snapshots --- maud/Cargo.toml | 1 + maud/tests/errors.rs | 15 ++++++ .../warnings-stable/keyword-without-at.rs | 11 ++++ .../warnings-stable/keyword-without-at.stderr | 34 +++++++++++++ .../warnings-stable/non-string-literal.rs | 16 ++++++ .../warnings-stable/non-string-literal.stderr | 51 +++++++++++++++++++ .../warnings-stable/void-element-slash.rs | 9 ++++ .../warnings-stable/void-element-slash.stderr | 15 ++++++ 8 files changed, 152 insertions(+) create mode 100644 maud/tests/warnings-stable/keyword-without-at.rs create mode 100644 maud/tests/warnings-stable/keyword-without-at.stderr create mode 100644 maud/tests/warnings-stable/non-string-literal.rs create mode 100644 maud/tests/warnings-stable/non-string-literal.stderr create mode 100644 maud/tests/warnings-stable/void-element-slash.rs create mode 100644 maud/tests/warnings-stable/void-element-slash.stderr diff --git a/maud/Cargo.toml b/maud/Cargo.toml index 86149086..9f5c33f6 100644 --- a/maud/Cargo.toml +++ b/maud/Cargo.toml @@ -43,6 +43,7 @@ serde_json = { version = "1", optional = true } [dev-dependencies] serde = { version = "1", features = ["derive"] } +rustversion = "1" trybuild = { version = "1.0.33", features = ["diff"] } [package.metadata.docs.rs] diff --git a/maud/tests/errors.rs b/maud/tests/errors.rs index fa31fd1b..5180b273 100644 --- a/maud/tests/errors.rs +++ b/maud/tests/errors.rs @@ -1,7 +1,22 @@ use trybuild::TestCases; #[test] +#[rustversion::nightly] fn run_warnings() { let config = TestCases::new(); config.compile_fail("tests/warnings/*.rs"); } + +#[test] +#[rustversion::not(nightly)] +fn run_warnings() { + let config = TestCases::new(); + + config.compile_fail("tests/warnings/attribute-missing-value.rs"); + config.compile_fail("tests/warnings/class-shorthand-missing-value.rs"); + config.compile_fail("tests/warnings/dynamic-attribute-names.rs"); + config.compile_fail("tests/warnings/elements-in-attributes.rs"); + config.compile_fail("tests/warnings/let-without-block.rs"); + config.compile_fail("tests/warnings/non-closed-element.rs"); + config.compile_fail("tests/warnings-stable/*.rs"); +} diff --git a/maud/tests/warnings-stable/keyword-without-at.rs b/maud/tests/warnings-stable/keyword-without-at.rs new file mode 100644 index 00000000..3c84dba7 --- /dev/null +++ b/maud/tests/warnings-stable/keyword-without-at.rs @@ -0,0 +1,11 @@ +use maud::html; + +fn main() { + html! { + if {} + else {} + for {} + while {} + match {} + }; +} diff --git a/maud/tests/warnings-stable/keyword-without-at.stderr b/maud/tests/warnings-stable/keyword-without-at.stderr new file mode 100644 index 00000000..0bc7c2e5 --- /dev/null +++ b/maud/tests/warnings-stable/keyword-without-at.stderr @@ -0,0 +1,34 @@ +error: found keyword `if` + = help: should this be `@if`? + --> tests/warnings-stable/keyword-without-at.rs:5:9 + | +5 | if {} + | ^^ + +error: found keyword `else` + = help: should this be `@else`? + --> tests/warnings-stable/keyword-without-at.rs:6:9 + | +6 | else {} + | ^^^^ + +error: found keyword `for` + = help: should this be `@for`? + --> tests/warnings-stable/keyword-without-at.rs:7:9 + | +7 | for {} + | ^^^ + +error: found keyword `while` + = help: should this be `@while`? + --> tests/warnings-stable/keyword-without-at.rs:8:9 + | +8 | while {} + | ^^^^^ + +error: found keyword `match` + = help: should this be `@match`? + --> tests/warnings-stable/keyword-without-at.rs:9:9 + | +9 | match {} + | ^^^^^ diff --git a/maud/tests/warnings-stable/non-string-literal.rs b/maud/tests/warnings-stable/non-string-literal.rs new file mode 100644 index 00000000..fbf6f3bf --- /dev/null +++ b/maud/tests/warnings-stable/non-string-literal.rs @@ -0,0 +1,16 @@ +use maud::html; + +fn main() { + html! { + 42 + 42usize + 42.0 + 'a' + b"a" + b'a' + + // `true` and `false` are only considered literals in attribute values + input disabled=true; + input disabled=false; + }; +} diff --git a/maud/tests/warnings-stable/non-string-literal.stderr b/maud/tests/warnings-stable/non-string-literal.stderr new file mode 100644 index 00000000..66722c8b --- /dev/null +++ b/maud/tests/warnings-stable/non-string-literal.stderr @@ -0,0 +1,51 @@ +error: literal must be double-quoted: `"42"` + --> tests/warnings-stable/non-string-literal.rs:5:9 + | +5 | 42 + | ^^ + +error: literal must be double-quoted: `"42usize"` + --> tests/warnings-stable/non-string-literal.rs:6:9 + | +6 | 42usize + | ^^^^^^^ + +error: literal must be double-quoted: `"42.0"` + --> tests/warnings-stable/non-string-literal.rs:7:9 + | +7 | 42.0 + | ^^^^ + +error: literal must be double-quoted: `"a"` + --> tests/warnings-stable/non-string-literal.rs:8:9 + | +8 | 'a' + | ^^^ + +error: expected string + --> tests/warnings-stable/non-string-literal.rs:9:9 + | +9 | b"a" + | ^^^^ + +error: expected string + --> tests/warnings-stable/non-string-literal.rs:10:9 + | +10 | b'a' + | ^^^^ + +error: attribute value must be a string + = help: to declare an empty attribute, omit the equals sign: `disabled` + = help: to toggle the attribute, use square brackets: `disabled[some_boolean_flag]` + --> tests/warnings-stable/non-string-literal.rs:13:15 + | +13 | input disabled=true; + | ^^^^^^^^^^^^^ + +error: attribute value must be a string + = help: to declare an empty attribute, omit the equals sign: `disabled` + = help: to toggle the attribute, use square brackets: `disabled[some_boolean_flag]` + --> tests/warnings-stable/non-string-literal.rs:14:15 + | +14 | input disabled=false; + | ^^^^^^^^^^^^^^ diff --git a/maud/tests/warnings-stable/void-element-slash.rs b/maud/tests/warnings-stable/void-element-slash.rs new file mode 100644 index 00000000..2bd0ff03 --- /dev/null +++ b/maud/tests/warnings-stable/void-element-slash.rs @@ -0,0 +1,9 @@ +use maud::html; + +fn main() { + html! { + br / + // Make sure we're not stopping on the first error + input type="text" / + }; +} diff --git a/maud/tests/warnings-stable/void-element-slash.stderr b/maud/tests/warnings-stable/void-element-slash.stderr new file mode 100644 index 00000000..e2d47836 --- /dev/null +++ b/maud/tests/warnings-stable/void-element-slash.stderr @@ -0,0 +1,15 @@ +error: void elements must use `;`, not `/` + = help: change this to `;` + = help: see https://github.com/lambda-fairy/maud/pull/315 for details + --> tests/warnings-stable/void-element-slash.rs:5:12 + | +5 | br / + | ^ + +error: void elements must use `;`, not `/` + = help: change this to `;` + = help: see https://github.com/lambda-fairy/maud/pull/315 for details + --> tests/warnings-stable/void-element-slash.rs:7:27 + | +7 | input type="text" / + | ^