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

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

Open
isaka-james opened this issue Nov 23, 2024 · 1 comment · May be fixed by #513
Open

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

isaka-james opened this issue Nov 23, 2024 · 1 comment · May be fixed by #513
Assignees

Comments

@isaka-james
Copy link

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

@tsatke
Copy link

tsatke commented Nov 24, 2024

Caused by rust-lang/rust/pull/130867

For now, I'd suggest you use a nightly version before that PR was merged until a version containing the fix is released.

@Freax13 Freax13 self-assigned this Nov 24, 2024
@Freax13 Freax13 linked a pull request Nov 24, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

3 participants