Skip to content

Trait Mismatch Error When Building the Project with cargo build #512

Closed
@isaka-james

Description

@isaka-james

I am currently working on a project and encountered a trait mismatch error in the x86_64 crate while building. Since I don't have time to rewrite the library, I decided to test the crate separately by cloning it and attempting to build it.

Steps I followed:

  1. Cloned the repository and tried building it on a fresh setup.
  2. Encountered the same error related to a trait mismatch in the steps_between method in the x86_64 crate.

The error message I am receiving is as follows:

error[E0053]: method `steps_between` has an incompatible type for trait
   --> /home/masterplan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/x86_64-0.15.1/src/addr.rs:362:51
    |
362 |     fn steps_between(start: &Self, end: &Self) -> Option<usize> {
    |                                                   ^^^^^^^^^^^^^ expected `(usize, Option<usize>)`, found `Option<usize>`
    |
    = note: expected signature `fn(&addr::VirtAddr, &addr::VirtAddr) -> (usize, Option<usize>)`
               found signature `fn(&addr::VirtAddr, &addr::VirtAddr) -> Option<usize>`
help: change the output type to match the trait
    |
362 |     fn steps_between(start: &Self, end: &Self) -> (usize, Option<usize>) {
    |                                                   ~~~~~~~~~~~~~~~~~~~~~~

Steps to reproduce:

  1. Clone the repository and enter the directory:

    git clone https://github.com/rust-osdev/x86_64
    cd x86-64
  2. Set the Rust toolchain to nightly (already set in my environment):

    rustup default nightly
  3. Attempt to build the project with the following command:

    cargo build

Result:
The build fails with the error related to the trait mismatch, as shown in the terminal output above.

Screenshots/Terminal Output:

Image

Image

Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @Freax13@tsatke@isaka-james

    Issue actions

      Trait Mismatch Error When Building the Project with `cargo build` · Issue #512 · rust-osdev/x86_64