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

std:: vs core:: namespace and other build errors #11

Open
mjt0k opened this issue Nov 30, 2024 · 0 comments
Open

std:: vs core:: namespace and other build errors #11

mjt0k opened this issue Nov 30, 2024 · 0 comments

Comments

@mjt0k
Copy link

mjt0k commented Nov 30, 2024

I'm trying to build this crate on debian, since btree is a new dependency of virtiofsd. But I'm having some.. issues with it.

$ cargo test --all-targets --no-default-features --features allimpls

This gives me numerous errors:

error[E0433]: failed to resolve: use of undeclared crate or module `std`
   --> src/impls/smallvec.rs:113:18
    |
113 |     type Iter<'a> = std::slice::Iter<'a, A::Item> where Self: 'a;
    |                     ^^^ use of undeclared crate or module `std`

This is because of no_std feature. But in this place (and a few others), it should be core::slice, not std::slice - it's a commonly confused thing it seems. Apparently this crate has never been test-run by cargo.

Another large source of errors is examples/ordered.rs:

error[E0277]: the trait bound `std::vec::Vec<i32>: CollectionRef` is not satisfied
  --> examples/ordered.rs:57:2
   |
57 |     ordered_stack_usage::<Vec<i32>>(); // a `Vec` is a stack so it works.
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `CollectionRef` is not implemented for `std::vec::Vec<i32>`
   |
   = help: the following other types implement trait `CollectionRef`:
             HashMap<K, V>
             HashSet<T>

error[E0277]: the trait bound `std::vec::Vec<i32>: PushBack` is not satisfied
  --> examples/ordered.rs:57:24
   |
57 |     ordered_stack_usage::<Vec<i32>>(); // a `Vec` is a stack so it works.
   |                           ^^^^^^^^ the trait `PushBack` is not implemented for `std::vec::Vec<i32>`
   |
note: required by a bound in `ordered_stack_usage`
  --> examples/ordered.rs:47:48
   |
45 |     fn ordered_stack_usage<S>()
   |        ------------------- required by a bound in this function
46 |     where
47 |         S: Default + Collection<Item = i32> + Back + PushBack,
   |                                                      ^^^^^^^^ required by this bound in `ordered_stack_usage`

error[E0277]: the trait bound `std::vec::Vec<i32>: Back` is not satisfied
  --> examples/ordered.rs:57:24
   |
57 |     ordered_stack_usage::<Vec<i32>>(); // a `Vec` is a stack so it works.
   |                           ^^^^^^^^ the trait `Get<usize>` is not implemented for `std::vec::Vec<i32>`, which is required by `std::vec::Vec<i32>: Back`
   |
   = help: the following other types implement trait `Get<T>`:
             HashMap<K, V>
             HashSet<T>
   = note: required for `std::vec::Vec<i32>` to implement `Back`
note: required by a bound in `ordered_stack_usage`
  --> examples/ordered.rs:47:41
   |
45 |     fn ordered_stack_usage<S>()
   |        ------------------- required by a bound in this function
46 |     where
47 |         S: Default + Collection<Item = i32> + Back + PushBack,
   |                                               ^^^^ required by this bound in `ordered_stack_usage`

error[E0277]: the trait bound `std::vec::Vec<i32>: Back` is not satisfied
  --> examples/ordered.rs:57:24
   |
57 |     ordered_stack_usage::<Vec<i32>>(); // a `Vec` is a stack so it works.
   |                           ^^^^^^^^ the trait `Len` is not implemented for `std::vec::Vec<i32>`, which is required by `std::vec::Vec<i32>: Back`
   |
   = help: the following other types implement trait `Len`:
             HashMap<K, V>
             HashSet<T>
   = note: required for `std::vec::Vec<i32>` to implement `Back`
note: required by a bound in `ordered_stack_usage`

etc.

For now, for virtiofsd needs, I disabled ijson, serde_json (lots of errors in there) and removed examples/ordered.rs, fixed s/std/core/ in a few places, and also patched out nightly feature. But apparently this can be fixed upstream for benefit of all :)

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

No branches or pull requests

1 participant