StarArawn / bevy_ecs_tilemap

A tilemap rendering crate for bevy which is more ECS friendly.
MIT License
943 stars 199 forks source link

Compile error: crate-private type `RenderChunkSize` in public interface #519

Closed fkallevik closed 8 months ago

fkallevik commented 8 months ago

Getting an error when trying to run my Bevy game after updating to bevy_ecs_tilemap 0.12.0.

Compiling bevy_ecs_tilemap v0.12.0:

error[E0446]: crate-private type `RenderChunkSize` in public interface
  --> /path/bevy_ecs_tilemap/src/render/chunk.rs:39:5
   |
39 | /     pub fn get_or_add(
40 | |         &mut self,
41 | |         tile_entity: Entity,
42 | |         tile_pos: UVec2,
...  |
57 | |         y_sort: bool,
58 | |     ) -> &mut RenderChunk2d {
   | |___________________________^ can't leak crate-private type
   |
  ::: /path/bevy_ecs_tilemap/src/render/mod.rs:63:1
   |
63 |   pub(crate) struct RenderChunkSize(UVec2);
   |   --------------------------------- `RenderChunkSize` declared as crate-private

The following patch fixes the error:

diff --git i/src/render/mod.rs w/src/render/mod.rs
index 4b41c3a..cd410ee 100644
--- i/src/render/mod.rs
+++ w/src/render/mod.rs
@@ -60,7 +60,7 @@ pub struct DefaultSampler(ImageSamplerDescriptor);
 /// Initialized from [`TilemapRenderSettings`](crate::map::TilemapRenderSettings) resource, if
 /// provided. Otherwise, defaults to `64 x 64`.
 #[derive(Debug, Copy, Clone, Deref)]
-pub(crate) struct RenderChunkSize(UVec2);
+pub struct RenderChunkSize(UVec2);

 impl RenderChunkSize {
     pub const fn new(chunk_size: UVec2) -> RenderChunkSize {
StarArawn commented 8 months ago

huh strange, I wonder why CI didn't catch this..

rparrett commented 8 months ago

I have been trying to reproduce this error with stable and nightly rust, native or web targets without any luck. My own project using bevy_ecs_tilemap 0.12.0 seems to work fine.

There does seem to be a lot of unnecessary pub laying around, but I'm not seeing how this particular type is exported anywhere.

How can I reproduce this?

rparrett commented 8 months ago

I can reproduce, but only with Rust 1.72. If you are able to, you can update to the latest stable rust as a workaround.

We should still fix this.

fkallevik commented 8 months ago

Good catch @rparrett ! I can confirm the error disappears after updating to Rust 1.76.

CalinZBaenen commented 8 months ago

I think this issue should be closed; it seems the issue has been resolved.

fkallevik commented 8 months ago

@CalinZBaenen The error only occurs for rust version <= 1.72, so that's probably why CI didn't catch it.