You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error[[E0277]](https://doc.rust-lang.org/stable/error_codes/E0277.html): the trait bound `P: Protocol<()>` is not satisfied
--> src/main.rs:21:5
|
21 | / fn update<P>()
22 | | where
23 | | P: Protocol<Self::Event>,
24 | | P::Effect: Composite
| |____________________________^ the trait `Protocol<()>` is not implemented for `P`
|
help: consider further restricting this bound
|
23 | P: Protocol<Self::Event> + Protocol<()>,
| ++++++++++++++
error[[E0277]](https://doc.rust-lang.org/stable/error_codes/E0277.html): the trait bound `P: Protocol<()>` is not satisfied
--> src/main.rs:21:8
|
21 | fn update<P>()
| ^^^^^^ the trait `Protocol<()>` is not implemented for `P`
|
help: consider further restricting this bound
|
23 | P: Protocol<Self::Event> + Protocol<()>,
| ++++++++++++++
The code would compile is I remove P::Effect: Composite on both sites, and I don't see how this bound prevent type check.
I'm not sure whether this code should be compiled or not. If not please kindly point out the problem. But anyway, the error message makes no sense. If I blindly follow the hint, it becomes even more nonsense:
error[[E0277]](https://doc.rust-lang.org/stable/error_codes/E0277.html): the trait bound `P: Protocol<()>` is not satisfied
--> src/main.rs:19:5
|
19 | / fn update<P>()
20 | | where
21 | | P: Protocol<Self::Event> + Protocol<()>,
22 | | <P as Protocol<()>>::Effect: Composite
| |______________________________________________^ the trait `Protocol<()>` is not implemented for `P`
|
help: consider further restricting this bound
|
21 | P: Protocol<Self::Event> + Protocol<()> + Protocol<()>,
| ++++++++++++++
error[[E0276]](https://doc.rust-lang.org/stable/error_codes/E0276.html): impl has stricter requirements than trait
--> src/main.rs:21:12
|
10 | / fn update<P>()
11 | | where
12 | | P: Protocol<Self::Event>,
13 | | P::Effect: Composite;
| |_____________________________- definition of `update` from trait
...
21 | P: Protocol<Self::Event> + Protocol<()>,
| ^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `P: Protocol<()>`
I agree the error message is confusing. I probably would've wrote the same code as OP to express the bound.
I'm not sure what the type checker's reasoning for the error is, actually. Maybe t-types can chime in.
Thanks for the correction! I wonder what is the semantic difference between the two versions? To me the correct version seems a little bit counterintuitive.
I guess this issue is a duplicated to #58231, so I would close it. There has been more than hundred of "trait bound not satisfied" issues, really hard to check all of them :|
I tried this code (not sure how to further minimize it):
I expect it to compile, but get error:
The code would compile is I remove
P::Effect: Composite
on both sites, and I don't see how this bound prevent type check.I'm not sure whether this code should be compiled or not. If not please kindly point out the problem. But anyway, the error message makes no sense. If I blindly follow the hint, it becomes even more nonsense:
Meta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: