bevy/crates/bevy_reflect_compile_fail_tests
Gino Valente 5e5a305d43
bevy_reflect: Fix trailing comma breaking derives (#8014)
# Objective

Fixes #7989

Based on #7991 by @CoffeeVampir3

## Solution

There were three parts to this issue:
1. `extend_where_clause` did not account for the optionality of a where
clause's trailing comma
    ```rust
    // OKAY
    struct Foo<T> where T: Asset, {/* ... */}
    // ERROR
    struct Foo<T> where T: Asset {/* ... */}
    ```
2. `FromReflect` derive logic was not actively using
`extend_where_clause` which led to some inconsistencies (enums weren't
adding _any_ additional bounds even)
3. Using `extend_where_clause` in the `FromReflect` derive logic meant
we had to optionally add `Default` bounds to ignored fields iff the
entire item itself was not already `Default` (otherwise the definition
for `Handle<T>` wouldn't compile since `HandleType` doesn't impl
`Default` but `Handle<T>` itself does)

---

## Changelog

- Fixed issue where a missing trailing comma could break the reflection
derives
2023-03-27 21:47:33 +00:00
..
src bevy_reflect: Add compile fail tests for bevy_reflect (#7041) 2023-01-02 21:07:33 +00:00
tests bevy_reflect: Fix trailing comma breaking derives (#8014) 2023-03-27 21:47:33 +00:00
Cargo.toml bevy_reflect: Add compile fail tests for bevy_reflect (#7041) 2023-01-02 21:07:33 +00:00
README.md bevy_reflect: Add compile fail tests for bevy_reflect (#7041) 2023-01-02 21:07:33 +00:00

Compile fail tests for bevy_reflect

This crate is separate from bevy_reflect and not part of the Bevy workspace in order to not fail crater tests for Bevy. The tests assert on the exact compiler errors and can easily fail for new Rust versions due to updated compiler errors (e.g. changes in spans).

The CI workflow executes these tests on the stable rust toolchain (see tools/ci).