sos-os / kernel

The Stupid Operating System
Apache License 2.0
264 stars 16 forks source link

iter::Step trait functions have changed #114

Closed hawkw closed 6 years ago

hawkw commented 6 years ago

build errors:

   Compiling memory v0.0.1 (file:///Users/eliza/Code/sos-kernel/memory)
error[E0407]: method `step` is not a member of trait `core::iter::Step`
   --> memory/src/macros.rs:229:13
    |
229 | /             fn step(&self, by: &Self) -> Option<Self> {
230 | |                 self.number
231 | |                     .step(&by.number)
232 | |                     .map(|s| $ty { number: s})
233 | |             }
    | |_____________^ not a member of trait `core::iter::Step`
    |
   ::: memory/src/arch/x86_64/mod.rs
    |
34  |       #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Page!(PAddr) )]
    |  ___________________________________________________________-
35  | |     pub struct PhysicalPage { pub number: u64 }
36  | | }
37  | | impl fmt::Debug for PhysicalPage {
...   |

error[E0407]: method `steps_between_by_one` is not a member of trait `core::iter::Step`
   --> memory/src/macros.rs:247:13
    |
247 | /             fn steps_between_by_one(start: &$ty, end: &$ty) -> Option<usize> {
248 | |                 use ::core::iter::Step;
249 | |                 <<$addr as Addr>::Repr as Step>::steps_between( &start.number
250 | |                                                               , &end.number
251 | |                                                               , &1
252 | |                                                               )
253 | |             }
    | |_____________^ not a member of trait `core::iter::Step`
    |
   ::: memory/src/arch/x86_64/mod.rs
    |
34  |       #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Page!(PAddr) )]
    |  ___________________________________________________________-
35  | |     pub struct PhysicalPage { pub number: u64 }
36  | | }
37  | | impl fmt::Debug for PhysicalPage {
...   |

error[E0407]: method `is_negative` is not a member of trait `core::iter::Step`
   --> memory/src/macros.rs:263:23
    |
263 |               #[inline] fn is_negative(&self) -> bool { unimplemented!(); }
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `core::iter::Step`
    |
   ::: memory/src/arch/x86_64/mod.rs
    |
34  |       #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Page!(PAddr) )]
    |  ___________________________________________________________-
35  | |     pub struct PhysicalPage { pub number: u64 }
36  | | }
37  | | impl fmt::Debug for PhysicalPage {
...   |

error[E0407]: method `step` is not a member of trait `core::iter::Step`
   --> memory/src/macros.rs:229:13
    |
229 | /             fn step(&self, by: &Self) -> Option<Self> {
230 | |                 self.number
231 | |                     .step(&by.number)
232 | |                     .map(|s| $ty { number: s})
233 | |             }
    | |_____________^ not a member of trait `core::iter::Step`
    |
   ::: memory/src/lib.rs
    |
160 |       #[derive( Copy, Clone, Eq, Ord, PartialEq, PartialOrd, Page!(VAddr) )]
    |  ____________________________________________________________-
161 | |     pub struct VirtualPage { pub number: usize }
162 | | }
163 | |
...   |
222 | |
223 | |     /// Remove `n` pages from the beginning of this `PageRange`
    | |___________________________________- in this macro invocation

error[E0407]: method `steps_between_by_one` is not a member of trait `core::iter::Step`
   --> memory/src/macros.rs:247:13
    |
247 | /             fn steps_between_by_one(start: &$ty, end: &$ty) -> Option<usize> {
248 | |                 use ::core::iter::Step;
249 | |                 <<$addr as Addr>::Repr as Step>::steps_between( &start.number
250 | |                                                               , &end.number
251 | |                                                               , &1
252 | |                                                               )
253 | |             }
    | |_____________^ not a member of trait `core::iter::Step`
    |
   ::: memory/src/lib.rs
    |
160 |       #[derive( Copy, Clone, Eq, Ord, PartialEq, PartialOrd, Page!(VAddr) )]
    |  ____________________________________________________________-
161 | |     pub struct VirtualPage { pub number: usize }
162 | | }
163 | |
...   |
222 | |
223 | |     /// Remove `n` pages from the beginning of this `PageRange`
    | |___________________________________- in this macro invocation

error[E0407]: method `is_negative` is not a member of trait `core::iter::Step`
   --> memory/src/macros.rs:263:23
    |
263 |               #[inline] fn is_negative(&self) -> bool { unimplemented!(); }
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `core::iter::Step`
    |
   ::: memory/src/lib.rs
    |
160 |       #[derive( Copy, Clone, Eq, Ord, PartialEq, PartialOrd, Page!(VAddr) )]
    |  ____________________________________________________________-
161 | |     pub struct VirtualPage { pub number: usize }
162 | | }
163 | |
...   |
222 | |
223 | |     /// Remove `n` pages from the beginning of this `PageRange`
    | |___________________________________- in this macro invocation

error[E0050]: method `steps_between` has 3 parameters but the declaration in trait `core::iter::Step::steps_between` has 2
   --> memory/src/macros.rs:237:58
    |
237 |               fn steps_between(start: &$ty, end: &$ty, by: &$ty)
    |                                                            ^^^^ expected 2 parameters, found 3
    |
   ::: memory/src/arch/x86_64/mod.rs
    |
34  |       #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Page!(PAddr) )]
    |  ___________________________________________________________-
35  | |     pub struct PhysicalPage { pub number: u64 }
36  | | }
37  | | impl fmt::Debug for PhysicalPage {
...   |
    |
    = note: `steps_between` from trait: `fn(&Self, &Self) -> core::option::Option<usize>`

error[E0046]: not all trait items implemented, missing: `add_usize`
   --> memory/src/macros.rs:227:9
    |
227 |           impl ::core::iter::Step for $ty {
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `add_usize` in implementation
    |
   ::: memory/src/arch/x86_64/mod.rs
    |
34  |       #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Page!(PAddr) )]
    |  ___________________________________________________________-
35  | |     pub struct PhysicalPage { pub number: u64 }
36  | | }
37  | | impl fmt::Debug for PhysicalPage {
...   |
    |
    = note: `add_usize` from trait: `fn(&Self, usize) -> core::option::Option<Self>`

error[E0050]: method `steps_between` has 3 parameters but the declaration in trait `core::iter::Step::steps_between` has 2
   --> memory/src/macros.rs:237:58
    |
237 |               fn steps_between(start: &$ty, end: &$ty, by: &$ty)
    |                                                            ^^^^ expected 2 parameters, found 3
    |
   ::: memory/src/lib.rs
    |
160 |       #[derive( Copy, Clone, Eq, Ord, PartialEq, PartialOrd, Page!(VAddr) )]
    |  ____________________________________________________________-
161 | |     pub struct VirtualPage { pub number: usize }
162 | | }
163 | |
...   |
222 | |
223 | |     /// Remove `n` pages from the beginning of this `PageRange`
    | |___________________________________- in this macro invocation
    |
    = note: `steps_between` from trait: `fn(&Self, &Self) -> core::option::Option<usize>`

error[E0046]: not all trait items implemented, missing: `add_usize`
   --> memory/src/macros.rs:227:9
    |
227 |           impl ::core::iter::Step for $ty {
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `add_usize` in implementation
    |
   ::: memory/src/lib.rs
    |
160 |       #[derive( Copy, Clone, Eq, Ord, PartialEq, PartialOrd, Page!(VAddr) )]
    |  ____________________________________________________________-
161 | |     pub struct VirtualPage { pub number: usize }
162 | | }
163 | |
...   |
222 | |
223 | |     /// Remove `n` pages from the beginning of this `PageRange`
    | |___________________________________- in this macro invocation
    |
    = note: `add_usize` from trait: `fn(&Self, usize) -> core::option::Option<Self>`

error: aborting due to 10 previous errors

error: Could not compile `memory`.
hawkw commented 6 years ago

Basically it looks like:

Refer to the docs for details: https://doc.rust-lang.org/std/iter/trait.Step.html

These implementations are generated in a macro, which just wraps the underlying field self.number's iter::Step implementation, so updating this should be pretty easy: https://github.com/hawkw/sos-kernel/blob/c84ca3b08e621f857bdb05367421a1487e2ab0a4/memory/src/macros.rs#L227-L265