Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples won't compile #759

Open
philipp-schmidt opened this issue Jan 3, 2024 · 8 comments
Open

Examples won't compile #759

philipp-schmidt opened this issue Jan 3, 2024 · 8 comments

Comments

@philipp-schmidt
Copy link

The examples won't compile and throw the following error:

   Compiling imgui-examples v0.1.0 (/tmp/imgui-rs/imgui-examples)
error[E0308]: mismatched types
   --> imgui-examples/examples/support/mod.rs:36:29
    |
36  |         .set_window_builder(builder)
    |          ------------------ ^^^^^^^ expected `WindowBuilder`, found a different `WindowBuilder`
    |          |
    |          arguments to this method are incorrect
    |
    = note: `WindowBuilder` and `WindowBuilder` have similar names, but are actually distinct types
note: `WindowBuilder` is defined in crate `winit`
   --> /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.8/src/window.rs:118:1
    |
118 | pub struct WindowBuilder {
    | ^^^^^^^^^^^^^^^^^^^^^^^^
note: `WindowBuilder` is defined in crate `winit`
   --> /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.28.7/src/window.rs:105:1
    |
105 | pub struct WindowBuilder {
    | ^^^^^^^^^^^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `winit` are being used?

Steps to get there were git clone into cargo test.

@philipp-schmidt
Copy link
Author

Steps to reproduce in docker:

docker run -it rust:latest /bin/bash
git clone https://github.com/imgui-rs/imgui-rs.git
cd imgui-rs
cargo test

Will fail with the following output:

error[E0277]: the trait bound `glutin::surface::WindowSurface: glium::glutin::surface::SurfaceTypeTrait` is not satisfied
  --> imgui-glium-renderer/examples/glium_01_basic.rs:91:47
   |
91 | fn create_window() -> (EventLoop<()>, Window, glium::Display<WindowSurface>) {
   |                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `glium::glutin::surface::SurfaceTypeTrait` is not implemented for `glutin::surface::WindowSurface`
   |
   = help: the following other types implement trait `glium::glutin::surface::SurfaceTypeTrait`:
             glium::glutin::surface::WindowSurface
             glium::glutin::surface::PbufferSurface
             glium::glutin::surface::PixmapSurface
note: required by a bound in `glium::Display`
  --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/glium-0.33.0/src/backend/glutin/mod.rs:83:23
   |
83 | pub struct Display<T: SurfaceTypeTrait + ResizeableSurface + 'static> {
   |                       ^^^^^^^^^^^^^^^^ required by this bound in `Display`

error[E0277]: the trait bound `glutin::surface::WindowSurface: glium::glutin::surface::ResizeableSurface` is not satisfied
  --> imgui-glium-renderer/examples/glium_01_basic.rs:91:47
   |
91 | fn create_window() -> (EventLoop<()>, Window, glium::Display<WindowSurface>) {
   |                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `glium::glutin::surface::ResizeableSurface` is not implemented for `glutin::surface::WindowSurface`
   |
   = help: the trait `glium::glutin::surface::ResizeableSurface` is implemented for `glium::glutin::surface::WindowSurface`
note: required by a bound in `glium::Display`
  --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/glium-0.33.0/src/backend/glutin/mod.rs:83:42
   |
83 | pub struct Display<T: SurfaceTypeTrait + ResizeableSurface + 'static> {
   |                                          ^^^^^^^^^^^^^^^^^ required by this bound in `Display`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `imgui-glium-renderer` (example "glium_01_basic") due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error[E0308]: mismatched types
   --> imgui-examples/examples/support/mod.rs:36:29
    |
36  |         .set_window_builder(builder)
    |          ------------------ ^^^^^^^ expected `WindowBuilder`, found a different `WindowBuilder`
    |          |
    |          arguments to this method are incorrect
    |
    = note: `WindowBuilder` and `WindowBuilder` have similar names, but are actually distinct types
note: `WindowBuilder` is defined in crate `winit`
   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.8/src/window.rs:118:1
    |
118 | pub struct WindowBuilder {
    | ^^^^^^^^^^^^^^^^^^^^^^^^
note: `WindowBuilder` is defined in crate `winit`
   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.28.7/src/window.rs:105:1
    |
105 | pub struct WindowBuilder {
    | ^^^^^^^^^^^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `winit` are being used?
note: method defined here
   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/glium-0.33.0/src/backend/glutin/mod.rs:321:12
    |
321 |     pub fn set_window_builder(mut self, window_builder: winit::window::WindowBuilder) -> Self {
    |            ^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
   --> imgui-examples/examples/support/mod.rs:37:16
    |
37  |         .build(&event_loop);
    |          ----- ^^^^^^^^^^^ expected `EventLoop<()>`, found a different `EventLoop<()>`
    |          |
    |          arguments to this method are incorrect
    |
    = note: `EventLoop<()>` and `EventLoop<()>` have similar names, but are actually distinct types
note: `EventLoop<()>` is defined in crate `winit`
   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.8/src/event_loop.rs:40:1
    |
40  | pub struct EventLoop<T: 'static> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `EventLoop<()>` is defined in crate `winit`
   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.28.7/src/event_loop.rs:35:1
    |
35  | pub struct EventLoop<T: 'static> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `winit` are being used?
note: method defined here
   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/glium-0.33.0/src/backend/glutin/mod.rs:333:12
    |
333 |     pub fn build(self, event_loop: &winit::event_loop::EventLoop<()>) -> (winit::window::Window,...
    |            ^^^^^

error[E0308]: mismatched types
   --> imgui-examples/examples/support/mod.rs:60:48
    |
60  |         platform.attach_window(imgui.io_mut(), &window, dpi_mode);
    |                  -------------                 ^^^^^^^ expected `Window`, found `winit::window::Window`
    |                  |
    |                  arguments to this method are incorrect
    |
    = note: `winit::window::Window` and `Window` have similar names, but are actually distinct types
note: `winit::window::Window` is defined in crate `winit`
   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.28.7/src/window.rs:44:1
    |
44  | pub struct Window {
    | ^^^^^^^^^^^^^^^^^
note: `Window` is defined in crate `winit`
   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.8/src/window.rs:54:1
    |
54  | pub struct Window {
    | ^^^^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `winit` are being used?
note: method defined here
   --> /imgui-rs/imgui-winit-support/src/lib.rs:333:12
    |
333 |     pub fn attach_window(&mut self, io: &mut Io, window: &Window, hidpi_mode: HiDpiMode) {
    |            ^^^^^^^^^^^^^

error[E0308]: mismatched types
   --> imgui-examples/examples/support/mod.rs:106:9
    |
106 |         window,
    |         ^^^^^^ expected `Window`, found `winit::window::Window`
    |
    = note: `winit::window::Window` and `Window` have similar names, but are actually distinct types
note: `winit::window::Window` is defined in crate `winit`
   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.28.7/src/window.rs:44:1
    |
44  | pub struct Window {
    | ^^^^^^^^^^^^^^^^^
note: `Window` is defined in crate `winit`
   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.8/src/window.rs:54:1
    |
54  | pub struct Window {
    | ^^^^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `winit` are being used?

For more information about this error, try `rustc --explain E0308`.
error: could not compile `imgui-examples` (example "test_window") due to 4 previous errors
error: could not compile `imgui-examples` (example "long_table") due to 4 previous errors
error: could not compile `imgui-examples` (example "text_input") due to 4 previous errors
error: could not compile `imgui-examples` (example "test_drawing_channels_split") due to 4 previous errors
error: could not compile `imgui-examples` (example "disablement") due to 4 previous errors
error: could not compile `imgui-examples` (example "keyboard") due to 4 previous errors
error: could not compile `imgui-examples` (example "creating_windows") due to 4 previous errors
error: could not compile `imgui-examples` (example "id_wrangling") due to 4 previous errors
error: could not compile `imgui-examples` (example "progress_bar") due to 4 previous errors
error: could not compile `imgui-examples` (example "long_list") due to 4 previous errors
error: could not compile `imgui-examples` (example "tables_api") due to 4 previous errors
error: could not compile `imgui-examples` (example "slider") due to 4 previous errors
error: could not compile `imgui-examples` (example "radio_button") due to 4 previous errors
error: failed to run custom build command for `sdl2-sys v0.34.5`

@avi-cenna
Copy link

I'm getting the same error.

@salvatorebenedetto
Copy link

I have the same issue and it seems ca05418 from @Rob2309 broke the examples. Checking out the commit before works fine.

The problem seems to be that there are 2 different and incompatible version of winit in the dependency tree.

One comes from imgui-winit-support version 0.29.3 while the other one is coming from glium 0.33.0 due to imgui-glium-rendered .

@Rob2309 is this not happening to you?

@pm100
Copy link

pm100 commented Feb 13, 2024

sigh, trying to find a working immediate mode rust gui. I guess this is life at the bleeding edge.

@Rob2309
Copy link
Contributor

Rob2309 commented Feb 13, 2024

Ok I am not quite sure what happened, the examples did certainly work for me at the time of my PR. The problem seems to be that the patch mentioned in my PR was not tied to a specific git commit of glium, which advanced to an incompatible state in the meantime.
I specifically mentioned that my PR is not stable enough to be merged, which happened anyways, so sorry for that.
It seems that glium 0.34.0 finally works without a cargo patch, so I will open a new PR fixing this problem shortly.

@Rob2309
Copy link
Contributor

Rob2309 commented Feb 13, 2024

#765 fixes this problem.

@philipp-schmidt
Copy link
Author

Thanks @Rob2309, much appreciated!

@ruby3141
Copy link

ruby3141 commented May 10, 2024

FYI, it seems #774 fixed this issue, and it's merged into main.
I think it's safe to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants