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

Confusing error message when trait bound is "satisfied" from different version of same crate #73560

Open
bugadani opened this issue Jun 20, 2020 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. D-confusing Diagnostics: Confusing error or lint that should be reworked. D-crate-version-mismatch Diagnostics: Errors or lints caused be the use of two different crate versions. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@bugadani
Copy link
Contributor

bugadani commented Jun 20, 2020

Hi!

I was trying to make the following extension to heapless in my project:

use heapless::spsc::Consumer;
use heapless::spsc::MultiCore;
use generic_array::ArrayLength;
pub trait ConsumerExt {
    fn flush(&mut self);
}

impl<T, N> ConsumerExt for Consumer<'_, T, N, usize, MultiCore>
where
    N: ArrayLength<T>,
{
    fn flush(&mut self) {
        while self.dequeue().is_some() {}
    }
}

In this case, the compatible type is reexported as heapless::ArrayLength;
I now understand that my generic_array::ArrayLength was from a mismatching version of generic_array. Regardless, the error message is extremely confusing:

error[E0277]: the trait bound `N: generic_array::ArrayLength<T>` is not satisfied
  --> src\utils\mod.rs:58:14
   |
58 |     fn flush(&mut self) {
   |              ^^^^^^^^^ the trait `generic_array::ArrayLength<T>` is not implemented for `N`
   | 
  ::: C:\Users\bugad\.cargo\registry\src\github.com-1285ae84e5963aae\heapless-0.5.5\src\spsc\split.rs:35:8
   |
35 |     N: ArrayLength<T>,
   |        -------------- required by this bound in `heapless::spsc::split::Consumer`
   |
help: consider further restricting this bound
   |
56 |     N: ArrayLength<T> + generic_array::ArrayLength<T>,
@jonas-schievink jonas-schievink added A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 20, 2020
@estebank estebank added D-crate-version-mismatch Diagnostics: Errors or lints caused be the use of two different crate versions. D-confusing Diagnostics: Confusing error or lint that should be reworked. labels Jun 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. D-confusing Diagnostics: Confusing error or lint that should be reworked. D-crate-version-mismatch Diagnostics: Errors or lints caused be the use of two different crate versions. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants