Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: E0277 trait bound not satisfied due to supertrait when using workspaces
Trying to refactor a function into a library workspace ui
, but getting an error equivalent to the message below.
1 error[E0277]: the trait bound `B: egui_taffy::TuiBuilderLogic<'_>` is not satisfied
--> features/src/main.rs:123:45
|
123 | ui::folder_browse::folder_browse_ui(self, app.folder_browse.as_slice())
| ----------------------------------- ^^^^ the trait `egui_taffy::AsTuiBuilder<'_>` is not implemented for `B`
| |
| required by a bound introduced by this call
|
= note: required for `B` to implement `egui_taffy::TuiBuilderLogic<'_>`
note: required by a bound in `folder_browse_ui`
--> /mnt/home/files/projects/2024-house-key-pin-decode/04-rust-burn-ml-key-nn/2-sscce-rust-supertrait-error/ui/src/folder_browse.rs
:18:16
|
17 | pub fn folder_browse_ui<'a>(
| ---------------- required by a bound in this function
18 | _tui: impl egui_taffy::TuiBuilderLogic<'a>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `folder_browse_ui`
help: consider further restricting type parameter `B` with trait `AsTuiBuilder`
|
118 | B: egui_taffy::TuiBuilderLogic<'a> + egui_taffy::AsTuiBuilder<'_>,
| ++++++++++++++++++++++++++++++
For more information about this error, try `rustc --explain E0277`.
error: could not compile `dataset-editor` (bin "dataset-editor") due to 1 previous error
I reduced my project to an SSCCE[1] on github[2]. This produced the error message above.
[1]: sscce.org
[2]: GitHub - boxofrox/sscce-rust-error-bound-requires-supertrait
I tried to create the equivalent playground[3] (without workspaces), but it compiles as expected (much like my project before refactoring).
[3]: Rust Playground
What was I refactoring? I moved pub fn folder_browse_ui<'a>(impl TuiBuilderLogic<'a>, ...)
from impl MyApp
into a free function in the workspace ui
.
I don't understand this error message. The function takes an implementor of TuiBuilderLogic<'a>
. The extension trait TuiBuilderLogicExt
requires Self: TuiBuilderLogic<'a>
.
I see apples matching apples for the generic type bounds, yet the error claims I'm missing a supertrait bound, which one would think would already be implied as a bound, since trait TuiBuilderLogic<'a>: AsTuiBuilder<'a>
in the egui_taffy
crate.
Let's assume Rust is doing the sensible thing here. Adding the supertrait bound as recommended does not resolve the error. The subsequent error wants me to add the supertrait bound a second time.
I expect the code to compile without error, instead of generating this error message.
Can anyone explain what's producing the error and how to fix it?
1 post - 1 participant
🏷️ rust_feed