diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..e6aa557 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,4 @@ +[term] +# Set `color` to `auto` in case the user has set it to `always`, which would +# cause divergence in compiler output and break the trybuild tests. +color = "auto" diff --git a/tree_hash/tests/compile_fail/duplicate_variant_selector.rs b/tree_hash/tests/compile_fail/duplicate_variant_selector.rs new file mode 100644 index 0000000..3a0e738 --- /dev/null +++ b/tree_hash/tests/compile_fail/duplicate_variant_selector.rs @@ -0,0 +1,11 @@ +//! More than one selector in a variant-level `tree_hash` attribute must be rejected. +use tree_hash_derive::TreeHash; + +#[derive(TreeHash)] +#[tree_hash(enum_behaviour = "compatible_union")] +enum Foo { + #[tree_hash(selector = "1", selector = "2")] + A(u8), +} + +fn main() {} diff --git a/tree_hash/tests/compile_fail/duplicate_variant_selector.stderr b/tree_hash/tests/compile_fail/duplicate_variant_selector.stderr new file mode 100644 index 0000000..4a5470c --- /dev/null +++ b/tree_hash/tests/compile_fail/duplicate_variant_selector.stderr @@ -0,0 +1,7 @@ +error: proc-macro derive panicked + --> tests/compile_fail/duplicate_variant_selector.rs:4:10 + | +4 | #[derive(TreeHash)] + | ^^^^^^^^ + | + = help: message: failed to parse variant attribute for "A": Duplicate field `selector`; note that `selector` must be an integer in 1..=127