sos-os / alarm

ALARM: Another Library for Allocating and Releasing Memory
Apache License 2.0
8 stars 6 forks source link

Not compiling properly #26

Closed leshow closed 6 years ago

leshow commented 6 years ago

I was thinking of taking an issue so I cloned the project and ran cargo build from the root dir, all appears to compile fine. I tried to add the extend trait for doubly behind a #[cfg(any(feature="alloc", feature = "std", test))]

However cargo build seems to just skip over the code there (I can leave typos in it and everything will still compile).

I'm wondering what I'm missing to get your library to compile? I tried compiling intruder_alarm independently also with --features="std" and this produces a bunch of errors:

error[E0307]: invalid `self` type: &mut doubly::List<T, Node, [type error]>
   --> intruder_alarm/src/doubly/mod.rs:364:23
    |
364 |     pub fn push_front(&mut self, item: T) -> &mut Self {
    |                       ^^^^^^^^^
    |
    = note: type must be `doubly::List<T, Node, [type error]>` or a type that dereferences to it`
    = help: consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`

How are you meant to build this library? How do you get everything to build behind the conditional compilation features?

hawkw commented 6 years ago

Hi @leshow, that looks like a bug --- I haven't yet set up a CI build for the std feature flag; the test task builds fine so I was foolishly assuming --features="std" would also work. I'll fix this.

leshow commented 6 years ago

Yes I was able to write some new code and runs tests fine. I think it's possible 'alloc' should to be added as a feature to intruder_alarm? It has cfg(feature="alloc") flags but the feature is absent from Cargo.toml

hawkw commented 6 years ago

@leshow yeah, that's correct. I think #27 should fix all the issues you're seeing, can you check it out and confirm?

hawkw commented 6 years ago

(well, fixes everything except for cargo build -p $PACKAGE --features $WHATEVER not passing features to the specified package as one would expect, but that's not our fault...)

leshow commented 6 years ago

I tried your branch and it builds fine, thanks. Off topic, but can I ask if there's a reason you write the bounds like:

where
    Node: Linked,
    Node: Into<T>,

as opposed to:

Node: Linked + Into<T>

I assume they are equivalent.

hawkw commented 6 years ago

@leshow yes, they should be equivalent; I've just gotten into the habit of writing each bound on a separate line because it's the convention of some other projects I contribute to. Don't feel obligated to write bounds that way here --- rustfmt won't enforce whether to use the + or separate bounds.